diff --git a/src/client/osd_ops.h b/src/client/osd_ops.h index 4cf9c6c4..1fe1b53e 100644 --- a/src/client/osd_ops.h +++ b/src/client/osd_ops.h @@ -208,7 +208,7 @@ struct __attribute__((__packed__)) osd_op_sec_list_t // inode range (used to select pools) uint64_t min_inode, max_inode; // min/max oid stripe, added after inodes for backwards compatibility - // also for backwards compatibility, max_stripe=UINT64_MAX means 0 and 0 means UINT64_MAX O_o + // also for backwards compatibility, max_stripe=0 means UINT64_MAX uint64_t min_stripe, max_stripe; // max stable object count uint32_t stable_limit; diff --git a/src/osd/osd_primary_describe.cpp b/src/osd/osd_primary_describe.cpp index bcc35d9b..19f262f6 100644 --- a/src/osd/osd_primary_describe.cpp +++ b/src/osd/osd_primary_describe.cpp @@ -198,7 +198,7 @@ void osd_t::continue_primary_list(osd_op_t *cur_op) cur_op->bs_op->min_oid.inode = cur_op->req.sec_list.min_inode; cur_op->bs_op->min_oid.stripe = cur_op->req.sec_list.min_stripe; cur_op->bs_op->max_oid.inode = cur_op->req.sec_list.max_inode; - if (cur_op->req.sec_list.max_inode && cur_op->req.sec_list.max_stripe != UINT64_MAX) + if (cur_op->req.sec_list.max_inode) { cur_op->bs_op->max_oid.stripe = cur_op->req.sec_list.max_stripe ? cur_op->req.sec_list.max_stripe : UINT64_MAX; diff --git a/src/test/osd_test.cpp b/src/test/osd_test.cpp index 1fc6ac44..0bf70b3d 100644 --- a/src/test/osd_test.cpp +++ b/src/test/osd_test.cpp @@ -1568,6 +1568,54 @@ void test_chained_read_enoent_races_parent_delete(bool tombstones) printf("test_chained_read_enoent_races_parent_delete(tombstones=%d) passed\n", tombstones); } +// A primary LIST up to max_stripe = UINT64_MAX must pass that upper bound to the store. +// {inode, 0} below min_oid made store v1 drop the bound and list other inodes of the PG +void test_primary_list_max_stripe_bound() +{ + printf("test_primary_list_max_stripe_bound\n"); + + osd_test_fixture_t f; + f.configure_replicated_pool(/*pool_id*/ 1, /*pg_size*/ 2, /*pg_minsize*/ 1, /*pg_count*/ 1, + { { 1, 2 } }); + f.start(json11::Json::object { + { "osd_num", 1 }, + { "etcd_address", "127.0.0.1:2379" }, + { "immediate_commit", "all" }, + { "block_size", 131072 }, + { "bitmap_granularity", 4096 }, + }); + f.connect_peer(2); + f.complete_peering_empty(); + assert(f.pg(1, 1).state == PG_ACTIVE); + + inode_t inode = INODE_WITH_POOL(1, 1); + uint64_t client_id = f.connect_client(); + auto *op = new osd_op_t(); + op->op_type = OSD_OP_IN; + op->client_id = client_id; + op->req.hdr.magic = SECONDARY_OSD_OP_MAGIC; + op->req.hdr.id = 1; + op->req.hdr.opcode = OSD_OP_SEC_LIST; + op->req.sec_list.list_pg = 1; + op->req.sec_list.min_inode = inode; + op->req.sec_list.max_inode = inode; + op->req.sec_list.min_stripe = 0x20000; + op->req.sec_list.max_stripe = UINT64_MAX; + op->req.sec_list.flags = OSD_LIST_PRIMARY; + f.exec(op); + auto *bs_list = f.bs->take(BS_OP_LIST); + assert(bs_list->min_oid == (object_id{ .inode = inode, .stripe = 0x20000 })); + assert(bs_list->max_oid == (object_id{ .inode = inode, .stripe = UINT64_MAX })); + bs_list->retval = 0; + bs_list->version = 0; + bs_list->buf = NULL; + std::function(bs_list->callback)(bs_list); + assert(f.client(client_id)->sent_ops.count(1) == 1); + assert(f.client(client_id)->sent_ops.at(1)->reply.hdr.retval == 0); + + printf("test_primary_list_max_stripe_bound passed\n"); +} + void test_chained_read_large_chain_info() { printf("test_chained_read_large_chain_info\n"); @@ -5552,6 +5600,7 @@ int main(int narg, char *args[]) test_repeated_partial_write_unmarks_outdated(); test_partial_write_to_misplaced_object(); test_partial_write_object_state_refs(); + test_primary_list_max_stripe_bound(); test_repeated_delete_is_noop(); test_read_enoent_waits_behind_running_delete(); test_read_enoent_without_racing_op_marks_corrupted();