diff options
author | Alex Elder <elder@inktank.com> | 2012-07-03 17:01:18 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 12:30:06 -0400 |
commit | 0bed54dc9af4ab75547739a27b64f0fe0aa98756 (patch) | |
tree | 37cbf57e1866c5651b02ea539acfe0cd579b18e2 /drivers/block/rbd.c | |
parent | 0ce1a7941341cc63c8352b7df50020e5485bc43a (diff) |
rbd: rename some fields in struct rbd_dev
An rbd image is not a single object, but a logical construct made up
of an aggregation of objects.
Rename some fields in struct rbd_dev, in hopes of reinforcing this.
obj --> image_name
obj_len --> image_name_len
obj_md_name --> header_name
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 03439565c738..7a87a8c3fa34 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -161,9 +161,9 @@ struct rbd_device { | |||
161 | spinlock_t lock; /* queue lock */ | 161 | spinlock_t lock; /* queue lock */ |
162 | 162 | ||
163 | struct rbd_image_header header; | 163 | struct rbd_image_header header; |
164 | char *obj; /* rbd image name */ | 164 | char *image_name; |
165 | size_t obj_len; | 165 | size_t image_name_len; |
166 | char *obj_md_name; /* hdr nm. */ | 166 | char *header_name; |
167 | char *pool_name; | 167 | char *pool_name; |
168 | int pool_id; | 168 | int pool_id; |
169 | 169 | ||
@@ -1225,8 +1225,8 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | |||
1225 | if (!rbd_dev) | 1225 | if (!rbd_dev) |
1226 | return; | 1226 | return; |
1227 | 1227 | ||
1228 | dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n", rbd_dev->obj_md_name, | 1228 | dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n", |
1229 | notify_id, (int)opcode); | 1229 | rbd_dev->header_name, notify_id, (int) opcode); |
1230 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | 1230 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); |
1231 | rc = __rbd_refresh_header(rbd_dev); | 1231 | rc = __rbd_refresh_header(rbd_dev); |
1232 | mutex_unlock(&ctl_mutex); | 1232 | mutex_unlock(&ctl_mutex); |
@@ -1234,7 +1234,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | |||
1234 | pr_warning(RBD_DRV_NAME "%d got notification but failed to " | 1234 | pr_warning(RBD_DRV_NAME "%d got notification but failed to " |
1235 | " update snaps: %d\n", rbd_dev->major, rc); | 1235 | " update snaps: %d\n", rbd_dev->major, rc); |
1236 | 1236 | ||
1237 | rbd_req_sync_notify_ack(rbd_dev, ver, notify_id, rbd_dev->obj_md_name); | 1237 | rbd_req_sync_notify_ack(rbd_dev, ver, notify_id, rbd_dev->header_name); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | /* | 1240 | /* |
@@ -1322,7 +1322,7 @@ static void rbd_notify_cb(u64 ver, u64 notify_id, u8 opcode, void *data) | |||
1322 | return; | 1322 | return; |
1323 | 1323 | ||
1324 | dout("rbd_notify_cb %s notify_id=%lld opcode=%d\n", | 1324 | dout("rbd_notify_cb %s notify_id=%lld opcode=%d\n", |
1325 | rbd_dev->obj_md_name, | 1325 | rbd_dev->header_name, |
1326 | notify_id, (int)opcode); | 1326 | notify_id, (int)opcode); |
1327 | } | 1327 | } |
1328 | 1328 | ||
@@ -1600,7 +1600,7 @@ static int rbd_read_header(struct rbd_device *rbd_dev, | |||
1600 | 1600 | ||
1601 | rc = rbd_req_sync_read(rbd_dev, | 1601 | rc = rbd_req_sync_read(rbd_dev, |
1602 | NULL, CEPH_NOSNAP, | 1602 | NULL, CEPH_NOSNAP, |
1603 | rbd_dev->obj_md_name, | 1603 | rbd_dev->header_name, |
1604 | 0, len, | 1604 | 0, len, |
1605 | (char *)dh, &ver); | 1605 | (char *)dh, &ver); |
1606 | if (rc < 0) | 1606 | if (rc < 0) |
@@ -1610,7 +1610,8 @@ static int rbd_read_header(struct rbd_device *rbd_dev, | |||
1610 | if (rc < 0) { | 1610 | if (rc < 0) { |
1611 | if (rc == -ENXIO) | 1611 | if (rc == -ENXIO) |
1612 | pr_warning("unrecognized header format" | 1612 | pr_warning("unrecognized header format" |
1613 | " for image %s", rbd_dev->obj); | 1613 | " for image %s\n", |
1614 | rbd_dev->image_name); | ||
1614 | goto out_dh; | 1615 | goto out_dh; |
1615 | } | 1616 | } |
1616 | 1617 | ||
@@ -1666,7 +1667,7 @@ static int rbd_header_add_snap(struct rbd_device *rbd_dev, | |||
1666 | ceph_encode_string_safe(&p, e, snap_name, name_len, bad); | 1667 | ceph_encode_string_safe(&p, e, snap_name, name_len, bad); |
1667 | ceph_encode_64_safe(&p, e, new_snapid, bad); | 1668 | ceph_encode_64_safe(&p, e, new_snapid, bad); |
1668 | 1669 | ||
1669 | ret = rbd_req_sync_exec(rbd_dev, rbd_dev->obj_md_name, | 1670 | ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name, |
1670 | "rbd", "snap_add", | 1671 | "rbd", "snap_add", |
1671 | data, p - data, &ver); | 1672 | data, p - data, &ver); |
1672 | 1673 | ||
@@ -1874,7 +1875,7 @@ static ssize_t rbd_name_show(struct device *dev, | |||
1874 | { | 1875 | { |
1875 | struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); | 1876 | struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); |
1876 | 1877 | ||
1877 | return sprintf(buf, "%s\n", rbd_dev->obj); | 1878 | return sprintf(buf, "%s\n", rbd_dev->image_name); |
1878 | } | 1879 | } |
1879 | 1880 | ||
1880 | static ssize_t rbd_snap_show(struct device *dev, | 1881 | static ssize_t rbd_snap_show(struct device *dev, |
@@ -2178,7 +2179,7 @@ static int rbd_init_watch_dev(struct rbd_device *rbd_dev) | |||
2178 | int ret, rc; | 2179 | int ret, rc; |
2179 | 2180 | ||
2180 | do { | 2181 | do { |
2181 | ret = rbd_req_sync_watch(rbd_dev, rbd_dev->obj_md_name, | 2182 | ret = rbd_req_sync_watch(rbd_dev, rbd_dev->header_name, |
2182 | rbd_dev->header.obj_version); | 2183 | rbd_dev->header.obj_version); |
2183 | if (ret == -ERANGE) { | 2184 | if (ret == -ERANGE) { |
2184 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | 2185 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); |
@@ -2341,7 +2342,7 @@ static inline char *dup_token(const char **buf, size_t *lenp) | |||
2341 | } | 2342 | } |
2342 | 2343 | ||
2343 | /* | 2344 | /* |
2344 | * This fills in the pool_name, obj, obj_len, snap_name, obj_len, | 2345 | * This fills in the pool_name, image_name, image_name_len, snap_name, |
2345 | * rbd_dev, rbd_md_name, and name fields of the given rbd_dev, based | 2346 | * rbd_dev, rbd_md_name, and name fields of the given rbd_dev, based |
2346 | * on the list of monitor addresses and other options provided via | 2347 | * on the list of monitor addresses and other options provided via |
2347 | * /sys/bus/rbd/add. | 2348 | * /sys/bus/rbd/add. |
@@ -2353,7 +2354,7 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2353 | const char **mon_addrs, | 2354 | const char **mon_addrs, |
2354 | size_t *mon_addrs_size, | 2355 | size_t *mon_addrs_size, |
2355 | char *options, | 2356 | char *options, |
2356 | size_t options_size) | 2357 | size_t options_size) |
2357 | { | 2358 | { |
2358 | size_t len; | 2359 | size_t len; |
2359 | int ret; | 2360 | int ret; |
@@ -2377,18 +2378,18 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2377 | if (!rbd_dev->pool_name) | 2378 | if (!rbd_dev->pool_name) |
2378 | goto out_err; | 2379 | goto out_err; |
2379 | 2380 | ||
2380 | rbd_dev->obj = dup_token(&buf, &rbd_dev->obj_len); | 2381 | rbd_dev->image_name = dup_token(&buf, &rbd_dev->image_name_len); |
2381 | if (!rbd_dev->obj) | 2382 | if (!rbd_dev->image_name) |
2382 | goto out_err; | 2383 | goto out_err; |
2383 | 2384 | ||
2384 | /* Create the name of the header object */ | 2385 | /* Create the name of the header object */ |
2385 | 2386 | ||
2386 | rbd_dev->obj_md_name = kmalloc(rbd_dev->obj_len | 2387 | rbd_dev->header_name = kmalloc(rbd_dev->image_name_len |
2387 | + sizeof (RBD_SUFFIX), | 2388 | + sizeof (RBD_SUFFIX), |
2388 | GFP_KERNEL); | 2389 | GFP_KERNEL); |
2389 | if (!rbd_dev->obj_md_name) | 2390 | if (!rbd_dev->header_name) |
2390 | goto out_err; | 2391 | goto out_err; |
2391 | sprintf(rbd_dev->obj_md_name, "%s%s", rbd_dev->obj, RBD_SUFFIX); | 2392 | sprintf(rbd_dev->header_name, "%s%s", rbd_dev->image_name, RBD_SUFFIX); |
2392 | 2393 | ||
2393 | /* | 2394 | /* |
2394 | * The snapshot name is optional. If none is is supplied, | 2395 | * The snapshot name is optional. If none is is supplied, |
@@ -2412,8 +2413,8 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2412 | return 0; | 2413 | return 0; |
2413 | 2414 | ||
2414 | out_err: | 2415 | out_err: |
2415 | kfree(rbd_dev->obj_md_name); | 2416 | kfree(rbd_dev->header_name); |
2416 | kfree(rbd_dev->obj); | 2417 | kfree(rbd_dev->image_name); |
2417 | kfree(rbd_dev->pool_name); | 2418 | kfree(rbd_dev->pool_name); |
2418 | rbd_dev->pool_name = NULL; | 2419 | rbd_dev->pool_name = NULL; |
2419 | 2420 | ||
@@ -2517,8 +2518,8 @@ err_out_client: | |||
2517 | err_put_id: | 2518 | err_put_id: |
2518 | if (rbd_dev->pool_name) { | 2519 | if (rbd_dev->pool_name) { |
2519 | kfree(rbd_dev->snap_name); | 2520 | kfree(rbd_dev->snap_name); |
2520 | kfree(rbd_dev->obj_md_name); | 2521 | kfree(rbd_dev->header_name); |
2521 | kfree(rbd_dev->obj); | 2522 | kfree(rbd_dev->image_name); |
2522 | kfree(rbd_dev->pool_name); | 2523 | kfree(rbd_dev->pool_name); |
2523 | } | 2524 | } |
2524 | rbd_id_put(rbd_dev); | 2525 | rbd_id_put(rbd_dev); |
@@ -2560,7 +2561,7 @@ static void rbd_dev_release(struct device *dev) | |||
2560 | rbd_dev->watch_request); | 2561 | rbd_dev->watch_request); |
2561 | } | 2562 | } |
2562 | if (rbd_dev->watch_event) | 2563 | if (rbd_dev->watch_event) |
2563 | rbd_req_sync_unwatch(rbd_dev, rbd_dev->obj_md_name); | 2564 | rbd_req_sync_unwatch(rbd_dev, rbd_dev->header_name); |
2564 | 2565 | ||
2565 | rbd_put_client(rbd_dev); | 2566 | rbd_put_client(rbd_dev); |
2566 | 2567 | ||
@@ -2570,9 +2571,9 @@ static void rbd_dev_release(struct device *dev) | |||
2570 | 2571 | ||
2571 | /* done with the id, and with the rbd_dev */ | 2572 | /* done with the id, and with the rbd_dev */ |
2572 | kfree(rbd_dev->snap_name); | 2573 | kfree(rbd_dev->snap_name); |
2573 | kfree(rbd_dev->obj_md_name); | 2574 | kfree(rbd_dev->header_name); |
2574 | kfree(rbd_dev->pool_name); | 2575 | kfree(rbd_dev->pool_name); |
2575 | kfree(rbd_dev->obj); | 2576 | kfree(rbd_dev->image_name); |
2576 | rbd_id_put(rbd_dev); | 2577 | rbd_id_put(rbd_dev); |
2577 | kfree(rbd_dev); | 2578 | kfree(rbd_dev); |
2578 | 2579 | ||
@@ -2643,7 +2644,7 @@ static ssize_t rbd_snap_add(struct device *dev, | |||
2643 | mutex_unlock(&ctl_mutex); | 2644 | mutex_unlock(&ctl_mutex); |
2644 | 2645 | ||
2645 | /* make a best effort, don't error if failed */ | 2646 | /* make a best effort, don't error if failed */ |
2646 | rbd_req_sync_notify(rbd_dev, rbd_dev->obj_md_name); | 2647 | rbd_req_sync_notify(rbd_dev, rbd_dev->header_name); |
2647 | 2648 | ||
2648 | ret = count; | 2649 | ret = count; |
2649 | kfree(name); | 2650 | kfree(name); |