[sheepdog] [PATCH v2] block/sheepdog: add error handling to sd_snapshot_delete()
Takashi Menjo
menjo.takashi at lab.ntt.co.jp
Tue Mar 22 05:33:12 CET 2016
Errors have been ignored or not propagated in some code paths
in sd_snapshot_delete(). This patch adds error handling.
Cc: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Cc: Jeff Cody <jcody at redhat.com>
Cc: Vasiliy Tolstov <v.tolstov at selfip.ru>
Cc: sheepdog at lists.wpkg.org
Signed-off-by: Takashi Menjo <menjo.takashi at lab.ntt.co.jp>
---
block/sheepdog.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index a3aeae4..39d13d2 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2565,6 +2565,7 @@ static int sd_snapshot_delete(BlockDriverState *bs,
SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr;
if (!remove_objects(s)) {
+ error_setg(errp, "failed to discard snapshot inode");
return -1;
}
@@ -2588,12 +2589,13 @@ static int sd_snapshot_delete(BlockDriverState *bs,
ret = find_vdi_name(s, s->name, snap_id, snap_tag, &vid, true,
&local_err);
if (ret) {
+ error_propagate(errp, local_err);
return ret;
}
fd = connect_to_sdog(s, &local_err);
if (fd < 0) {
- error_report_err(local_err);
+ error_propagate(errp, local_err);
return -1;
}
@@ -2601,16 +2603,17 @@ static int sd_snapshot_delete(BlockDriverState *bs,
buf, &wlen, &rlen);
closesocket(fd);
if (ret) {
+ error_setg_errno(errp, -ret, "failed to delete %s", s->name);
return ret;
}
switch (rsp->result) {
case SD_RES_NO_VDI:
- error_report("%s was already deleted", s->name);
+ error_setg(errp, "%s was already deleted", s->name);
case SD_RES_SUCCESS:
break;
default:
- error_report("%s, %s", sd_strerror(rsp->result), s->name);
+ error_setg(errp, "%s, %s", sd_strerror(rsp->result), s->name);
return -1;
}
--
2.7.4.windows.1
More information about the sheepdog
mailing list