git: f822d4feb87a - main - ffs_update(): recalculate flags after relocking the vnode

Konstantin Belousov kib at FreeBSD.org
Tue Aug 31 04:38:54 UTC 2021


The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f822d4feb87a7bd7747679aa779942d24fff08e0

commit f822d4feb87a7bd7747679aa779942d24fff08e0
Author:     Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-08-26 16:12:58 +0000
Commit:     Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-08-31 04:38:35 +0000

    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 b3d41aa023f9..2bc3da7e603f 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 @@ loop:
 		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))


More information about the dev-commits-src-all mailing list