Whamcloud - gitweb
LU-18488 utils: make lrc_synced usage intuitive 37/57137/2
authorBobi Jam <bobijam@whamcloud.com>
Tue, 26 Nov 2024 08:07:48 +0000 (16:07 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Dec 2024 06:15:47 +0000 (06:15 +0000)
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 <bobijam@whamcloud.com>
Change-Id: I844dd3019b32b2a3746eb3b5b14c498ad7455270
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57137
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/liblustreapi_layout.c

index e61ef67..5e8b371 100644 (file)
@@ -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;
        }