From 402232444a08ec4dda3a6c6818c3888cf562fbfc Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Tue, 26 Nov 2024 16:07:48 +0800 Subject: [PATCH] LU-18488 utils: make lrc_synced usage intuitive llapi_resync_comp::lrc_synced is used against intuitiveness in the mirror resync code, this patch corrects it. Test-Parameters: testlist=sanity-flr,sanity-pfl,sanity-flr Test-Parameters: testlist=sanity-pfl,sanity-flr,sanity-pfl Signed-off-by: Bobi Jam Change-Id: I844dd3019b32b2a3746eb3b5b14c498ad7455270 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57137 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi_layout.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index e61ef67..5e8b371 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -3112,6 +3112,7 @@ int llapi_mirror_find_stale(struct llapi_layout *layout, comp[idx].lrc_mirror_id = mirror_id; comp[idx].lrc_start = start; comp[idx].lrc_end = end; + comp[idx].lrc_synced = true; idx++; if (idx >= comp_size) { @@ -3425,17 +3426,7 @@ do_read: buf + pos2 - pos, to_write2, pos2); if (written < 0) { - /** - * this component is not written successfully, - * mark it using its lrc_synced, it is supposed - * to be false before getting here. - * - * And before this function returns, all - * elements of comp_array will reverse their - * lrc_synced flag to reflect their true - * meanings. - */ - comp_array[i].lrc_synced = true; + comp_array[i].lrc_synced = false; llapi_error(LLAPI_MSG_ERROR, written, "component %u not synced", comp_array[i].lrc_id); @@ -3516,31 +3507,28 @@ do_read: /** * no fatal error happens, each lrc_synced tells whether the component - * has been resync successfully (note: we'd reverse the value to - * reflect its true meaning. + * has been resync successfully. */ for (i = 0; i < comp_size; i++) { struct llapi_resync_comp *comp = comp_array + i; - comp->lrc_synced = !comp->lrc_synced; - if (!comp->lrc_synced) continue; if (pos < comp->lrc_start || pos >= comp->lrc_end) continue; if (pos < st.st_size) { - llapi_mirror_punch(fd, comp->lrc_mirror_id, pos, - comp_array[i].lrc_end - pos); - continue; + rc = llapi_mirror_punch(fd, comp->lrc_mirror_id, pos, + comp->lrc_end - pos); + } else { + rc = llapi_mirror_truncate(fd, comp->lrc_mirror_id, + pos); } - rc = llapi_mirror_truncate(fd, comp->lrc_mirror_id, pos); /* Ignore truncate error on encrypted file without the * key if tried on LUSTRE_ENCRYPTION_UNIT_SIZE boundary. */ - if (rc < 0 && (rc != -ENOKEY || - pos & ~LUSTRE_ENCRYPTION_MASK)) + if (rc < 0 && (rc != -ENOKEY || pos & ~LUSTRE_ENCRYPTION_MASK)) comp->lrc_synced = false; } -- 1.8.3.1