Whamcloud - gitweb
LU-16896 flr: resync should not change file size 44/51344/6
authorBobi Jam <bobijam@whamcloud.com>
Sat, 17 Jun 2023 00:51:26 +0000 (08:51 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:31:15 +0000 (06:31 +0000)
mirror resync could punch a hole reaching the end of file in a
mirror, which could change the file size when the mirror is referred.

This patch calls truncate after punch in this case to keep the file
size unchanged in the mirror.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: Ia0fc1f220a32a60f3516c69e86867796ae5c35c7
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51344
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/fsx.c
lustre/tests/sanity-flr.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c

index d621295..9290f72 100644 (file)
@@ -1465,12 +1465,12 @@ do_mirror_ops(int op)
 
                rc = system(cmd);
                if (rc < 0) {
-                       prt("%s: %d\n", cmd, errno);
+                       prt("mirror op %d: %s: %d\n", op, cmd, errno);
                        report_failure(184);
                } else if (WIFEXITED(rc)) {
                        rc = WEXITSTATUS(rc);
                        if (rc > 0) {
-                               prt("%s: %d\n", cmd, rc);
+                               prt("mirror op %d: %s: %d\n", op, cmd, rc);
                                snprintf(cmd, sizeof(cmd),
                                         "lfs mirror verify -v %s", tf->path);
                                rc = system(cmd);
index 5ddf98d..e9f49d6 100644 (file)
@@ -3269,7 +3269,7 @@ test_70a() {
                error "setstripe $tf failed"
 
        FSXNUM=${FSXNUM:-1000}
-       $FSX -p 5 -N $FSXNUM -S 0 -M $tf || error "fsx FLR file $tf failed"
+       $FSX -p 1 -N $FSXNUM -S 0 -M $tf || error "fsx FLR file $tf failed"
 }
 run_test 70a "flr mode fsx test"
 
index bab249e..bf4ba78 100644 (file)
@@ -12532,10 +12532,11 @@ int lfs_mirror_verify_chunk(int fd, size_t file_size,
                                rc = -EINVAL;
 
                                fprintf(stderr,
-                                       "%s: chunk "DEXT" has different checksum value on mirror %u and mirror %u.\n",
+                                       "%s: chunk "DEXT" has different checksum value on mirror %u:%lx and mirror %u:%lx.\n",
                                        progname, PEXT(&chunk->chunk),
-                                       chunk->mirror_id[0],
-                                       chunk->mirror_id[i]);
+                                       chunk->mirror_id[0], crc_array[0],
+                                       chunk->mirror_id[i], crc_array[i]);
+                               print_checksums(chunk, crc_array, pos, buflen);
                        }
                }
 
index 271e44b..6e4a844 100644 (file)
@@ -3023,10 +3023,10 @@ int llapi_mirror_resync_many_params(int fd, struct llapi_layout *layout,
                ssize_t bytes_read;
                size_t to_read;
                size_t to_write;
+               size_t data_size;
 
                if (pos >= data_end) {
                        off_t tmp_off;
-                       size_t data_size;
 
                        if (pos >= mirror_end || !src) {
                                rc = llapi_mirror_find(layout, pos, end,
@@ -3078,23 +3078,22 @@ int llapi_mirror_resync_many_params(int fd, struct llapi_layout *layout,
                                else
                                        to_punch = data_off - cur_pos;
 
-                               if (comp_array[i].lrc_end == OBD_OBJECT_EOF) {
+                               if (comp_array[i].lrc_end == OBD_OBJECT_EOF)
                                        /* the last component can be truncated
                                         * safely
                                         */
                                        rc = llapi_mirror_truncate(fd, mid,
                                                                   cur_pos);
-                                       /* hole at the end of file, so just
-                                        * truncate up to set size.
-                                        */
-                                       if (!rc && data_off == data_end)
-                                               rc = llapi_mirror_truncate(fd,
+                               else if (data_size)
+                                       rc = llapi_mirror_punch(fd, mid,
+                                                       cur_pos, to_punch);
+                               /**
+                                * hole at the end of file, so just truncate up
+                                * to set size.
+                                */
+                               if (!rc && data_off == data_end && !data_size)
+                                       rc = llapi_mirror_truncate(fd,
                                                                mid, data_end);
-                               } else {
-                                       rc = llapi_mirror_punch(fd,
-                                               comp_array[i].lrc_mirror_id,
-                                               cur_pos, to_punch);
-                               }
                                /* if failed then read failed hole range */
                                if (rc < 0) {
                                        rc = 0;