Commit 21079786 authored by Alex Elder's avatar Alex Elder

rbd: a few small cleanups

Some minor cleanups in "drivers/block/rbd.c:
    - Use the more meaningful "RBD_MAX_OBJ_NAME_LEN" in place if "96"
      in the definition of RBD_MAX_MD_NAME_LEN.
    - Use DEFINE_SPINLOCK() to define and initialize node_lock.
    - Drop a needless (char *) cast in parse_rbd_opts_token().
    - Make a few minor formatting changes.
Signed-off-by: default avatarAlex Elder <elder@dreamhost.com>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent 18fa8b3f
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */ #define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */
#define RBD_MAX_MD_NAME_LEN (96 + sizeof(RBD_SUFFIX)) #define RBD_MAX_MD_NAME_LEN (RBD_MAX_OBJ_NAME_LEN + sizeof(RBD_SUFFIX))
#define RBD_MAX_POOL_NAME_LEN 64 #define RBD_MAX_POOL_NAME_LEN 64
#define RBD_MAX_SNAP_NAME_LEN 32 #define RBD_MAX_SNAP_NAME_LEN 32
#define RBD_MAX_OPT_LEN 1024 #define RBD_MAX_OPT_LEN 1024
...@@ -175,7 +175,7 @@ static struct bus_type rbd_bus_type = { ...@@ -175,7 +175,7 @@ static struct bus_type rbd_bus_type = {
.name = "rbd", .name = "rbd",
}; };
static spinlock_t node_lock; /* protects client get/put */ static DEFINE_SPINLOCK(node_lock); /* protects client get/put */
static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */ static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */
static LIST_HEAD(rbd_dev_list); /* devices */ static LIST_HEAD(rbd_dev_list); /* devices */
...@@ -324,7 +324,7 @@ static int parse_rbd_opts_token(char *c, void *private) ...@@ -324,7 +324,7 @@ static int parse_rbd_opts_token(char *c, void *private)
substring_t argstr[MAX_OPT_ARGS]; substring_t argstr[MAX_OPT_ARGS];
int token, intval, ret; int token, intval, ret;
token = match_token((char *)c, rbdopt_tokens, argstr); token = match_token(c, rbdopt_tokens, argstr);
if (token < 0) if (token < 0)
return -EINVAL; return -EINVAL;
...@@ -372,7 +372,8 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr, ...@@ -372,7 +372,8 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT; rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT;
ret = ceph_parse_options(&opt, options, mon_addr, ret = ceph_parse_options(&opt, options, mon_addr,
mon_addr + strlen(mon_addr), parse_rbd_opts_token, rbd_opts); mon_addr + strlen(mon_addr),
parse_rbd_opts_token, rbd_opts);
if (ret < 0) if (ret < 0)
goto done_err; goto done_err;
...@@ -460,15 +461,13 @@ static int rbd_header_from_disk(struct rbd_image_header *header, ...@@ -460,15 +461,13 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
u32 snap_count = le32_to_cpu(ondisk->snap_count); u32 snap_count = le32_to_cpu(ondisk->snap_count);
int ret = -ENOMEM; int ret = -ENOMEM;
if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT))) { if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT)))
return -ENXIO; return -ENXIO;
}
init_rwsem(&header->snap_rwsem); init_rwsem(&header->snap_rwsem);
header->snap_names_len = le64_to_cpu(ondisk->snap_names_len); header->snap_names_len = le64_to_cpu(ondisk->snap_names_len);
header->snapc = kmalloc(sizeof(struct ceph_snap_context) + header->snapc = kmalloc(sizeof(struct ceph_snap_context) +
snap_count * snap_count * sizeof (*ondisk),
sizeof(struct rbd_image_snap_ondisk),
gfp_flags); gfp_flags);
if (!header->snapc) if (!header->snapc)
return -ENOMEM; return -ENOMEM;
...@@ -498,8 +497,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header, ...@@ -498,8 +497,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
header->snapc->num_snaps = snap_count; header->snapc->num_snaps = snap_count;
header->total_snaps = snap_count; header->total_snaps = snap_count;
if (snap_count && if (snap_count && allocated_snaps == snap_count) {
allocated_snaps == snap_count) {
for (i = 0; i < snap_count; i++) { for (i = 0; i < snap_count; i++) {
header->snapc->snaps[i] = header->snapc->snaps[i] =
le64_to_cpu(ondisk->snaps[i].id); le64_to_cpu(ondisk->snaps[i].id);
...@@ -2423,7 +2421,7 @@ static int rbd_sysfs_init(void) ...@@ -2423,7 +2421,7 @@ static int rbd_sysfs_init(void)
rbd_bus_type.bus_attrs = rbd_bus_attrs; rbd_bus_type.bus_attrs = rbd_bus_attrs;
ret = bus_register(&rbd_bus_type); ret = bus_register(&rbd_bus_type);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = device_register(&rbd_root_dev); ret = device_register(&rbd_root_dev);
...@@ -2444,7 +2442,6 @@ int __init rbd_init(void) ...@@ -2444,7 +2442,6 @@ int __init rbd_init(void)
rc = rbd_sysfs_init(); rc = rbd_sysfs_init();
if (rc) if (rc)
return rc; return rc;
spin_lock_init(&node_lock);
pr_info("loaded " DRV_NAME_LONG "\n"); pr_info("loaded " DRV_NAME_LONG "\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment