Skip to content

Commit

Permalink
rbd: rename rbd_id_get()
Browse files Browse the repository at this point in the history
This should have been done as part of this commit:

    commit de71a29
    Author: Alex Elder <elder@inktank.com>
    Date:   Tue Jul 3 16:01:19 2012 -0500
    rbd: rename rbd_device->id

rbd_id_get() is assigning the rbd_dev->dev_id field.  Change the
name of that function as well as rbd_id_put() and rbd_id_max
to reflect what they are affecting.

Add some dynamic debug statements related to rbd device id activity.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent aafb230 commit e283930
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2304,41 +2304,45 @@ static int rbd_init_watch_dev(struct rbd_device *rbd_dev)
return ret;
}

static atomic64_t rbd_id_max = ATOMIC64_INIT(0);
static atomic64_t rbd_dev_id_max = ATOMIC64_INIT(0);

/*
* Get a unique rbd identifier for the given new rbd_dev, and add
* the rbd_dev to the global list. The minimum rbd id is 1.
*/
static void rbd_id_get(struct rbd_device *rbd_dev)
static void rbd_dev_id_get(struct rbd_device *rbd_dev)
{
rbd_dev->dev_id = atomic64_inc_return(&rbd_id_max);
rbd_dev->dev_id = atomic64_inc_return(&rbd_dev_id_max);

spin_lock(&rbd_dev_list_lock);
list_add_tail(&rbd_dev->node, &rbd_dev_list);
spin_unlock(&rbd_dev_list_lock);
dout("rbd_dev %p given dev id %llu\n", rbd_dev,
(unsigned long long) rbd_dev->dev_id);
}

/*
* Remove an rbd_dev from the global list, and record that its
* identifier is no longer in use.
*/
static void rbd_id_put(struct rbd_device *rbd_dev)
static void rbd_dev_id_put(struct rbd_device *rbd_dev)
{
struct list_head *tmp;
int rbd_id = rbd_dev->dev_id;
int max_id;

rbd_assert(rbd_id > 0);

dout("rbd_dev %p released dev id %llu\n", rbd_dev,
(unsigned long long) rbd_dev->dev_id);
spin_lock(&rbd_dev_list_lock);
list_del_init(&rbd_dev->node);

/*
* If the id being "put" is not the current maximum, there
* is nothing special we need to do.
*/
if (rbd_id != atomic64_read(&rbd_id_max)) {
if (rbd_id != atomic64_read(&rbd_dev_id_max)) {
spin_unlock(&rbd_dev_list_lock);
return;
}
Expand All @@ -2359,12 +2363,13 @@ static void rbd_id_put(struct rbd_device *rbd_dev)
spin_unlock(&rbd_dev_list_lock);

/*
* The max id could have been updated by rbd_id_get(), in
* The max id could have been updated by rbd_dev_id_get(), in
* which case it now accurately reflects the new maximum.
* Be careful not to overwrite the maximum value in that
* case.
*/
atomic64_cmpxchg(&rbd_id_max, rbd_id, max_id);
atomic64_cmpxchg(&rbd_dev_id_max, rbd_id, max_id);
dout(" max dev id has been reset\n");
}

/*
Expand Down Expand Up @@ -2563,7 +2568,7 @@ static ssize_t rbd_add(struct bus_type *bus,
init_rwsem(&rbd_dev->header_rwsem);

/* generate unique id: find highest unique id, add one */
rbd_id_get(rbd_dev);
rbd_dev_id_get(rbd_dev);

/* Fill in the device name, now that we have its id. */
BUILD_BUG_ON(DEV_NAME_LEN
Expand Down Expand Up @@ -2631,7 +2636,7 @@ static ssize_t rbd_add(struct bus_type *bus,
kfree(rbd_dev->image_name);
kfree(rbd_dev->pool_name);
}
rbd_id_put(rbd_dev);
rbd_dev_id_put(rbd_dev);
err_nomem:
kfree(rbd_dev);
kfree(options);
Expand Down Expand Up @@ -2683,7 +2688,7 @@ static void rbd_dev_release(struct device *dev)
kfree(rbd_dev->header_name);
kfree(rbd_dev->pool_name);
kfree(rbd_dev->image_name);
rbd_id_put(rbd_dev);
rbd_dev_id_put(rbd_dev);
kfree(rbd_dev);

/* release module ref */
Expand Down

0 comments on commit e283930

Please sign in to comment.