diff options
author | Alex Elder <elder@inktank.com> | 2012-10-26 00:34:41 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2012-10-30 09:34:29 -0400 |
commit | 819d52bf72b61a8455024ff7863eed5d681e73c7 (patch) | |
tree | ec487d71a6f13f0c54bbc17c41e6c4b37d4b3f39 /drivers/block | |
parent | f28e565a1b15eef62618db4011d9e320089a4214 (diff) |
rbd: remove snap_name arg from rbd_add_parse_args()
The snapshot name returned by rbd_add_parse_args() just gets saved
in the rbd_dev eventually. So just do that inside that function and
do away with the snap_name argument, both in rbd_add_parse_args()
and rbd_dev_set_mapping().
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 62df67a11321..ae16cf615f02 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -665,23 +665,22 @@ static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name) | |||
665 | return -ENOENT; | 665 | return -ENOENT; |
666 | } | 666 | } |
667 | 667 | ||
668 | static int rbd_dev_set_mapping(struct rbd_device *rbd_dev, char *snap_name) | 668 | static int rbd_dev_set_mapping(struct rbd_device *rbd_dev) |
669 | { | 669 | { |
670 | int ret; | 670 | int ret; |
671 | 671 | ||
672 | if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME, | 672 | if (!memcmp(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME, |
673 | sizeof (RBD_SNAP_HEAD_NAME))) { | 673 | sizeof (RBD_SNAP_HEAD_NAME))) { |
674 | rbd_dev->snap_id = CEPH_NOSNAP; | 674 | rbd_dev->snap_id = CEPH_NOSNAP; |
675 | rbd_dev->mapping.size = rbd_dev->header.image_size; | 675 | rbd_dev->mapping.size = rbd_dev->header.image_size; |
676 | rbd_dev->mapping.features = rbd_dev->header.features; | 676 | rbd_dev->mapping.features = rbd_dev->header.features; |
677 | ret = 0; | 677 | ret = 0; |
678 | } else { | 678 | } else { |
679 | ret = snap_by_name(rbd_dev, snap_name); | 679 | ret = snap_by_name(rbd_dev, rbd_dev->snap_name); |
680 | if (ret < 0) | 680 | if (ret < 0) |
681 | goto done; | 681 | goto done; |
682 | rbd_dev->mapping.read_only = true; | 682 | rbd_dev->mapping.read_only = true; |
683 | } | 683 | } |
684 | rbd_dev->snap_name = snap_name; | ||
685 | rbd_dev->exists = true; | 684 | rbd_dev->exists = true; |
686 | done: | 685 | done: |
687 | return ret; | 686 | return ret; |
@@ -2843,8 +2842,7 @@ static inline char *dup_token(const char **buf, size_t *lenp) | |||
2843 | * Note: rbd_dev is assumed to have been initially zero-filled. | 2842 | * Note: rbd_dev is assumed to have been initially zero-filled. |
2844 | */ | 2843 | */ |
2845 | static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev, | 2844 | static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev, |
2846 | const char *buf, | 2845 | const char *buf) |
2847 | char **snap_name) | ||
2848 | { | 2846 | { |
2849 | size_t len; | 2847 | size_t len; |
2850 | const char *mon_addrs; | 2848 | const char *mon_addrs; |
@@ -2893,11 +2891,11 @@ static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2893 | err_ptr = ERR_PTR(-ENAMETOOLONG); | 2891 | err_ptr = ERR_PTR(-ENAMETOOLONG); |
2894 | goto out_err; | 2892 | goto out_err; |
2895 | } | 2893 | } |
2896 | *snap_name = kmalloc(len + 1, GFP_KERNEL); | 2894 | rbd_dev->snap_name = kmalloc(len + 1, GFP_KERNEL); |
2897 | if (!*snap_name) | 2895 | if (!rbd_dev->snap_name) |
2898 | goto out_mem; | 2896 | goto out_mem; |
2899 | memcpy(*snap_name, buf, len); | 2897 | memcpy(rbd_dev->snap_name, buf, len); |
2900 | *(*snap_name + len) = '\0'; | 2898 | *(rbd_dev->snap_name + len) = '\0'; |
2901 | 2899 | ||
2902 | /* Initialize all rbd options to the defaults */ | 2900 | /* Initialize all rbd options to the defaults */ |
2903 | 2901 | ||
@@ -3132,7 +3130,6 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3132 | size_t count) | 3130 | size_t count) |
3133 | { | 3131 | { |
3134 | struct rbd_device *rbd_dev = NULL; | 3132 | struct rbd_device *rbd_dev = NULL; |
3135 | char *snap_name; | ||
3136 | struct ceph_options *ceph_opts; | 3133 | struct ceph_options *ceph_opts; |
3137 | struct ceph_osd_client *osdc; | 3134 | struct ceph_osd_client *osdc; |
3138 | int rc = -ENOMEM; | 3135 | int rc = -ENOMEM; |
@@ -3151,7 +3148,7 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3151 | init_rwsem(&rbd_dev->header_rwsem); | 3148 | init_rwsem(&rbd_dev->header_rwsem); |
3152 | 3149 | ||
3153 | /* parse add command */ | 3150 | /* parse add command */ |
3154 | ceph_opts = rbd_add_parse_args(rbd_dev, buf, &snap_name); | 3151 | ceph_opts = rbd_add_parse_args(rbd_dev, buf); |
3155 | if (IS_ERR(ceph_opts)) { | 3152 | if (IS_ERR(ceph_opts)) { |
3156 | rc = PTR_ERR(ceph_opts); | 3153 | rc = PTR_ERR(ceph_opts); |
3157 | goto err_out_mem; | 3154 | goto err_out_mem; |
@@ -3178,7 +3175,7 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3178 | if (rc) | 3175 | if (rc) |
3179 | goto err_out_probe; | 3176 | goto err_out_probe; |
3180 | 3177 | ||
3181 | rc = rbd_dev_set_mapping(rbd_dev, snap_name); | 3178 | rc = rbd_dev_set_mapping(rbd_dev); |
3182 | if (rc) | 3179 | if (rc) |
3183 | goto err_out_snaps; | 3180 | goto err_out_snaps; |
3184 | 3181 | ||