Message ID | 1487103124-2974-14-git-send-email-idryomov@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Nit: only since you are correcting the v1 name format, it should also include 32bits of "extra" randomness (i.e. rb.<idhi>.<idlo>.<extra>.000000000000). Looks like it's documented incorrectly in librbd as well. On Tue, Feb 14, 2017 at 3:12 PM, Ilya Dryomov <idryomov@gmail.com> wrote: > ... and also fix up the comment -- format 1 data objects have always > been 12 hex digits long. > > Signed-off-by: Ilya Dryomov <idryomov@gmail.com> > --- > drivers/block/rbd.c | 6 ++---- > drivers/block/rbd_types.h | 7 ++++--- > 2 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index 47cfd5d89e69..3bc84afe5b50 100644 > --- a/drivers/block/rbd.c > +++ b/drivers/block/rbd.c > @@ -1257,18 +1257,16 @@ static void rbd_segment_name_free(const char *name) > > static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) > { > + const char *name_format = rbd_dev->image_format == 1 ? > + RBD_V1_DATA_FORMAT : RBD_V2_DATA_FORMAT; > 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; > - name_format = "%s.%012llx"; > - if (rbd_dev->image_format == 2) > - name_format = "%s.%016llx"; > ret = snprintf(name, CEPH_MAX_OID_NAME_LEN + 1, name_format, > rbd_dev->header.object_prefix, segment); > if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) { > diff --git a/drivers/block/rbd_types.h b/drivers/block/rbd_types.h > index be9c76d292f5..0a15ca3aa0f1 100644 > --- a/drivers/block/rbd_types.h > +++ b/drivers/block/rbd_types.h > @@ -25,8 +25,8 @@ > */ > > #define RBD_HEADER_PREFIX "rbd_header." > -#define RBD_DATA_PREFIX "rbd_data." > #define RBD_ID_PREFIX "rbd_id." > +#define RBD_V2_DATA_FORMAT "%s.%016llx" > > #define RBD_LOCK_NAME "rbd_lock" > #define RBD_LOCK_TAG "internal" > @@ -42,13 +42,14 @@ enum rbd_notify_op { > /* > * For format version 1, rbd image 'foo' consists of objects > * foo.rbd - image metadata > - * rb.<idhi>.<idlo>.00000000 > - * rb.<idhi>.<idlo>.00000001 > + * rb.<idhi>.<idlo>.000000000000 > + * rb.<idhi>.<idlo>.000000000001 > * ... - data > * There is no notion of a persistent image id in rbd format 1. > */ > > #define RBD_SUFFIX ".rbd" > +#define RBD_V1_DATA_FORMAT "%s.%012llx" > > #define RBD_DIRECTORY "rbd_directory" > #define RBD_INFO "rbd_info" > -- > 2.4.3 > > -- > 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 --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 47cfd5d89e69..3bc84afe5b50 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1257,18 +1257,16 @@ static void rbd_segment_name_free(const char *name) static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) { + const char *name_format = rbd_dev->image_format == 1 ? + RBD_V1_DATA_FORMAT : RBD_V2_DATA_FORMAT; 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; - name_format = "%s.%012llx"; - if (rbd_dev->image_format == 2) - name_format = "%s.%016llx"; ret = snprintf(name, CEPH_MAX_OID_NAME_LEN + 1, name_format, rbd_dev->header.object_prefix, segment); if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) { diff --git a/drivers/block/rbd_types.h b/drivers/block/rbd_types.h index be9c76d292f5..0a15ca3aa0f1 100644 --- a/drivers/block/rbd_types.h +++ b/drivers/block/rbd_types.h @@ -25,8 +25,8 @@ */ #define RBD_HEADER_PREFIX "rbd_header." -#define RBD_DATA_PREFIX "rbd_data." #define RBD_ID_PREFIX "rbd_id." +#define RBD_V2_DATA_FORMAT "%s.%016llx" #define RBD_LOCK_NAME "rbd_lock" #define RBD_LOCK_TAG "internal" @@ -42,13 +42,14 @@ enum rbd_notify_op { /* * For format version 1, rbd image 'foo' consists of objects * foo.rbd - image metadata - * rb.<idhi>.<idlo>.00000000 - * rb.<idhi>.<idlo>.00000001 + * rb.<idhi>.<idlo>.000000000000 + * rb.<idhi>.<idlo>.000000000001 * ... - data * There is no notion of a persistent image id in rbd format 1. */ #define RBD_SUFFIX ".rbd" +#define RBD_V1_DATA_FORMAT "%s.%012llx" #define RBD_DIRECTORY "rbd_directory" #define RBD_INFO "rbd_info"
... and also fix up the comment -- format 1 data objects have always been 12 hex digits long. Signed-off-by: Ilya Dryomov <idryomov@gmail.com> --- drivers/block/rbd.c | 6 ++---- drivers/block/rbd_types.h | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-)