Whamcloud - gitweb
LU-18075 tests: fiemap test for sparse files 83/55883/6
authorElena Gryaznova <elena.gryaznova@hpe.com>
Sun, 18 Aug 2024 14:08:55 +0000 (17:08 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 22:00:47 +0000 (22:00 +0000)
New "Check fiemap for sparse files" test shows the
memory corruption without the following fix:
  LU-17110 llite: fix slab corruption with fm_extent_count=0

Test-Parameters: trivial testlist=sanity env=ONLY=44f,ONLY_REPEAT=10,NUMFILES_44f=20
Signed-off-by: Elena Gryaznova <elena.gryaznova@hpe.com>
Signed-off-by: Vladimir Saveliev <vladimir.saveliev@hpe.com>
HPE-bug-id: LUS-11952,LUS-12040
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Vladimir Saveliev <vladimir.saveliev@hpe.com>
Change-Id: I22034c7937366d9ea4b2b3f02fd7085d7ebe7e10
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55883
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/multiop.c
lustre/tests/sanity.sh

index 69da675..82b91be 100644 (file)
@@ -82,6 +82,7 @@ char usage[] =
 "       G gid get grouplock\n"
 "       g gid put grouplock\n"
 "       H[num] create HSM released file with num stripes\n"
+"       I  fiemap\n"
 "       K  link path to filename\n"
 "       L  link\n"
 "       l  symlink filename to path\n"
@@ -235,6 +236,39 @@ out_closedir:
        return rc;
 }
 
+static int do_fiemap(int fd)
+{
+       struct fiemap *pf;
+       int extents;
+       int save_errno;
+       int i;
+
+       extents = 0;
+       for (i = 0; i < 2; i++) {
+               if ((pf = malloc(sizeof(struct fiemap) +
+                       extents * sizeof(struct fiemap_extent))) == NULL) {
+                       perror("malloc failed");
+                       exit(1);
+               }
+               pf->fm_start = 0;
+               pf->fm_length = FIEMAP_MAX_OFFSET;
+               pf->fm_flags = FIEMAP_FLAG_SYNC;
+               pf->fm_extent_count = extents;
+
+               if (ioctl(fd, FS_IOC_FIEMAP, pf) < 0) {
+                       save_errno = errno;
+                       if (i == 0)
+                               perror("probe fiemap failed");
+                       else
+                               perror("fiemap failed");
+                       exit(save_errno);
+               }
+               extents = pf->fm_mapped_extents;
+               free(pf);
+       }
+       return 0;
+}
+
 #define POP_ARG() (pop_arg(argc, argv))
 
 int main(int argc, char **argv)
@@ -478,6 +512,9 @@ int main(int argc, char **argv)
                        }
                        rc = fd;
                        break;
+               case 'I':
+                       do_fiemap(fd);
+                       break;
                case 'j':
                        if (flock(fd, LOCK_EX) == -1)
                                errx(-1, "flock()");
index 871c575..31dd8dc 100755 (executable)
@@ -6036,6 +6036,22 @@ test_44e() {
 }
 run_test 44e "write and read maximal stripes"
 
+test_44f() {
+       [ "$FSTYPE" != "zfs" ] ||
+               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
+
+       local i
+       # required space: NUMFILES_44f * 20Mb
+       local NUMFILES_44f=${NUMFILES_44f:-50}
+
+       for (( i=0; i<NUMFILES_44f; i++ )); do
+               multiop $DIR/$tfile-$i \
+                       Ow10485760Z10485760w10485760Ic ||
+                       error "multiop failed"
+       done
+}
+run_test 44f "Check fiemap for sparse files"
+
 dirty_osc_total() {
        tot=0
        for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do