git: 8d8589b385c9 - main - ufs: be more persistent with finishing some operations

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 31 Jan 2022 02:46:59 UTC
The branch main has been updated by kib:

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

commit 8d8589b385c901581ee71d09d86d044a6f42dfef
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-18 01:49:36 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-31 02:46:21 +0000

    ufs: be more persistent with finishing some operations
    
    when the vnode is doomed after relock.  The mere fact that the vnode is
    doomed does not prevent us from doing UFS operations on it while it is
    still belongs to UFS, which is determined by non-NULL v_data.  Not
    finishing some operations, e.g. not syncing the inode block only because
    the vnode started reclamation, is not correct.
    
    Add macro IS_UFS() which incapsulates the v_data != NULL, and use it
    instead of VN_IS_DOOMED() for places where the operation completion is
    important.
    
    Reviewed by:    markj, mckusick
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D34072
---
 sys/ufs/ffs/ffs_inode.c   | 2 +-
 sys/ufs/ffs/ffs_softdep.c | 2 +-
 sys/ufs/ffs/ffs_vnops.c   | 2 +-
 sys/ufs/ufs/inode.h       | 1 +
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index d8b86df27121..91d1b78e3d93 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -179,7 +179,7 @@ loop:
 		pause("ffsupd", 1);
 		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 		vrele(vp);
-		if (VN_IS_DOOMED(vp))
+		if (!IS_UFS(vp))
 			return (ENOENT);
 
 		/*
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 0b816b4139d3..f4c146c52249 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -13772,7 +13772,7 @@ softdep_request_cleanup_inactivate(struct mount *mp)
 		vholdl(vp);
 		vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY);
 		VI_LOCK(vp);
-		if (vp->v_data != NULL && vp->v_usecount == 0) {
+		if (IS_UFS(vp) && vp->v_usecount == 0) {
 			while ((vp->v_iflag & VI_OWEINACT) != 0) {
 				error = vinactive(vp);
 				if (error != 0 && error != ERELOOKUP)
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 24bb39a3d48f..0a2cd5970906 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -2066,7 +2066,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap)
 	 *    and respond to dead vnodes by returning ESTALE.
 	 */
 	VOP_LOCK(vp, vp_locked | LK_RETRY);
-	if (!VN_IS_DOOMED(vp))
+	if (IS_UFS(vp))
 		return (0);
 
 	/*
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 7ea88d15b1e3..cf02253dcca2 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -247,6 +247,7 @@ I_IS_UFS2(const struct inode *ip)
 	} while (0)
 
 #define	IS_SNAPSHOT(ip)		((ip)->i_flags & SF_SNAPSHOT)
+#define	IS_UFS(vp)		((vp)->v_data != NULL)
 
 /*
  * Structure used to pass around logical block paths generated by