rbd: add support for sparse reads
Subsystems (2)
RFC PATCH 1/1 rbd: add support for sparse reads
Add a "sparseread" krbd option that makes it use sparse reads instead of normal reads. It's not clear whether this adds any performance benefit on its own, but it may help with large, sparse devices.
--- drivers/block/rbd.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
This obviously relies on the sparse read infrastructure that's in the testing branch.
I'm testing this now and it seems to work. I tested this with a patch that forced sparse reads on, though. I couldn't really test the "sparseread" option as that required support in the userland rbd utility and I was too lazy to want to build and install it for testing.
No idea whether this is useful for anything, but since we have sparse read support in libceph we might as well allow rbd to use it.
drivers/block/rbd.c +30 -2
@@ -791,6 +791,7 @@ enum { Opt_lock_on_read, Opt_exclusive, Opt_notrim, + Opt_sparseread, }; enum {
@@ -820,6 +821,7 @@ static const struct fs_parameter_spec rbd_parameters[] = {fsparam_flag ("read_write" , Opt_read_write),fsparam_flag ("ro" , Opt_read_only),fsparam_flag ("rw" , Opt_read_write), + fsparam_flag ("sparseread", Opt_sparseread), {} };
@@ -831,6 +833,7 @@ struct rbd_options {bool lock_on_read;bool exclusive;bool trim; +bool sparseread;u32 alloc_hint_flags;/* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */ };
@@ -842,6 +845,7 @@ struct rbd_options {#define RBD_LOCK_ON_READ_DEFAULT false#define RBD_EXCLUSIVE_DEFAULT false#define RBD_TRIM_DEFAULT true +#define RBD_SPARSEREAD_DEFAULT falsestruct rbd_parse_opts_ctx {struct rbd_spec *spec;
@@ -1379,6 +1383,8 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req)*/ if (osd_req->r_result >0 &&rbd_img_is_write (obj_req->img_request)) result =0 ; +else if (osd_req->r_result >0 && osd_req->r_reply->sparse_read) + result =ceph_sparse_ext_map_end (&osd_req->r_ops[0 ]);else result = osd_req->r_result;
@@ -2753,14 +2759,23 @@ static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req)static int rbd_obj_read_object (struct rbd_obj_request *obj_req) {struct ceph_osd_request *osd_req; +bool sparse = obj_req->img_request->rbd_dev->opts->sparseread;int ret; osd_req =__rbd_obj_add_osd_request (obj_req,NULL ,1 );if (IS_ERR (osd_req))return PTR_ERR (osd_req); -osd_req_op_extent_init (osd_req,0 ,CEPH_OSD_OP_READ , +osd_req_op_extent_init (osd_req,0 , + sparse ?CEPH_OSD_OP_SPARSE_READ :CEPH_OSD_OP_READ , obj_req->ex.oe_off, obj_req->ex.oe_len,0 ,0 ); + +if (sparse) { + ret =ceph_alloc_sparse_ext_map (&osd_req->r_ops[0 ]); +if (ret) +return ret; + } +rbd_osd_setup_data (osd_req,0 );rbd_osd_format_read (osd_req);
@@ -4743,6 +4758,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;struct ceph_osd_request *req;struct page **pages; +bool sparse = rbd_dev->opts->sparseread;int num_pages =calc_pages_for (0 , buf_len);int ret;
@@ -4760,10 +4776,18 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, goto out_req; } -osd_req_op_extent_init (req,0 ,CEPH_OSD_OP_READ ,0 , buf_len,0 ,0 ); +osd_req_op_extent_init (req,0 , + sparse ?CEPH_OSD_OP_SPARSE_READ :CEPH_OSD_OP_READ , +0 , buf_len,0 ,0 );osd_req_op_extent_osd_data_pages (req,0 , pages, buf_len,0 , false, true); +if (sparse) { + ret =ceph_alloc_sparse_ext_map (&req->r_ops[0 ]); +if (ret) + goto out_req; + } + ret =ceph_osdc_alloc_messages (req,GFP_KERNEL );if (ret) goto out_req;
@@ -6312,6 +6336,9 @@ static int rbd_parse_param(struct fs_parameter *param,case Opt_notrim: opt->trim = false;break ; +case Opt_sparseread: + opt->sparseread = true; +break ;default :BUG (); }
@@ -6493,6 +6520,7 @@ static int rbd_add_parse_args(const char *buf, pctx.opts->lock_on_read =RBD_LOCK_ON_READ_DEFAULT ; pctx.opts->exclusive =RBD_EXCLUSIVE_DEFAULT ; pctx.opts->trim =RBD_TRIM_DEFAULT ; + pctx.opts->sparseread =RBD_SPARSEREAD_DEFAULT ; ret =ceph_parse_mon_ips (mon_addrs, mon_addrs_size, pctx.copts,NULL ,',' );
Signature · 1 line
2.35.1
kernel test robot
build bot[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Jeff,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on ceph-client/for-linus]
[also build test ERROR on v5.17 next-20220401]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Jeff-Layton/rbd-add-support-for-sparse-reads/20220402-010754 base: https://github.com/ceph/ceph-client.git for-linus config: x86_64-randconfig-c007 (https://download.01.org/0day-ci/archive/20220402/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1af6e49fa0bc1a2d7fdc8a400512ca8b6361eab6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jeff-Layton/rbd-add-support-for-sparse-reads/20220402-010754
git checkout 1af6e49fa0bc1a2d7fdc8a400512ca8b6361eab6
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/block/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/block/rbd.c:1387:54: error: no member named 'sparse_read' in 'struct ceph_msg'
else if (osd_req->r_result > 0 && osd_req->r_reply->sparse_read)
~~~~~~~~~~~~~~~~ ^
drivers/block/rbd.c:1388:12: error: implicit declaration of function 'ceph_sparse_ext_map_end' [-Werror,-Wimplicit-function-declaration]
result = ceph_sparse_ext_map_end(&osd_req->r_ops[0]);
^
drivers/block/rbd.c:2775:9: error: implicit declaration of function 'ceph_alloc_sparse_ext_map' [-Werror,-Wimplicit-function-declaration]
ret = ceph_alloc_sparse_ext_map(&osd_req->r_ops[0]);
^
drivers/block/rbd.c:4787:9: error: implicit declaration of function 'ceph_alloc_sparse_ext_map' [-Werror,-Wimplicit-function-declaration]
ret = ceph_alloc_sparse_ext_map(&req->r_ops[0]);
^ drivers/block/rbd.c:6101:17: warning: result of comparison of constant 2305843009213693948 with expression of type 'u32' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 4 errors generated.
vim +1387 drivers/block/rbd.c
1371
1372 static void rbd_osd_req_callback(struct ceph_osd_request *osd_req)
1373 {
1374 struct rbd_obj_request *obj_req = osd_req->r_priv;
1375 int result;
1376
1377 dout("%s osd_req %p result %d for obj_req %p\n", __func__, osd_req,
1378 osd_req->r_result, obj_req);
1379
1380 /*
1381 * Writes aren't allowed to return a data payload. In some
1382 * guarded write cases (e.g. stat + zero on an empty object)
1383 * a stat response makes it through, but we don't care.
1384 */
1385 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request))
1386 result = 0;
> 1387 else if (osd_req->r_result > 0 && osd_req->r_reply->sparse_read)
1388 result = ceph_sparse_ext_map_end(&osd_req->r_ops[0]);
1389 else
1390 result = osd_req->r_result;
1391
1392 rbd_obj_handle_request(obj_req, result);
1393 }
1394
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp