git: 46f02c4282ff - main - SU+J: all writes to SU journal must be exempt from runningbufspace throttling

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 13 Nov 2024 19:35:46 UTC
The branch main has been updated by kib:

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

commit 46f02c4282ff76b66579c83be53ef441ea522536
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-11-12 06:29:23 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-11-13 19:35:03 +0000

    SU+J: all writes to SU journal must be exempt from runningbufspace throttling
    
    regardless whether they come from the system thread or initiated from a
    normal thread helping the system.  If we block waiting for other writes,
    that writes might not finish because our journal updates block that.
    
    Set TDP_NORUNNINGBUF around softdep_process_journal().
    
    Note: Another solution might be to use bwrite() instead of bawrite() if the
    current thread is subject to the runningbufspace limit.  The exempt
    approach is used to be same as the bufdaemon.
    
    PR:     282449
    Noted and reviewed by:  markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/ufs/ffs/ffs_softdep.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 97f50867b012..98ad4269b5f2 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -3630,6 +3630,7 @@ softdep_process_journal(struct mount *mp,
 	int cnt;
 	int off;
 	int devbsize;
+	int savef;
 
 	ump = VFSTOUFS(mp);
 	if (ump->um_softdep == NULL || ump->um_softdep->sd_jblocks == NULL)
@@ -3641,6 +3642,8 @@ softdep_process_journal(struct mount *mp,
 	fs = ump->um_fs;
 	jblocks = ump->softdep_jblocks;
 	devbsize = ump->um_devvp->v_bufobj.bo_bsize;
+	savef = curthread_pflags_set(TDP_NORUNNINGBUF);
+
 	/*
 	 * We write anywhere between a disk block and fs block.  The upper
 	 * bound is picked to prevent buffer cache fragmentation and limit
@@ -3859,12 +3862,15 @@ softdep_process_journal(struct mount *mp,
 	 */
 	if (flags == 0 && jblocks->jb_suspended) {
 		if (journal_unsuspend(ump))
-			return;
+			goto out;
 		FREE_LOCK(ump);
 		VFS_SYNC(mp, MNT_NOWAIT);
 		ffs_sbupdate(ump, MNT_WAIT, 0);
 		ACQUIRE_LOCK(ump);
 	}
+
+out:
+	curthread_pflags_restore(savef);
 }
 
 /*