From f822d4feb87a7bd7747679aa779942d24fff08e0 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 26 Aug 2021 19:12:58 +0300 Subject: [PATCH] ffs_update(): recalculate flags after relocking the vnode Inode type could migrate between snapshot and regular types while the vnode is unlocked. Recalculate flags specific for snapshot after relock. Reviewed by: mckusick Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/ufs/ffs/ffs_inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index b3d41aa023f..2bc3da7e603 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -145,10 +145,10 @@ ffs_update(vp, waitfor) * snapshot vnode to prevent it from being removed while we are * waiting for the buffer. */ +loop: flags = 0; if (IS_SNAPSHOT(ip)) flags = GB_LOCK_NOWAIT; -loop: bn = fsbtodb(fs, ino_to_fsba(fs, ip->i_number)); error = ffs_breadz(VFSTOUFS(vp->v_mount), ITODEVVP(ip), bn, bn, (int) fs->fs_bsize, NULL, NULL, 0, NOCRED, flags, NULL, &bp); @@ -176,6 +176,11 @@ ffs_update(vp, waitfor) vrele(vp); if (VN_IS_DOOMED(vp)) return (ENOENT); + + /* + * Recalculate flags, because the vnode was relocked and + * could no longer be a snapshot. + */ goto loop; } if (DOINGSOFTDEP(vp)) -- 2.45.0