git: 47048a611dd2 - stable/13 - Set UFS/FFS file type to snapshot before changing its block pointers.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 20 Aug 2023 04:28:28 UTC
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=47048a611dd2606fe93dd59ca9e3f7ec5d756390 commit 47048a611dd2606fe93dd59ca9e3f7ec5d756390 Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2023-08-12 18:20:08 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> CommitDate: 2023-08-20 04:27:38 +0000 Set UFS/FFS file type to snapshot before changing its block pointers. Reported-by: Peter Holm Tested-by: Peter Holm Sponsored-by: The FreeBSD Foundation (cherry picked from commit 220427da0e9b2c1d8e964120becc17eb7524e46f) --- sys/ufs/ffs/ffs_alloc.c | 1 + sys/ufs/ffs/ffs_snapshot.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index a84202eccc05..933745885755 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -3130,6 +3130,7 @@ ffs_checkcgintegrity(struct fs *fs, fs->fs_cstotal.cs_nifree -= fs->fs_cs(fs, cg).cs_nifree; fs->fs_cs(fs, cg).cs_nifree = 0; fs->fs_maxcluster[cg] = 0; + fs->fs_flags |= FS_NEEDSFSCK; fs->fs_fmod = 1; } diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 5ceca72fd44f..b7844e0564d0 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -368,6 +368,15 @@ restart: goto out; } } + /* + * Change inode to snapshot type file. Before setting its block + * pointers to BLK_SNAP and BLK_NOCOPY in cgaccount, we have to + * set its type to SF_SNAPSHOT so that VOP_REMOVE will know that + * they need to be rolled back before attempting deletion. + */ + ip->i_flags |= SF_SNAPSHOT; + DIP_SET(ip, i_flags, ip->i_flags); + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * Copy all the cylinder group maps. Although the * filesystem is still active, we hope that only a few @@ -393,12 +402,6 @@ restart: if (error) goto out; } - /* - * Change inode to snapshot type file. - */ - ip->i_flags |= SF_SNAPSHOT; - DIP_SET(ip, i_flags, ip->i_flags); - UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * Ensure that the snapshot is completely on disk. * Since we have marked it as a snapshot it is safe to