git: 9e4f35ac2553 - main - vfs: deperl msleep flag calculation in vn_start_*write

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 17 Sep 2022 15:42:38 UTC
The branch main has been updated by mjg:

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

commit 9e4f35ac25538fb426c459400f0c36e085546ffa
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-09-17 15:17:20 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-09-17 15:17:20 +0000

    vfs: deperl msleep flag calculation in vn_start_*write
---
 sys/kern/vfs_vnops.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 2e39d8a9e4d2..a7ca547f571f 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1875,8 +1875,12 @@ vn_start_write_refed(struct mount *mp, int flags, bool mplocked)
 	 */
 	if ((curthread->td_pflags & TDP_IGNSUSP) == 0 ||
 	    mp->mnt_susp_owner != curthread) {
-		mflags = ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ?
-		    (flags & PCATCH) : 0) | (PUSER - 1);
+		mflags = 0;
+		if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
+			if (flags & PCATCH)
+				mflags |= PCATCH;
+		}
+		mflags |= (PUSER - 1);
 		while ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) {
 			if (flags & V_NOWAIT) {
 				error = EWOULDBLOCK;
@@ -1944,7 +1948,7 @@ int
 vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
 {
 	struct mount *mp;
-	int error;
+	int error, mflags;
 
  retry:
 	if (vp != NULL) {
@@ -1986,9 +1990,13 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
 	/*
 	 * Wait for the suspension to finish.
 	 */
-	error = msleep(&mp->mnt_flag, MNT_MTX(mp), (PUSER - 1) | PDROP |
-	    ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ? (flags & PCATCH) : 0),
-	    "suspfs", 0);
+	mflags = 0;
+	if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
+		if (flags & PCATCH)
+			mflags |= PCATCH;
+	}
+	mflags |= (PUSER - 1) | PDROP;
+	error = msleep(&mp->mnt_flag, MNT_MTX(mp), mflags, "suspfs", 0);
 	vfs_rel(mp);
 	if (error == 0)
 		goto retry;