diff mbox

rbd: fix bug in rbd_dev_id_put()

Message ID 5076E6FE.9070400@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder Oct. 11, 2012, 3:34 p.m. UTC
In rbd_dev_id_put(), there's a loop that's intended to determine
the maximum device id in use.  But it isn't doing that at all,
the effect of how it's written is to simply use the just-put id
number, which ignores whole purpose of this function.

Fix the bug.

Signed-off-by: Alex Elder <elder@inktank.com>
---
  drivers/block/rbd.c |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Josh Durgin Oct. 24, 2012, 4:43 p.m. UTC | #1
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 10/11/2012 08:34 AM, Alex Elder wrote:
> In rbd_dev_id_put(), there's a loop that's intended to determine
> the maximum device id in use.  But it isn't doing that at all,
> the effect of how it's written is to simply use the just-put id
> number, which ignores whole purpose of this function.
>
> Fix the bug.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index ca28036..cf5d109 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2642,8 +2642,8 @@ static void rbd_dev_id_put(struct rbd_device
> *rbd_dev)
>           struct rbd_device *rbd_dev;
>
>           rbd_dev = list_entry(tmp, struct rbd_device, node);
> -        if (rbd_id > max_id)
> -            max_id = rbd_id;
> +        if (rbd_dev->dev_id > max_id)
> +            max_id = rbd_dev->dev_id;
>       }
>       spin_unlock(&rbd_dev_list_lock);
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index ca28036..cf5d109 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2642,8 +2642,8 @@  static void rbd_dev_id_put(struct rbd_device *rbd_dev)
  		struct rbd_device *rbd_dev;

  		rbd_dev = list_entry(tmp, struct rbd_device, node);
-		if (rbd_id > max_id)
-			max_id = rbd_id;
+		if (rbd_dev->dev_id > max_id)
+			max_id = rbd_dev->dev_id;
  	}
  	spin_unlock(&rbd_dev_list_lock);