Skip to content

Commit

Permalink
rbd: compression_hint option
Browse files Browse the repository at this point in the history
Allow hinting to bluestore if the data should/should not be compressed.
The default is to not hint (compression_hint=none).

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Ilya Dryomov committed Jun 1, 2020
1 parent d3798ac commit dc1dad8
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dc1dad8

Please sign in to comment.