@@ -211,6 +211,12 @@ void usage(ostream& out)
211211" set the max number of objects for write benchmarking\n "
212212" --obj-name-file file\n "
213213" use the content of the specified file in place of <obj-name>\n "
214+ " --omap-read-start-after\n "
215+ " set the start_after parameter for OMAP list benchmarking\n "
216+ " --omap-read-filter-prefix\n "
217+ " set the filter_prefix parameter for OMAP list benchmarking\n "
218+ " --omap-read-max-return\n "
219+ " set the max number of entries for OMAP list benchmarking\n "
214220" -s name\n "
215221" --snap name\n "
216222" select given snap name for (read) IO\n "
@@ -1062,13 +1068,20 @@ enum OpDest {
10621068 OP_DEST_XATTR = 2 << 2 ,
10631069};
10641070
1071+ struct omap_read_params_t {
1072+ std::string start_after;
1073+ std::string filter_prefix;
1074+ uint64_t max_return{MAX_OMAP_BYTES_PER_REQUEST};
1075+ };
1076+
10651077class RadosBencher : public ObjBencher {
10661078 librados::AioCompletion **completions;
10671079 librados::Rados& rados;
10681080 librados::IoCtx& io_ctx;
10691081 librados::NObjectIterator oi;
10701082 bool iterator_valid;
10711083 OpDest destination;
1084+ omap_read_params_t omap_read;
10721085
10731086protected:
10741087 int completions_init (int concurrentios) override {
@@ -1094,7 +1107,28 @@ class RadosBencher : public ObjBencher {
10941107
10951108 int aio_read (const std::string& oid, int slot, bufferlist *pbl, size_t len,
10961109 size_t offset) override {
1097- return io_ctx.aio_read (oid, completions[slot], pbl, len, offset);
1110+ int ret = 0 ;
1111+ if (destination & OP_DEST_OBJ) {
1112+ ret = io_ctx.aio_read (oid, completions[slot], pbl, len, offset);
1113+ if (ret < 0 ) {
1114+ return ret;
1115+ }
1116+ }
1117+
1118+ if (destination & OP_DEST_OMAP) {
1119+ std::map<std::string, librados::bufferlist> values;
1120+ ObjectReadOperation rop;
1121+ rop.omap_get_vals2 (omap_read.start_after , omap_read.filter_prefix , omap_read.max_return , nullptr , nullptr , nullptr );
1122+ ret = io_ctx.aio_operate (oid, completions[slot], &rop, pbl);
1123+ if (ret < 0 ) {
1124+ return ret;
1125+ }
1126+ }
1127+
1128+ if (destination & OP_DEST_XATTR) {
1129+ ceph_abort (" not supported yet" );
1130+ }
1131+ return ret;
10981132 }
10991133
11001134 int aio_write (const std::string& oid, int slot, bufferlist& bl, size_t len,
@@ -1189,6 +1223,9 @@ class RadosBencher : public ObjBencher {
11891223 void set_destination (OpDest dest) {
11901224 destination = dest;
11911225 }
1226+ void set_omap_read_patams (const omap_read_params_t & omap_read_params) {
1227+ omap_read = omap_read_params;
1228+ }
11921229};
11931230
11941231static int do_lock_cmd (std::vector<const char *> &nargs,
@@ -1886,6 +1923,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
18861923 bool obj_offset_specified = false ;
18871924 bool block_size_specified = false ;
18881925 int bench_dest = 0 ;
1926+ omap_read_params_t omap_read;
18891927 bool cleanup = true ;
18901928 bool hints = true ; // for rados bench
18911929 bool reuse_bench = false ;
@@ -2133,6 +2171,22 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
21332171 }
21342172 omap_key = std::string (indata.c_str (), indata.length ());
21352173 }
2174+ i = opts.find (" omap-read-start-after" );
2175+ if (i != opts.end ()) {
2176+ omap_read.start_after = i->second ;
2177+ } else {
2178+ // fall back to empty string which is set by the omap_read_params_t's ctor
2179+ }
2180+ i = opts.find (" omap-read-filter-prefix" );
2181+ if (i != opts.end ()) {
2182+ omap_read.filter_prefix = i->second ;
2183+ }
2184+ i = opts.find (" omap-read-max-return" );
2185+ if (i != opts.end ()) {
2186+ if (rados_sistrtoll (i, &omap_read.max_return )) {
2187+ return -EINVAL;
2188+ }
2189+ }
21362190 i = opts.find (" obj-name-file" );
21372191 if (i != opts.end ()) {
21382192 string err;
@@ -3340,6 +3394,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
33403394 RadosBencher bencher (g_ceph_context, rados, io_ctx);
33413395 bencher.set_show_time (show_time);
33423396 bencher.set_destination (static_cast <OpDest>(bench_dest));
3397+ bencher.set_omap_read_patams (omap_read);
33433398
33443399 ostream *outstream = NULL ;
33453400 if (formatter) {
@@ -4235,8 +4290,20 @@ int main(int argc, const char **argv)
42354290 opts[" dest-obj" ] = " true" ;
42364291 } else if (ceph_argparse_flag (args, i, " --write-xattr" , (char *)NULL )) {
42374292 opts[" dest-xattr" ] = " true" ;
4293+ } else if (ceph_argparse_flag (args, i, " --read-omap" , (char *)NULL )) {
4294+ opts[" dest-omap" ] = " true" ;
4295+ } else if (ceph_argparse_flag (args, i, " --read-object" , (char *)NULL )) {
4296+ opts[" dest-obj" ] = " true" ;
4297+ } else if (ceph_argparse_flag (args, i, " --read-xattr" , (char *)NULL )) {
4298+ opts[" dest-xattr" ] = " true" ;
42384299 } else if (ceph_argparse_flag (args, i, " --with-clones" , (char *)NULL )) {
42394300 opts[" with-clones" ] = " true" ;
4301+ } else if (ceph_argparse_witharg (args, i, &val, " --omap-read-start-after" , (char *)NULL )) {
4302+ opts[" omap-read-start-after" ] = val;
4303+ } else if (ceph_argparse_witharg (args, i, &val, " --omap-read-filter-prefix" , (char *)NULL )) {
4304+ opts[" omap-read-filter-prefix" ] = val;
4305+ } else if (ceph_argparse_witharg (args, i, &val, " --omap-read-max-return" , (char *)NULL )) {
4306+ opts[" omap-read-max-return" ] = val;
42404307 } else if (ceph_argparse_witharg (args, i, &val, " --omap-key-file" , (char *)NULL )) {
42414308 opts[" omap-key-file" ] = val;
42424309 } else if (ceph_argparse_witharg (args, i, &val, " --obj-name-file" , (char *)NULL )) {
0 commit comments