Whamcloud - gitweb
LU-16073 utils: double snapshot_mount fix 25/48225/5
authorAkash B <akash-b@hpe.com>
Thu, 11 Aug 2022 07:51:57 +0000 (03:51 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 12 Sep 2022 02:57:11 +0000 (02:57 +0000)
lsnapshot_mount on already mounted snapshot fs
results in umount of snapshot fs and the following
error is seen:

-> lsnapshot_mount -F testfs -n snap_test_fo
Can't mount the snapshot snap_test_fo: No such process

Add additional test to the existing sanity-lsnapshot.sh
(test_1b) to reproduce the above issue.

This is handled by returning appropriate error
code and return -EALREADY if snapshot fs is
already mounted.

HPE-bug-id: LUS-10650
Test-Parameters: fstype=zfs testlist=sanity-lsnapshot
Signed-off-by: Akash B <akash-b@hpe.com>
Change-Id: Ia13c3e1cf929ec7c53463a2ea74eb98fb46f8358
Reviewed-on: https://es-gerrit.dev.cray.com/160589
Reviewed-by: Dipak Ghosh <dipak.ghosh@hpe.com>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-on: https://review.whamcloud.com/48225
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Alexander <alexander.boyko@hpe.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-lsnapshot.sh
lustre/utils/lsnapshot.c

index afa20ca..ef5b30e 100755 (executable)
@@ -97,7 +97,7 @@ test_1a() {
                lss_err "(5) Fail to mount lss_1a_0"
 
        echo "Check whether mounted (2)"
                lss_err "(5) Fail to mount lss_1a_0"
 
        echo "Check whether mounted (2)"
-       local mcount=$(lsnapshot_list -n lss_1a_0 -d | grep "not mount" | wc -l)
+       local mcount=$(lsnapshot_list -n lss_1a_0 -d | grep -c "not mount")
        [[ $mcount -ne 0 ]] && {
                if combined_mgs_mds ; then
                        lsnapshot_list -n lss_1a_0 -d
        [[ $mcount -ne 0 ]] && {
                if combined_mgs_mds ; then
                        lsnapshot_list -n lss_1a_0 -d
@@ -179,17 +179,27 @@ test_1b() {
                lss_err "(5) Expect 'mounted', got 'not mount' for lss_1b_0"
        }
 
                lss_err "(5) Expect 'mounted', got 'not mount' for lss_1b_0"
        }
 
+       echo "Remount lss_1b_0"
+       lsnapshot_mount -n lss_1b_0 &&
+               lss_err "(6) Mount already mounted snapshot should fail"
+
+       echo "Check whether mounted (3)"
+       lsnapshot_list -n lss_1b_0 -d | grep "not mount" && {
+               lsnapshot_list -n lss_1b_0 -d
+               lss_err "(7) Expect 'mounted', got 'not mount' for lss_1b_0"
+       }
+
        echo "umount lss_1b_0"
        lsnapshot_umount -n lss_1b_0 ||
        echo "umount lss_1b_0"
        lsnapshot_umount -n lss_1b_0 ||
-               lss_err "(6) Fail to umount lss_1b_0"
+               lss_err "(8) Fail to umount lss_1b_0"
 
 
-       echo "Check whether mounted (3)"
+       echo "Check whether mounted (4)"
        lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
                lsnapshot_list -n lss_1b_0 -d
        lsnapshot_list -n lss_1b_0 -d | grep "mounted" && {
                lsnapshot_list -n lss_1b_0 -d
-               lss_err "(7) Expect 'not mount', got 'mounted' for lss_1b_0"
+               lss_err "(9) Expect 'not mount', got 'mounted' for lss_1b_0"
        }
 
        }
 
-       setupall || lss_err "(8) Fail to setupall"
+       setupall || lss_err "(10) Fail to setupall"
 }
 run_test 1b "mount snapshot without original filesystem mounted"
 
 }
 run_test 1b "mount snapshot without original filesystem mounted"
 
index 0f1539e..34794a2 100644 (file)
@@ -2297,6 +2297,8 @@ static int snapshot_mount(struct snapshot_instance *si)
 
                if (si->si_mgs == si->si_mdt0)
                        mdt0_mounted = true;
 
                if (si->si_mgs == si->si_mdt0)
                        mdt0_mounted = true;
+       } else {
+               si->si_mgs->st_ignored = 1;
        }
 
        /* 2. Mount MDT0 if it is not combined with the MGS. */
        }
 
        /* 2. Mount MDT0 if it is not combined with the MGS. */
@@ -2304,6 +2306,10 @@ static int snapshot_mount(struct snapshot_instance *si)
                si->si_mdt0->st_ignored = 0;
                si->si_mdt0->st_pid = 0;
                rc = snapshot_mount_target(si, si->si_mdt0, ",nomgs");
                si->si_mdt0->st_ignored = 0;
                si->si_mdt0->st_pid = 0;
                rc = snapshot_mount_target(si, si->si_mdt0, ",nomgs");
+               if (rc == -ESRCH) {
+                       si->si_mdt0->st_ignored = 1;
+                       rc = 0;
+               }
                if (rc)
                        goto cleanup;
        }
                if (rc)
                        goto cleanup;
        }