Re: [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit()

Ilya Dryomov
2016-09-13T08:10:48Z

On Mon, Sep 12, 2016 at 9:14 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 12 Sep 2016 19:44:30 +0200
>
> Adjust a jump target so that a duplicate check can then be avoided
> at the end.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/block/rbd.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 17bdc21..66801ec 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2920,7 +2920,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
> stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0,
> OBJ_REQUEST_PAGES);
> if (!stat_request)
> - goto out;
> + goto put_request;
>
> rbd_obj_request_get(obj_request);
> stat_request->obj_request = obj_request;
> @@ -2932,7 +2932,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
> stat_request->osd_req = rbd_osd_req_create(rbd_dev, OBJ_OP_READ, 1,
> stat_request);
> if (!stat_request->osd_req)
> - goto out;
> + goto put_request;
> stat_request->callback = rbd_img_obj_exists_callback;
>
> osd_req_op_init(stat_request->osd_req, 0, CEPH_OSD_OP_STAT, 0);
> @@ -2942,8 +2942,8 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
>
> osdc = &rbd_dev->rbd_client->client->osdc;
> ret = rbd_obj_request_submit(osdc, stat_request);
> -out:
> if (ret)
> + put_request:
> rbd_obj_request_put(obj_request);
>
> return ret;
> --
> 2.10.0

Don't do this. goto into an if block is rarely a good idea, more so
when you are attempting to micro-optimize a very cold error path.

Thanks,

Ilya