From ab2dbd9b871dd00afc6ad78acb386ffa48b6b053 Mon Sep 17 00:00:00 2001 From: Robert Wing Date: Wed, 16 Mar 2022 17:27:34 -0800 Subject: [PATCH] ffs_mount(): fix snapshotting Commit 0455cc7104ec broke snapshotting for ffs. In that commit, ffs_mount() was changed so the namei() lookup for a disk device happens before ffs_snapshot(). This caused the issue where namei() would lookup the snapshot file and fail because the file doesn't exist. Even if it did exist, taking a snapshot would still fail since it's not a disk device. Fix this by taking a snapshot of the filesystem as-is and return without altering ro/rw or any other attributes that are passed in. Reported by: pho Reviewed by: mckusick Fixes: 0455cc7104ec ("ffs_mount(): return early if namei() fails to lookup disk device") Differential Revision: https://reviews.freebsd.org/D34562 --- sys/ufs/ffs/ffs_vfsops.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 578e71014a2..455508cf996 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -410,6 +410,12 @@ ffs_mount(struct mount *mp) mp->mnt_flag |= mntorflags; MNT_IUNLOCK(mp); + /* + * If this is a snapshot request, take the snapshot. + */ + if (mp->mnt_flag & MNT_SNAPSHOT) + return (ffs_snapshot(mp, fspec)); + /* * Must not call namei() while owning busy ref. */ @@ -684,11 +690,6 @@ ffs_mount(struct mount *mp) MNT_IUNLOCK(mp); } - /* - * If this is a snapshot request, take the snapshot. - */ - if (mp->mnt_flag & MNT_SNAPSHOT) - return (ffs_snapshot(mp, fspec)); } MNT_ILOCK(mp);