[sheepdog] [PATCH v2] block/sheepdog: add error handling to sd_snapshot_delete()

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Mar 22 05:51:18 CET 2016


On Tue, Mar 22, 2016 at 1:33 PM, Takashi Menjo <menjo.takashi at lab.ntt.co.jp>
wrote:

> 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(-)
>

Looks good to me.
Reviewed-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>

Vasiliy, could you test it on your environment if you have a time?

Thanks,
Hitoshi


>
> 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
>
>
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> https://lists.wpkg.org/mailman/listinfo/sheepdog
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20160322/1270f708/attachment.html>


More information about the sheepdog mailing list