diff mbox

[2/2] rbd: use the correct length for format 2 object names

Message ID 1371093046-5814-2-git-send-email-josh.durgin@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Josh Durgin June 13, 2013, 3:10 a.m. UTC
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.

Reported-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
---
 drivers/block/rbd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

Alex Elder June 15, 2013, 5:05 p.m. UTC | #1
On 06/12/2013 10:10 PM, Josh Durgin wrote:
> 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.
> 
> Reported-by: Chris Dunlop <chris@onthe.net.au>
> Signed-off-by: Josh Durgin <josh.durgin@inktank.com>

Looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

>  drivers/block/rbd.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 9f72125..39ee017 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1028,12 +1028,16 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
>  	char *name;
>  	u64 segment;
>  	int ret;
> +	char *name_format;
>  
>  	name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO);
>  	if (!name)
>  		return NULL;
>  	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);
>  	if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) {
>  		pr_err("error formatting segment name for #%llu (%d)\n",
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9f72125..39ee017 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1028,12 +1028,16 @@  static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
 	char *name;
 	u64 segment;
 	int ret;
+	char *name_format;
 
 	name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO);
 	if (!name)
 		return NULL;
 	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);
 	if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) {
 		pr_err("error formatting segment name for #%llu (%d)\n",