Skip to content

Commit

Permalink
rbd: rename rbd_device->id
Browse files Browse the repository at this point in the history
The "id" field of an rbd device structure represents the unique
client-local device id mapped to the underlying rbd image.  Each rbd
image will have another id--the image id--and each snapshot has its
own id as well.  The simple name "id" no longer conveys the
information one might like to have.

Rename the device "id" field in struct rbd_dev to be "dev_id" to
make it a little more obvious what we're dealing with without having
to think more about context.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
  • Loading branch information
Alex Elder authored and Sage Weil committed Jul 31, 2012
1 parent 8e94af8 commit de71a29
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct rbd_snap {
* a single device
*/
struct rbd_device {
int id; /* blkdev unique id */
int dev_id; /* blkdev unique id */

int major; /* blkdev assigned major */
struct gendisk *disk; /* blkdev's gendisk and rq */
Expand Down Expand Up @@ -1782,7 +1782,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
goto out;

snprintf(disk->disk_name, sizeof(disk->disk_name), RBD_DRV_NAME "%d",
rbd_dev->id);
rbd_dev->dev_id);
disk->major = rbd_dev->major;
disk->first_minor = 0;
disk->fops = &rbd_bd_ops;
Expand Down Expand Up @@ -2171,7 +2171,7 @@ static int rbd_bus_add_dev(struct rbd_device *rbd_dev)
dev->type = &rbd_device_type;
dev->parent = &rbd_root_dev;
dev->release = rbd_dev_release;
dev_set_name(dev, "%d", rbd_dev->id);
dev_set_name(dev, "%d", rbd_dev->dev_id);
ret = device_register(dev);
if (ret < 0)
goto out;
Expand Down Expand Up @@ -2219,7 +2219,7 @@ static atomic64_t rbd_id_max = ATOMIC64_INIT(0);
*/
static void rbd_id_get(struct rbd_device *rbd_dev)
{
rbd_dev->id = atomic64_inc_return(&rbd_id_max);
rbd_dev->dev_id = atomic64_inc_return(&rbd_id_max);

spin_lock(&rbd_dev_list_lock);
list_add_tail(&rbd_dev->node, &rbd_dev_list);
Expand All @@ -2233,7 +2233,7 @@ static void rbd_id_get(struct rbd_device *rbd_dev)
static void rbd_id_put(struct rbd_device *rbd_dev)
{
struct list_head *tmp;
int rbd_id = rbd_dev->id;
int rbd_id = rbd_dev->dev_id;
int max_id;

BUG_ON(rbd_id < 1);
Expand Down Expand Up @@ -2472,7 +2472,7 @@ static ssize_t rbd_add(struct bus_type *bus,
/* Fill in the device name, now that we have its id. */
BUILD_BUG_ON(DEV_NAME_LEN
< sizeof (RBD_DRV_NAME) + MAX_INT_FORMAT_WIDTH);
sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->id);
sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->dev_id);

/* parse add command */
rc = rbd_add_parse_args(rbd_dev, buf, &mon_addrs, &mon_addrs_size,
Expand Down Expand Up @@ -2549,15 +2549,15 @@ static ssize_t rbd_add(struct bus_type *bus,
return (ssize_t) rc;
}

static struct rbd_device *__rbd_get_dev(unsigned long id)
static struct rbd_device *__rbd_get_dev(unsigned long dev_id)
{
struct list_head *tmp;
struct rbd_device *rbd_dev;

spin_lock(&rbd_dev_list_lock);
list_for_each(tmp, &rbd_dev_list) {
rbd_dev = list_entry(tmp, struct rbd_device, node);
if (rbd_dev->id == id) {
if (rbd_dev->dev_id == dev_id) {
spin_unlock(&rbd_dev_list_lock);
return rbd_dev;
}
Expand Down

0 comments on commit de71a29

Please sign in to comment.