Skip to contentSkip to conversation

rbd: compression_hint option

PATCH In review Ilya Dryomov 3 participants 10 messages Jun 1, 2020 – Jun 2, 2020

Subsystems (3)
lore
Share & tools
lore

Ilya Dryomov

author maintainer
#0 lore raw

cover rbd: compression_hint option

Hello,

This adds support for RADOS compressible/incompressible allocation hints, available since Kraken.

Thanks,

Ilya

Ilya Dryomov (2):
libceph: support for alloc hint flags
rbd: compression_hint option

 drivers/block/rbd.c             | 44 ++++++++++++++++++++++++++++++++-
 include/linux/ceph/osd_client.h |  4 ++-
 include/linux/ceph/rados.h      | 14 +++++++++++
 net/ceph/osd_client.c           |  8 +++++-
 4 files changed, 67 insertions(+), 3 deletions(-)
Signature · 1 line
2.19.2
author maintainer
#2 lore raw

PATCH 2/2 rbd: compression_hint option

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
 drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +42 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
 	Opt_lock_timeout,
 	/* int args above */
 	Opt_pool_ns,
+	Opt_compression_hint,
 	/* string args above */
 	Opt_read_only,
 	Opt_read_write,
@@ -844,8 +845,23 @@ enum {
 	Opt_notrim,
 };
 
+enum {
+	Opt_compression_hint_none,
+	Opt_compression_hint_compressible,
+	Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+	{"none",		Opt_compression_hint_none},
+	{"compressible",	Opt_compression_hint_compressible},
+	{"incompressible",	Opt_compression_hint_incompressible},
+	{}
+};
+
 static const struct fs_parameter_spec rbd_parameters[] = {
 	fsparam_u32	("alloc_size",			Opt_alloc_size),
+	fsparam_enum	("compression_hint",		Opt_compression_hint,
+			 rbd_param_compression_hint),
 	fsparam_flag	("exclusive",			Opt_exclusive),
 	fsparam_flag	("lock_on_read",		Opt_lock_on_read),
 	fsparam_u32	("lock_timeout",		Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
 	bool	lock_on_read;
 	bool	exclusive;
 	bool	trim;
+
+	u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
 };
 
 #define RBD_QUEUE_DEPTH_DEFAULT	BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
 		osd_req_op_alloc_hint_init(osd_req, which++,
 					   rbd_dev->layout.object_size,
 					   rbd_dev->layout.object_size,
-					   0);
+					   rbd_dev->opts->alloc_hint_flags);
 	}
 
 	if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
 		pctx->spec->pool_ns = param->string;
 		param->string = NULL;
 		break;
+	case Opt_compression_hint:
+		switch (result.uint_32) {
+		case Opt_compression_hint_none:
+			opt->alloc_hint_flags &=
+			    ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+			      CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+			break;
+		case Opt_compression_hint_compressible:
+			opt->alloc_hint_flags |=
+			    CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+			opt->alloc_hint_flags &=
+			    ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+			break;
+		case Opt_compression_hint_incompressible:
+			opt->alloc_hint_flags |=
+			    CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+			opt->alloc_hint_flags &=
+			    ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+			break;
+		default:
+			BUG();
+		}
+		break;
 	case Opt_read_only:
 		opt->read_only = true;
 		break;
Signature · 1 line
2.19.2
author maintainer
#1 lore raw

PATCH 1/2 libceph: support for alloc hint flags

In reply to Ilya Dryomov

Allow indicating future I/O pattern via flags. This is supported since Kraken (and bluestore persists flags together with expected_object_size and expected_write_size).

---
 drivers/block/rbd.c             |  3 ++-
 include/linux/ceph/osd_client.h |  4 +++-
 include/linux/ceph/rados.h      | 14 ++++++++++++++
 net/ceph/osd_client.c           |  8 +++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)
drivers/block/rbd.c +2 -1
index 74b2f00199ac..b1cd41e671d1 100644
@@ -2253,7 +2253,8 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
 	    !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) {
 		osd_req_op_alloc_hint_init(osd_req, which++,
 					   rbd_dev->layout.object_size,
-					   rbd_dev->layout.object_size);
+					   rbd_dev->layout.object_size,
+					   0);
 	}
 
 	if (rbd_obj_is_entire(obj_req))
include/linux/ceph/osd_client.h +3 -1
index 671fb93e8c60..c60b59e9291b 100644
@@ -136,6 +136,7 @@ struct ceph_osd_req_op {
 		struct {
 			u64 expected_object_size;
 			u64 expected_write_size;
+			u32 flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
 		} alloc_hint;
 		struct {
 			u64 snapid;
@@ -472,7 +473,8 @@ extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int
 extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
 				       unsigned int which,
 				       u64 expected_object_size,
-				       u64 expected_write_size);
+				       u64 expected_write_size,
+				       u32 flags);
 
 extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
 					       struct ceph_snap_context *snapc,
include/linux/ceph/rados.h +14 -0
index 88ed3c5c04c5..3a518fd0eaad 100644
@@ -464,6 +464,19 @@ enum {
 
 const char *ceph_osd_watch_op_name(int o);
 
+enum {
+	CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE = 1,
+	CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE = 2,
+	CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
+	CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ = 8,
+	CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
+	CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE = 32,
+	CEPH_OSD_ALLOC_HINT_FLAG_SHORTLIVED = 64,
+	CEPH_OSD_ALLOC_HINT_FLAG_LONGLIVED = 128,
+	CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE = 256,
+	CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE = 512,
+};
+
 enum {
 	CEPH_OSD_BACKOFF_OP_BLOCK = 1,
 	CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
@@ -517,6 +530,7 @@ struct ceph_osd_op {
 		struct {
 			__le64 expected_object_size;
 			__le64 expected_write_size;
+			__le32 flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
 		} __attribute__ ((packed)) alloc_hint;
 		struct {
 			__le64 snapid;
net/ceph/osd_client.c +7 -1
index 22733e844be1..4fea3c33af2a 100644
@@ -932,10 +932,14 @@ static void osd_req_op_watch_init(struct ceph_osd_request *req, int which,
 	op->watch.gen = 0;
 }
 
+/*
+ * @flags: CEPH_OSD_OP_ALLOC_HINT_FLAG_*
+ */
 void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
 				unsigned int which,
 				u64 expected_object_size,
-				u64 expected_write_size)
+				u64 expected_write_size,
+				u32 flags)
 {
 	struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which,
 						      CEPH_OSD_OP_SETALLOCHINT,
@@ -943,6 +947,7 @@ void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
 
 	op->alloc_hint.expected_object_size = expected_object_size;
 	op->alloc_hint.expected_write_size = expected_write_size;
+	op->alloc_hint.flags = flags;
 
 	/*
 	 * CEPH_OSD_OP_SETALLOCHINT op is advisory and therefore deemed
@@ -1018,6 +1023,7 @@ static u32 osd_req_encode_op(struct ceph_osd_op *dst,
 		    cpu_to_le64(src->alloc_hint.expected_object_size);
 		dst->alloc_hint.expected_write_size =
 		    cpu_to_le64(src->alloc_hint.expected_write_size);
+		dst->alloc_hint.flags = cpu_to_le32(src->alloc_hint.flags);
 		break;
 	case CEPH_OSD_OP_SETXATTR:
 	case CEPH_OSD_OP_CMPXATTR:
Signature · 1 line
2.19.2
Reviewed-by on the v1 series
#8 lore raw
In reply to Ilya Dryomov
Quoted 15 lines · Ilya Dryomov

Hello,

This adds support for RADOS compressible/incompressible allocation hints, available since Kraken.

Thanks,

Ilya

Ilya Dryomov (2):
libceph: support for alloc hint flags
rbd: compression_hint option

Quoted 9 lines
 drivers/block/rbd.c             | 44 ++++++++++++++++++++++++++++++++-
 include/linux/ceph/osd_client.h |  4 ++-
 include/linux/ceph/rados.h      | 14 +++++++++++
 net/ceph/osd_client.c           |  8 +++++-
 4 files changed, 67 insertions(+), 3 deletions(-)

--
2.19.2

lgtm

Signature · 1 line
Jason
Reviewed-by on the v1 series
#9 lore raw
In reply to Ilya Dryomov

Thanx

Yang

Quoted 20 lines · Ilya Dryomov

Hello,

This adds support for RADOS compressible/incompressible allocation hints, available since Kraken.

Thanks,

Ilya

Ilya Dryomov (2):
libceph: support for alloc hint flags
rbd: compression_hint option

  drivers/block/rbd.c             | 44 ++++++++++++++++++++++++++++++++-
  include/linux/ceph/osd_client.h |  4 ++-
  include/linux/ceph/rados.h      | 14 +++++++++++
  net/ceph/osd_client.c           |  8 +++++-
  4 files changed, 67 insertions(+), 3 deletions(-)
#3 lore raw
In reply to Ilya Dryomov

Hi Ilya,

Quoted 75 lines · Ilya Dryomov

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
  drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +28 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
  	Opt_lock_timeout,
  	/* int args above */
  	Opt_pool_ns,
+	Opt_compression_hint,
  	/* string args above */
  	Opt_read_only,
  	Opt_read_write,
@@ -844,8 +845,23 @@ enum {
  	Opt_notrim,
  };
 
+enum {
+	Opt_compression_hint_none,
+	Opt_compression_hint_compressible,
+	Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+	{"none",		Opt_compression_hint_none},
+	{"compressible",	Opt_compression_hint_compressible},
+	{"incompressible",	Opt_compression_hint_incompressible},
+	{}
+};
+
  static const struct fs_parameter_spec rbd_parameters[] = {
  	fsparam_u32	("alloc_size",			Opt_alloc_size),
+	fsparam_enum	("compression_hint",		Opt_compression_hint,
+			 rbd_param_compression_hint),
  	fsparam_flag	("exclusive",			Opt_exclusive),
  	fsparam_flag	("lock_on_read",		Opt_lock_on_read),
  	fsparam_u32	("lock_timeout",		Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
  	bool	lock_on_read;
  	bool	exclusive;
  	bool	trim;
+
+	u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
  };
 
  #define RBD_QUEUE_DEPTH_DEFAULT	BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
  		osd_req_op_alloc_hint_init(osd_req, which++,
  					   rbd_dev->layout.object_size,
  					   rbd_dev->layout.object_size,
-					   0);
+					   rbd_dev->opts->alloc_hint_flags);
  	}
 
  	if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
  		pctx->spec->pool_ns = param->string;
  		param->string = NULL;
  		break;
+	case Opt_compression_hint:
+		switch (result.uint_32) {
+		case Opt_compression_hint_none:
+			opt->alloc_hint_flags &=
+			    ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+			      CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+			break;
+		case Opt_compression_hint_compressible:
+			opt->alloc_hint_flags |=

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6371

Quoted 10 lines
drivers/block/rbd.c +10 -0
+			    CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+			opt->alloc_hint_flags &=
+			    ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+			break;
+		case Opt_compression_hint_incompressible:
+			opt->alloc_hint_flags |=
+			    CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+			opt->alloc_hint_flags &=
+			    ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+			break;

Just one little question here,

(1) none opt means clear compressible related bits in hint flags, then lets the compressor in bluestore to decide compress or not.

(2) compressible opt means set compressible bit and clear incompressible bit

(3) incompressible opt means set incompressible bit and clear compressible bit

Is there any scenario that alloc_hint_flags is not zero filled before rbd_parse_param(), then we have to clear the unexpected bit?

Thanx

Yang

Quoted 7 lines
drivers/block/rbd.c +4 -0
+		default:
+			BUG();
+		}
+		break;
  	case Opt_read_only:
  		opt->read_only = true;
  		break;
author maintainer
#4 lore raw
Quoted 96 lines · Dongsheng Yang

Hi Ilya,

Quoted 75 lines · Ilya Dryomov

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
  drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +28 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
      Opt_lock_timeout,
      /* int args above */
      Opt_pool_ns,
+     Opt_compression_hint,
      /* string args above */
      Opt_read_only,
      Opt_read_write,
@@ -844,8 +845,23 @@ enum {
      Opt_notrim,
  };
 
+enum {
+     Opt_compression_hint_none,
+     Opt_compression_hint_compressible,
+     Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+     {"none",                Opt_compression_hint_none},
+     {"compressible",        Opt_compression_hint_compressible},
+     {"incompressible",      Opt_compression_hint_incompressible},
+     {}
+};
+
  static const struct fs_parameter_spec rbd_parameters[] = {
      fsparam_u32     ("alloc_size",                  Opt_alloc_size),
+     fsparam_enum    ("compression_hint",            Opt_compression_hint,
+                      rbd_param_compression_hint),
      fsparam_flag    ("exclusive",                   Opt_exclusive),
      fsparam_flag    ("lock_on_read",                Opt_lock_on_read),
      fsparam_u32     ("lock_timeout",                Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
      bool    lock_on_read;
      bool    exclusive;
      bool    trim;
+
+     u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
  };
 
  #define RBD_QUEUE_DEPTH_DEFAULT     BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
              osd_req_op_alloc_hint_init(osd_req, which++,
                                         rbd_dev->layout.object_size,
                                         rbd_dev->layout.object_size,
-                                        0);
+                                        rbd_dev->opts->alloc_hint_flags);
      }
 
      if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
              pctx->spec->pool_ns = param->string;
              param->string = NULL;
              break;
+     case Opt_compression_hint:
+             switch (result.uint_32) {
+             case Opt_compression_hint_none:
+                     opt->alloc_hint_flags &=
+                         ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+                           CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+                     break;
+             case Opt_compression_hint_compressible:
+                     opt->alloc_hint_flags |=

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6371

Quoted 10 lines
drivers/block/rbd.c +10 -0
+                         CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     break;
+             case Opt_compression_hint_incompressible:
+                     opt->alloc_hint_flags |=
+                         CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     break;

Just one little question here,

(1) none opt means clear compressible related bits in hint flags, then lets the compressor in bluestore to decide compress or not.

Quoted 8 lines

(2) compressible opt means set compressible bit and clear incompressible bit

(3) incompressible opt means set incompressible bit and clear compressible bit

Is there any scenario that alloc_hint_flags is not zero filled before rbd_parse_param(), then we have to clear the unexpected bit?

Hi Dongsheng,

This is to handle the case when the map option string has multiple compression_hint options:

name=admin,...,compression_hint=compressible,...,compression_hint=none

The last one wins and we always end up with either zero or just one of the flags set, not both.

Thanks,

Ilya

#5 lore raw
Quoted 106 lines · Ilya Dryomov
Quoted 94 lines · Dongsheng Yang

Hi Ilya,

Quoted 75 lines · Ilya Dryomov

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
   drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
   1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +28 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
       Opt_lock_timeout,
       /* int args above */
       Opt_pool_ns,
+     Opt_compression_hint,
       /* string args above */
       Opt_read_only,
       Opt_read_write,
@@ -844,8 +845,23 @@ enum {
       Opt_notrim,
   };
 
+enum {
+     Opt_compression_hint_none,
+     Opt_compression_hint_compressible,
+     Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+     {"none",                Opt_compression_hint_none},
+     {"compressible",        Opt_compression_hint_compressible},
+     {"incompressible",      Opt_compression_hint_incompressible},
+     {}
+};
+
   static const struct fs_parameter_spec rbd_parameters[] = {
       fsparam_u32     ("alloc_size",                  Opt_alloc_size),
+     fsparam_enum    ("compression_hint",            Opt_compression_hint,
+                      rbd_param_compression_hint),
       fsparam_flag    ("exclusive",                   Opt_exclusive),
       fsparam_flag    ("lock_on_read",                Opt_lock_on_read),
       fsparam_u32     ("lock_timeout",                Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
       bool    lock_on_read;
       bool    exclusive;
       bool    trim;
+
+     u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
   };
 
   #define RBD_QUEUE_DEPTH_DEFAULT     BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
               osd_req_op_alloc_hint_init(osd_req, which++,
                                          rbd_dev->layout.object_size,
                                          rbd_dev->layout.object_size,
-                                        0);
+                                        rbd_dev->opts->alloc_hint_flags);
       }
 
       if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
               pctx->spec->pool_ns = param->string;
               param->string = NULL;
               break;
+     case Opt_compression_hint:
+             switch (result.uint_32) {
+             case Opt_compression_hint_none:
+                     opt->alloc_hint_flags &=
+                         ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+                           CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+                     break;
+             case Opt_compression_hint_compressible:
+                     opt->alloc_hint_flags |=

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6371

Quoted 10 lines
drivers/block/rbd.c +10 -0
+                         CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     break;
+             case Opt_compression_hint_incompressible:
+                     opt->alloc_hint_flags |=
+                         CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     break;

Just one little question here,

(1) none opt means clear compressible related bits in hint flags, then lets the compressor in bluestore to decide compress or not.

Quoted 8 lines

(2) compressible opt means set compressible bit and clear incompressible bit

(3) incompressible opt means set incompressible bit and clear compressible bit

Is there any scenario that alloc_hint_flags is not zero filled before rbd_parse_param(), then we have to clear the unexpected bit?

Hi Dongsheng,

Quoted 7 lines

This is to handle the case when the map option string has multiple compression_hint options:

name=admin,...,compression_hint=compressible,...,compression_hint=none

The last one wins and we always end up with either zero or just one of the flags set, not both.

Hi Ilya,

     Considering this case, should we make this kind of useage invalid? Maybe we

can do it in another patch to solve all rbd parameters conflicting problem.

Thanx

Quoted 3 lines

Thanks,

Ilya

author maintainer
#6 lore raw
Quoted 118 lines · Dongsheng Yang
Quoted 106 lines · Ilya Dryomov
Quoted 94 lines · Dongsheng Yang

Hi Ilya,

Quoted 75 lines · Ilya Dryomov

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
   drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
   1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +28 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
       Opt_lock_timeout,
       /* int args above */
       Opt_pool_ns,
+     Opt_compression_hint,
       /* string args above */
       Opt_read_only,
       Opt_read_write,
@@ -844,8 +845,23 @@ enum {
       Opt_notrim,
   };
 
+enum {
+     Opt_compression_hint_none,
+     Opt_compression_hint_compressible,
+     Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+     {"none",                Opt_compression_hint_none},
+     {"compressible",        Opt_compression_hint_compressible},
+     {"incompressible",      Opt_compression_hint_incompressible},
+     {}
+};
+
   static const struct fs_parameter_spec rbd_parameters[] = {
       fsparam_u32     ("alloc_size",                  Opt_alloc_size),
+     fsparam_enum    ("compression_hint",            Opt_compression_hint,
+                      rbd_param_compression_hint),
       fsparam_flag    ("exclusive",                   Opt_exclusive),
       fsparam_flag    ("lock_on_read",                Opt_lock_on_read),
       fsparam_u32     ("lock_timeout",                Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
       bool    lock_on_read;
       bool    exclusive;
       bool    trim;
+
+     u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
   };
 
   #define RBD_QUEUE_DEPTH_DEFAULT     BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
               osd_req_op_alloc_hint_init(osd_req, which++,
                                          rbd_dev->layout.object_size,
                                          rbd_dev->layout.object_size,
-                                        0);
+                                        rbd_dev->opts->alloc_hint_flags);
       }
 
       if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
               pctx->spec->pool_ns = param->string;
               param->string = NULL;
               break;
+     case Opt_compression_hint:
+             switch (result.uint_32) {
+             case Opt_compression_hint_none:
+                     opt->alloc_hint_flags &=
+                         ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+                           CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+                     break;
+             case Opt_compression_hint_compressible:
+                     opt->alloc_hint_flags |=

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6371

Quoted 10 lines
drivers/block/rbd.c +10 -0
+                         CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     break;
+             case Opt_compression_hint_incompressible:
+                     opt->alloc_hint_flags |=
+                         CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     break;

Just one little question here,

(1) none opt means clear compressible related bits in hint flags, then lets the compressor in bluestore to decide compress or not.

Quoted 8 lines

(2) compressible opt means set compressible bit and clear incompressible bit

(3) incompressible opt means set incompressible bit and clear compressible bit

Is there any scenario that alloc_hint_flags is not zero filled before rbd_parse_param(), then we have to clear the unexpected bit?

Hi Dongsheng,

Quoted 7 lines

This is to handle the case when the map option string has multiple compression_hint options:

name=admin,...,compression_hint=compressible,...,compression_hint=none

The last one wins and we always end up with either zero or just one of the flags set, not both.

Quoted 6 lines

Hi Ilya,

Considering this case, should we make this kind of useage invalid?
Maybe we

can do it in another patch to solve all rbd parameters conflicting problem.

No. On the contrary, the intention is to support overriding in the form of "the last one wins" going forward to be consistent with filesystems, where this behaviour is expected for the use case of overriding /etc/fstab options on the command line.

Thanks,

Ilya

#7 lore raw
Quoted 119 lines · Ilya Dryomov
Quoted 117 lines · Dongsheng Yang
Quoted 105 lines · Ilya Dryomov
Quoted 93 lines · Dongsheng Yang

Hi Ilya,

Quoted 75 lines · Ilya Dryomov

Allow hinting to bluestore if the data should/should not be compressed. The default is to not hint (compression_hint=none).

---
    drivers/block/rbd.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
    1 file changed, 42 insertions(+), 1 deletion(-)
drivers/block/rbd.c +28 -1
index b1cd41e671d1..e02089d550a4 100644
@@ -836,6 +836,7 @@ enum {
        Opt_lock_timeout,
        /* int args above */
        Opt_pool_ns,
+     Opt_compression_hint,
        /* string args above */
        Opt_read_only,
        Opt_read_write,
@@ -844,8 +845,23 @@ enum {
        Opt_notrim,
    };
 
+enum {
+     Opt_compression_hint_none,
+     Opt_compression_hint_compressible,
+     Opt_compression_hint_incompressible,
+};
+
+static const struct constant_table rbd_param_compression_hint[] = {
+     {"none",                Opt_compression_hint_none},
+     {"compressible",        Opt_compression_hint_compressible},
+     {"incompressible",      Opt_compression_hint_incompressible},
+     {}
+};
+
    static const struct fs_parameter_spec rbd_parameters[] = {
        fsparam_u32     ("alloc_size",                  Opt_alloc_size),
+     fsparam_enum    ("compression_hint",            Opt_compression_hint,
+                      rbd_param_compression_hint),
        fsparam_flag    ("exclusive",                   Opt_exclusive),
        fsparam_flag    ("lock_on_read",                Opt_lock_on_read),
        fsparam_u32     ("lock_timeout",                Opt_lock_timeout),
@@ -867,6 +883,8 @@ struct rbd_options {
        bool    lock_on_read;
        bool    exclusive;
        bool    trim;
+
+     u32 alloc_hint_flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
    };
 
    #define RBD_QUEUE_DEPTH_DEFAULT     BLKDEV_MAX_RQ
@@ -2254,7 +2272,7 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
                osd_req_op_alloc_hint_init(osd_req, which++,
                                           rbd_dev->layout.object_size,
                                           rbd_dev->layout.object_size,
-                                        0);
+                                        rbd_dev->opts->alloc_hint_flags);
        }
 
        if (rbd_obj_is_entire(obj_req))
@@ -6332,6 +6350,29 @@ static int rbd_parse_param(struct fs_parameter *param,
                pctx->spec->pool_ns = param->string;
                param->string = NULL;
                break;
+     case Opt_compression_hint:
+             switch (result.uint_32) {
+             case Opt_compression_hint_none:
+                     opt->alloc_hint_flags &=
+                         ~(CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE |
+                           CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE);
+                     break;
+             case Opt_compression_hint_compressible:
+                     opt->alloc_hint_flags |=

drivers/block/rbd.c static int rbd_parse_param(struct fs_parameter *param, · line 6371

Quoted 10 lines
drivers/block/rbd.c +10 -0
+                         CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     break;
+             case Opt_compression_hint_incompressible:
+                     opt->alloc_hint_flags |=
+                         CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE;
+                     opt->alloc_hint_flags &=
+                         ~CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE;
+                     break;

Just one little question here,

(1) none opt means clear compressible related bits in hint flags, then lets the compressor in bluestore to decide compress or not.

Quoted 8 lines

(2) compressible opt means set compressible bit and clear incompressible bit

(3) incompressible opt means set incompressible bit and clear compressible bit

Is there any scenario that alloc_hint_flags is not zero filled before rbd_parse_param(), then we have to clear the unexpected bit?

Hi Dongsheng,

Quoted 7 lines

This is to handle the case when the map option string has multiple compression_hint options:

name=admin,...,compression_hint=compressible,...,compression_hint=none

The last one wins and we always end up with either zero or just one of the flags set, not both.

Hi Ilya,

Quoted 8 lines
Quoted 4 lines

Considering this case, should we make this kind of useage invalid?
Maybe we

can do it in another patch to solve all rbd parameters conflicting problem.

No. On the contrary, the intention is to support overriding in the form of "the last one wins" going forward to be consistent with filesystems, where this behaviour is expected for the use case of overriding /etc/fstab options on the command line.

Okey makes sense.

Thanx

Quoted 4 lines

Thanks,

Ilya