osd: Return the stored bitmap for secondary reads sent without attr_len #227
@@ -200,7 +200,8 @@ void osd_t::exec_secondary_real(osd_op_t *cur_op)
|
||||
cur_op->bs_op->offset = cur_op->req.sec_rw.offset;
|
||||
cur_op->bs_op->len = cur_op->req.sec_rw.len;
|
||||
cur_op->bs_op->buf = (uint8_t*)cur_op->buf;
|
||||
if (cur_op->req.sec_rw.attr_len)
|
||||
// A read always replies with the bitmap, and primaries before 51ecbadb send reads with attr_len = 0
|
||||
if (cur_op->req.sec_rw.attr_len || cur_op->req.hdr.opcode == OSD_OP_SEC_READ)
|
||||
cur_op->bs_op->bitmap = (uint8_t*)cur_op->bitmap;
|
||||
else
|
||||
cur_op->bs_op->bitmap = NULL;
|
||||
|
||||
@@ -5768,6 +5768,53 @@ void test_primary_list_inverted_range()
|
||||
printf("test_primary_list_inverted_range passed\n");
|
||||
}
|
||||
|
||||
// A primary without 51ecbadb (3.0.13 and older) sends SEC_READ with attr_len = 0
|
||||
// and uses the bitmap of the reply, so the reply must carry the stored bitmap
|
||||
static void test_sec_read_without_attr_len_returns_bitmap()
|
||||
{
|
||||
printf("test_sec_read_without_attr_len_returns_bitmap\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", 2 },
|
||||
{ "etcd_address", "127.0.0.1:2379" },
|
||||
{ "immediate_commit", "all" },
|
||||
{ "block_size", 131072 },
|
||||
{ "bitmap_granularity", 4096 },
|
||||
});
|
||||
// clean_entry_bitmap_size = 131072/4096/8 = 4
|
||||
const uint32_t stored_bmp = 0xa5c3;
|
||||
object_id oid = { .inode = INODE_WITH_POOL(1, 1), .stripe = 0 };
|
||||
uint64_t cl_id = f.connect_client();
|
||||
f.client(cl_id)->in_osd_num = 1;
|
||||
for (uint32_t attr_len: { 0u, (uint32_t)sizeof(stored_bmp) })
|
||||
{
|
||||
auto *op = new osd_op_t();
|
||||
op->op_type = OSD_OP_IN;
|
||||
op->client_id = cl_id;
|
||||
op->req.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
||||
op->req.hdr.id = 1+attr_len;
|
||||
op->req.hdr.opcode = OSD_OP_SEC_READ;
|
||||
op->req.sec_rw.oid = oid;
|
||||
op->req.sec_rw.version = UINT64_MAX;
|
||||
op->req.sec_rw.len = 4096;
|
||||
op->req.sec_rw.attr_len = attr_len;
|
||||
op->req.sec_rw.flags = OSD_OP_IGNORE_PG_LOCK;
|
||||
f.exec(op);
|
||||
auto *rd = f.bs->take(BS_OP_READ);
|
||||
if (rd->bitmap)
|
||||
memcpy(rd->bitmap, &stored_bmp, sizeof(stored_bmp));
|
||||
rd->version = 1;
|
||||
rd->retval = rd->len;
|
||||
rd->callback(rd);
|
||||
auto *reply = f.client(cl_id)->sent_ops.at(op->req.hdr.id);
|
||||
assert(reply->reply.sec_rw.attr_len == sizeof(stored_bmp));
|
||||
assert(!memcmp(reply->bitmap, &stored_bmp, sizeof(stored_bmp)));
|
||||
}
|
||||
printf("test_sec_read_without_attr_len_returns_bitmap passed\n");
|
||||
}
|
||||
|
||||
int main(int narg, char *args[])
|
||||
{
|
||||
test_load_global_config();
|
||||
@@ -5855,5 +5902,6 @@ int main(int narg, char *args[])
|
||||
test_peering_yields_after_repeer();
|
||||
test_peering_yields_between_pgs();
|
||||
test_peering_sends_replies_before_calc();
|
||||
test_sec_read_without_attr_len_returns_bitmap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user