ffs_mount(): fix snapshotting

Commit 0455cc7104 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: 0455cc7104 ("ffs_mount(): return early if namei() fails to lookup disk device")
Differential Revision:	https://reviews.freebsd.org/D34562
This commit is contained in:
Robert Wing 2022-03-16 17:27:34 -08:00
parent 4f75af31a8
commit ab2dbd9b87

View file

@ -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);