Extract validation to check_rw(), remove duplicate code with OP_SYNC
Test / buildenv (push) Successful in 10s Details
Test / build (push) Successful in 3m33s Details
Test / make_test (push) Successful in 35s Details
Test / test_add_osd (push) Successful in 3m52s Details
Test / test_cas (push) Successful in 8s Details
Test / test_change_pg_count (push) Successful in 43s Details
Test / test_change_pg_count_ec (push) Successful in 39s Details
Test / test_change_pg_size (push) Successful in 10s Details
Test / test_create_nomaxid (push) Successful in 7s Details
Test / test_etcd_fail (push) Successful in 1m11s Details
Test / test_interrupted_rebalance (push) Successful in 2m24s Details
Test / test_interrupted_rebalance_imm (push) Successful in 2m47s Details
Test / test_interrupted_rebalance_ec (push) Successful in 1m11s Details
Test / test_interrupted_rebalance_ec_imm (push) Successful in 1m17s Details
Test / test_failure_domain (push) Successful in 9s Details
Test / test_snapshot (push) Successful in 19s Details
Test / test_snapshot_ec (push) Successful in 19s Details
Test / test_minsize_1 (push) Successful in 12s Details
Test / test_move_reappear (push) Successful in 18s Details
Test / test_rm (push) Successful in 11s Details
Test / test_snapshot_chain (push) Successful in 59s Details
Test / test_snapshot_chain_ec (push) Successful in 1m41s Details
Test / test_snapshot_down (push) Successful in 22s Details
Test / test_snapshot_down_ec (push) Successful in 22s Details
Test / test_splitbrain (push) Successful in 14s Details
Test / test_rebalance_verify (push) Successful in 3m23s Details
Test / test_rebalance_verify_imm (push) Successful in 3m19s Details
Test / test_rebalance_verify_ec (push) Successful in 5m33s Details
Test / test_rebalance_verify_ec_imm (push) Successful in 5m28s Details
Test / test_write (push) Successful in 51s Details
Test / test_write_xor (push) Successful in 1m6s Details
Test / test_write_no_same (push) Successful in 18s Details
Test / test_heal_pg_size_2 (push) Successful in 4m26s Details
Test / test_heal_ec (push) Successful in 5m21s Details
Test / test_heal_csum_32k_dmj (push) Successful in 5m56s Details
Test / test_heal_csum_32k_dj (push) Successful in 6m2s Details
Test / test_heal_csum_32k (push) Successful in 6m41s Details
Test / test_heal_csum_4k_dmj (push) Successful in 6m53s Details
Test / test_heal_csum_4k_dj (push) Successful in 3m58s Details
Test / test_heal_csum_4k (push) Successful in 4m55s Details
Test / test_scrub (push) Successful in 48s Details
Test / test_scrub_zero_osd_2 (push) Successful in 54s Details
Test / test_scrub_xor (push) Successful in 50s Details
Test / test_scrub_pg_size_3 (push) Successful in 1m4s Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Successful in 46s Details
Test / test_scrub_ec (push) Successful in 47s Details

fsync-feedback
Vitaliy Filippov 2023-08-12 11:12:14 +03:00
parent 30ce2bd951
commit 7862282938
2 changed files with 66 additions and 70 deletions

View File

@ -455,39 +455,18 @@ void cluster_client_t::execute(cluster_op_t *op)
} }
op->cur_inode = op->inode; op->cur_inode = op->inode;
op->retval = 0; op->retval = 0;
op->flags = op->flags & OSD_OP_IGNORE_READONLY; // single allowed flag op->flags = op->flags & OSD_OP_IGNORE_READONLY; // the only allowed flag
if (op->opcode != OSD_OP_SYNC) // check alignment, readonly flag and so on
if (!check_rw(op))
{ {
pool_id_t pool_id = INODE_POOL(op->cur_inode); return;
if (!pool_id)
{
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return;
}
auto pool_it = st_cli.pool_config.find(pool_id);
if (pool_it == st_cli.pool_config.end() || pool_it->second.real_pg_count == 0)
{
// Pools are loaded, but this one is unknown
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return;
}
// Check alignment
if (!op->len && (op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP || op->opcode == OSD_OP_WRITE) ||
op->offset % pool_it->second.bitmap_granularity || op->len % pool_it->second.bitmap_granularity)
{
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return;
}
if (pool_it->second.immediate_commit == IMMEDIATE_ALL)
{
op->flags |= OP_IMMEDIATE_COMMIT;
}
} }
if (op->opcode == OSD_OP_WRITE && !(op->flags & OP_IMMEDIATE_COMMIT)) if (op->opcode == OSD_OP_WRITE && !(op->flags & OP_IMMEDIATE_COMMIT))
{ {
if (!(op->flags & OP_FLUSH_BUFFER))
{
copy_write(op, dirty_buffers);
}
if (dirty_bytes >= client_max_dirty_bytes || dirty_ops >= client_max_dirty_ops) if (dirty_bytes >= client_max_dirty_bytes || dirty_ops >= client_max_dirty_ops)
{ {
// Push an extra SYNC operation to flush previous writes // Push an extra SYNC operation to flush previous writes
@ -497,17 +476,7 @@ void cluster_client_t::execute(cluster_op_t *op)
{ {
delete sync_op; delete sync_op;
}; };
sync_op->prev = op_queue_tail; execute(sync_op);
if (op_queue_tail)
{
op_queue_tail->next = sync_op;
op_queue_tail = sync_op;
}
else
op_queue_tail = op_queue_head = sync_op;
dirty_bytes = 0;
dirty_ops = 0;
calc_wait(sync_op);
} }
dirty_bytes += op->len; dirty_bytes += op->len;
dirty_ops++; dirty_ops++;
@ -536,6 +505,52 @@ void cluster_client_t::execute(cluster_op_t *op)
} }
} }
bool cluster_client_t::check_rw(cluster_op_t *op)
{
if (op->opcode == OSD_OP_SYNC)
{
return true;
}
pool_id_t pool_id = INODE_POOL(op->cur_inode);
if (!pool_id)
{
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return false;
}
auto pool_it = st_cli.pool_config.find(pool_id);
if (pool_it == st_cli.pool_config.end() || pool_it->second.real_pg_count == 0)
{
// Pools are loaded, but this one is unknown
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return false;
}
// Check alignment
if (!op->len && (op->opcode == OSD_OP_READ || op->opcode == OSD_OP_READ_BITMAP || op->opcode == OSD_OP_READ_CHAIN_BITMAP || op->opcode == OSD_OP_WRITE) ||
op->offset % pool_it->second.bitmap_granularity || op->len % pool_it->second.bitmap_granularity)
{
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);
return false;
}
if (pool_it->second.immediate_commit == IMMEDIATE_ALL)
{
op->flags |= OP_IMMEDIATE_COMMIT;
}
if ((op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE) && !(op->flags & OSD_OP_IGNORE_READONLY))
{
auto ino_it = st_cli.inode_config.find(op->inode);
if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly)
{
op->retval = -EROFS;
std::function<void(cluster_op_t*)>(op->callback)(op);
return false;
}
}
return true;
}
void cluster_client_t::execute_raw(osd_num_t osd_num, osd_op_t *op) void cluster_client_t::execute_raw(osd_num_t osd_num, osd_op_t *op)
{ {
auto fd_it = msgr.osd_peer_fds.find(osd_num); auto fd_it = msgr.osd_peer_fds.find(osd_num);
@ -691,27 +706,7 @@ int cluster_client_t::continue_rw(cluster_op_t *op)
goto resume_1; goto resume_1;
else if (op->state == 2) else if (op->state == 2)
goto resume_2; goto resume_2;
else if (op->state == 3)
goto resume_3;
resume_0: resume_0:
if (op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE)
{
if (!(op->flags & OSD_OP_IGNORE_READONLY))
{
auto ino_it = st_cli.inode_config.find(op->inode);
if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly)
{
op->retval = -EINVAL;
erase_op(op);
return 1;
}
}
if (op->opcode == OSD_OP_WRITE && !(op->flags & OP_IMMEDIATE_COMMIT) && !(op->flags & OP_FLUSH_BUFFER))
{
copy_write(op, dirty_buffers);
}
}
resume_1:
// Slice the operation into parts // Slice the operation into parts
slice_rw(op); slice_rw(op);
op->needs_reslice = false; op->needs_reslice = false;
@ -722,9 +717,9 @@ resume_1:
erase_op(op); erase_op(op);
return 1; return 1;
} }
resume_2: resume_1:
// Send unsent parts, if they're not subject to change // Send unsent parts, if they're not subject to change
op->state = 3; op->state = 2;
if (op->needs_reslice) if (op->needs_reslice)
{ {
for (int i = 0; i < op->parts.size(); i++) for (int i = 0; i < op->parts.size(); i++)
@ -734,7 +729,7 @@ resume_2:
op->retval = -EPIPE; op->retval = -EPIPE;
} }
} }
goto resume_3; goto resume_2;
} }
for (int i = 0; i < op->parts.size(); i++) for (int i = 0; i < op->parts.size(); i++)
{ {
@ -755,18 +750,18 @@ resume_2:
}); });
} }
} }
op->state = 2; op->state = 1;
} }
} }
} }
if (op->state == 2) if (op->state == 1)
{ {
return 0; return 0;
} }
resume_3: resume_2:
if (op->inflight_count > 0) if (op->inflight_count > 0)
{ {
op->state = 3; op->state = 2;
return 0; return 0;
} }
if (op->done_count >= op->parts.size()) if (op->done_count >= op->parts.size())
@ -794,7 +789,7 @@ resume_3:
op->cur_inode = ino_it->second.parent_id; op->cur_inode = ino_it->second.parent_id;
op->parts.clear(); op->parts.clear();
op->done_count = 0; op->done_count = 0;
goto resume_1; goto resume_0;
} }
} }
op->retval = op->len; op->retval = op->len;
@ -821,7 +816,7 @@ resume_3:
{ {
op->parts.clear(); op->parts.clear();
op->done_count = 0; op->done_count = 0;
goto resume_1; goto resume_0;
} }
else else
{ {
@ -832,7 +827,7 @@ resume_3:
op->parts[i].flags = PART_RETRY; op->parts[i].flags = PART_RETRY;
} }
} }
goto resume_2; goto resume_1;
} }
} }
return 0; return 0;

View File

@ -147,6 +147,7 @@ protected:
void on_change_hook(std::map<std::string, etcd_kv_t> & changes); void on_change_hook(std::map<std::string, etcd_kv_t> & changes);
void on_change_osd_state_hook(uint64_t peer_osd); void on_change_osd_state_hook(uint64_t peer_osd);
int continue_rw(cluster_op_t *op); int continue_rw(cluster_op_t *op);
bool check_rw(cluster_op_t *op);
void slice_rw(cluster_op_t *op); void slice_rw(cluster_op_t *op);
bool try_send(cluster_op_t *op, int i); bool try_send(cluster_op_t *op, int i);
int continue_sync(cluster_op_t *op); int continue_sync(cluster_op_t *op);