From 27723374a38c76c8b8905b5c38f284060161fc3d Mon Sep 17 00:00:00 2001 From: Akash B Date: Thu, 11 Aug 2022 03:51:57 -0400 Subject: [PATCH] LU-16073 utils: double snapshot_mount fix 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 Change-Id: Ia13c3e1cf929ec7c53463a2ea74eb98fb46f8358 Reviewed-on: https://es-gerrit.dev.cray.com/160589 Reviewed-by: Dipak Ghosh Reviewed-by: Sergey Cheremencev Reviewed-by: Alexander Boyko Reviewed-on: https://review.whamcloud.com/48225 Tested-by: jenkins Reviewed-by: Emoly Liu Reviewed-by: Alexander Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/tests/sanity-lsnapshot.sh | 20 +++++++++++++++----- lustre/utils/lsnapshot.c | 6 ++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lustre/tests/sanity-lsnapshot.sh b/lustre/tests/sanity-lsnapshot.sh index afa20ca..ef5b30e 100755 --- a/lustre/tests/sanity-lsnapshot.sh +++ b/lustre/tests/sanity-lsnapshot.sh @@ -97,7 +97,7 @@ test_1a() { 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 @@ -179,17 +179,27 @@ test_1b() { 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 || - 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 - 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" diff --git a/lustre/utils/lsnapshot.c b/lustre/utils/lsnapshot.c index 0f1539e..34794a2 100644 --- a/lustre/utils/lsnapshot.c +++ b/lustre/utils/lsnapshot.c @@ -2297,6 +2297,8 @@ static int snapshot_mount(struct snapshot_instance *si) 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. */ @@ -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"); + if (rc == -ESRCH) { + si->si_mdt0->st_ignored = 1; + rc = 0; + } if (rc) goto cleanup; } -- 1.8.3.1