Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>

+9 -12
+9 -12
drivers/block/rbd.c
··· 46 46 47 47 #define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */ 48 48 49 - #define RBD_MAX_MD_NAME_LEN (96 + sizeof(RBD_SUFFIX)) 49 + #define RBD_MAX_MD_NAME_LEN (RBD_MAX_OBJ_NAME_LEN + sizeof(RBD_SUFFIX)) 50 50 #define RBD_MAX_POOL_NAME_LEN 64 51 51 #define RBD_MAX_SNAP_NAME_LEN 32 52 52 #define RBD_MAX_OPT_LEN 1024 ··· 175 175 .name = "rbd", 176 176 }; 177 177 178 - static spinlock_t node_lock; /* protects client get/put */ 178 + static DEFINE_SPINLOCK(node_lock); /* protects client get/put */ 179 179 180 180 static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */ 181 181 static LIST_HEAD(rbd_dev_list); /* devices */ ··· 324 324 substring_t argstr[MAX_OPT_ARGS]; 325 325 int token, intval, ret; 326 326 327 - token = match_token((char *)c, rbdopt_tokens, argstr); 327 + token = match_token(c, rbdopt_tokens, argstr); 328 328 if (token < 0) 329 329 return -EINVAL; 330 330 ··· 372 372 rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT; 373 373 374 374 ret = ceph_parse_options(&opt, options, mon_addr, 375 - mon_addr + strlen(mon_addr), parse_rbd_opts_token, rbd_opts); 375 + mon_addr + strlen(mon_addr), 376 + parse_rbd_opts_token, rbd_opts); 376 377 if (ret < 0) 377 378 goto done_err; 378 379 ··· 461 460 u32 snap_count = le32_to_cpu(ondisk->snap_count); 462 461 int ret = -ENOMEM; 463 462 464 - if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT))) { 463 + if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT))) 465 464 return -ENXIO; 466 - } 467 465 468 466 init_rwsem(&header->snap_rwsem); 469 467 header->snap_names_len = le64_to_cpu(ondisk->snap_names_len); 470 468 header->snapc = kmalloc(sizeof(struct ceph_snap_context) + 471 - snap_count * 472 - sizeof(struct rbd_image_snap_ondisk), 469 + snap_count * sizeof (*ondisk), 473 470 gfp_flags); 474 471 if (!header->snapc) 475 472 return -ENOMEM; ··· 497 498 header->snapc->num_snaps = snap_count; 498 499 header->total_snaps = snap_count; 499 500 500 - if (snap_count && 501 - allocated_snaps == snap_count) { 501 + if (snap_count && allocated_snaps == snap_count) { 502 502 for (i = 0; i < snap_count; i++) { 503 503 header->snapc->snaps[i] = 504 504 le64_to_cpu(ondisk->snaps[i].id); ··· 2421 2423 rbd_bus_type.bus_attrs = rbd_bus_attrs; 2422 2424 2423 2425 ret = bus_register(&rbd_bus_type); 2424 - if (ret < 0) 2426 + if (ret < 0) 2425 2427 return ret; 2426 2428 2427 2429 ret = device_register(&rbd_root_dev); ··· 2442 2444 rc = rbd_sysfs_init(); 2443 2445 if (rc) 2444 2446 return rc; 2445 - spin_lock_init(&node_lock); 2446 2447 pr_info("loaded " DRV_NAME_LONG "\n"); 2447 2448 return 0; 2448 2449 }