diff options
author | Alex Elder <elder@inktank.com> | 2012-07-03 17:01:19 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2012-10-26 18:18:08 -0400 |
commit | d4b125e9eb43babd14538ba61718e3db71a98d29 (patch) | |
tree | 39e9e9c0a9a1734ada9db898763cbf1b6db3e5c8 /drivers/block | |
parent | db2388b6ee40a949084e4cdddc3b0a4357068a62 (diff) |
rbd: increase maximum snapshot name length
Change RBD_MAX_SNAP_NAME_LEN to be based on NAME_MAX. That is a
practical limit for the length of a snapshot name (based on the
presence of a directory using the name under /sys/bus/rbd to
represent the snapshot).
The /sys entry is created by prefixing it with "snap_"; define that
prefix symbolically, and take its length into account in defining
the snapshot name length limit.
Enforce the limit in rbd_add_parse_args(). Also delete a dout()
call in that function that was not meant to be committed.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4734446c3b5b..4858d925b95e 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -61,7 +61,10 @@ | |||
61 | 61 | ||
62 | #define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */ | 62 | #define RBD_MINORS_PER_MAJOR 256 /* max minors per blkdev */ |
63 | 63 | ||
64 | #define RBD_MAX_SNAP_NAME_LEN 32 | 64 | #define RBD_SNAP_DEV_NAME_PREFIX "snap_" |
65 | #define RBD_MAX_SNAP_NAME_LEN \ | ||
66 | (NAME_MAX - (sizeof (RBD_SNAP_DEV_NAME_PREFIX) - 1)) | ||
67 | |||
65 | #define RBD_MAX_SNAP_COUNT 510 /* allows max snapc to fit in 4KB */ | 68 | #define RBD_MAX_SNAP_COUNT 510 /* allows max snapc to fit in 4KB */ |
66 | #define RBD_MAX_OPT_LEN 1024 | 69 | #define RBD_MAX_OPT_LEN 1024 |
67 | 70 | ||
@@ -2063,7 +2066,7 @@ static int rbd_register_snap_dev(struct rbd_snap *snap, | |||
2063 | dev->type = &rbd_snap_device_type; | 2066 | dev->type = &rbd_snap_device_type; |
2064 | dev->parent = parent; | 2067 | dev->parent = parent; |
2065 | dev->release = rbd_snap_dev_release; | 2068 | dev->release = rbd_snap_dev_release; |
2066 | dev_set_name(dev, "snap_%s", snap->name); | 2069 | dev_set_name(dev, "%s%s", RBD_SNAP_DEV_NAME_PREFIX, snap->name); |
2067 | dout("%s: registering device for snapshot %s\n", __func__, snap->name); | 2070 | dout("%s: registering device for snapshot %s\n", __func__, snap->name); |
2068 | 2071 | ||
2069 | ret = device_register(dev); | 2072 | ret = device_register(dev); |
@@ -2797,8 +2800,13 @@ static char *rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2797 | if (!rbd_dev->image_name) | 2800 | if (!rbd_dev->image_name) |
2798 | goto out_err; | 2801 | goto out_err; |
2799 | 2802 | ||
2800 | /* Snapshot name is optional */ | 2803 | /* Snapshot name is optional; default is to use "head" */ |
2804 | |||
2801 | len = next_token(&buf); | 2805 | len = next_token(&buf); |
2806 | if (len > RBD_MAX_SNAP_NAME_LEN) { | ||
2807 | err_ptr = ERR_PTR(-ENAMETOOLONG); | ||
2808 | goto out_err; | ||
2809 | } | ||
2802 | if (!len) { | 2810 | if (!len) { |
2803 | buf = RBD_SNAP_HEAD_NAME; /* No snapshot supplied */ | 2811 | buf = RBD_SNAP_HEAD_NAME; /* No snapshot supplied */ |
2804 | len = sizeof (RBD_SNAP_HEAD_NAME) - 1; | 2812 | len = sizeof (RBD_SNAP_HEAD_NAME) - 1; |
@@ -2809,8 +2817,6 @@ static char *rbd_add_parse_args(struct rbd_device *rbd_dev, | |||
2809 | memcpy(snap_name, buf, len); | 2817 | memcpy(snap_name, buf, len); |
2810 | *(snap_name + len) = '\0'; | 2818 | *(snap_name + len) = '\0'; |
2811 | 2819 | ||
2812 | dout(" SNAP_NAME is <%s>, len is %zd\n", snap_name, len); | ||
2813 | |||
2814 | return snap_name; | 2820 | return snap_name; |
2815 | 2821 | ||
2816 | out_err: | 2822 | out_err: |