Commit 3a96d5cd authored by Josh Durgin's avatar Josh Durgin Committed by Sage Weil

rbd: use the correct length for format 2 object names

Format 2 objects use 16 characters for the object name suffix to be
able to express the full 64-bit range of object numbers. Format 1
images only use 12 characters for this. Using 12-character names for
format 2 caused userspace and kernel rbd clients to read differently
named objects, which made an image written by one client look empty to
the other client.

CC: stable@vger.kernel.org  # 3.9+
Reported-by: default avatarChris Dunlop <chris@onthe.net.au>
Signed-off-by: default avatarJosh Durgin <josh.durgin@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent 3abef3b3
...@@ -1038,12 +1038,16 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) ...@@ -1038,12 +1038,16 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
char *name; char *name;
u64 segment; u64 segment;
int ret; int ret;
char *name_format;
name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO); name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO);
if (!name) if (!name)
return NULL; return NULL;
segment = offset >> rbd_dev->header.obj_order; segment = offset >> rbd_dev->header.obj_order;
ret = snprintf(name, MAX_OBJ_NAME_SIZE + 1, "%s.%012llx", name_format = "%s.%012llx";
if (rbd_dev->image_format == 2)
name_format = "%s.%016llx";
ret = snprintf(name, MAX_OBJ_NAME_SIZE + 1, name_format,
rbd_dev->header.object_prefix, segment); rbd_dev->header.object_prefix, segment);
if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) { if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) {
pr_err("error formatting segment name for #%llu (%d)\n", pr_err("error formatting segment name for #%llu (%d)\n",
......
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