From nobody Thu Nov 19 12:18:26 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jVcv668hfz6w7tJ for ; Thu, 19 Nov 2026 12:18:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jVcv63Bkyz4Fv9 for ; Thu, 19 Nov 2026 12:18:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795090706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lssb//ul4oRjiMSMolz5ZAKn8BF86h4Eay+rNW+IADk=; b=ohBw+XwV6fX5LAbhhmwsqZLGNj51sg7MBMD8usd6MRK66dZ8MEjC/GGncC0NhN2QKgX0dh vWJQ/vJjEm+W4GOiIbs5E7XzIo/aC9Xfdjh4OEJtS9V3lFkicdv1Jeb4t2aV6TqS9QnDjM QstvPDeNPq4Ln/S+Eo/L63A5fj3/tIdbuto/UQ6nk9sC063ykeAlkn576WvZp+FJ32upKw WGjNdQ45DoD1Z5AT+7fQ6D0cRdCKvZSAdBVnh76Mq5T0cfgo27n9yYKpBRGWsMH6M003jH s4CosBDA8VesHQgYJBnK3p+VByh+C9koOrZ+q1XNgl//NqLK994NO4HS59727g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795090706; b=vyUE9tuuWWmrh30WDpNnhXV/KoeyXymnSydzzYL/jh2QidhS67+ZkbgwleAaoIi/5FFLyZ o0oSlK2tIwYfUjZXrMqP11WXZZyq5378aI4crJkSldRu+U33CvqqQcTc0lRGvMIm0UmODW B2ZIZw0k+e15QNCp9HtWzSijFC+4b6dUGGxbhpzfsU7ZeDnVVEE7HYpa+ttRlLxSnWfBLe C3c5qubUZcVfiGnOjqCckkemMVbUkHm8d89q3MIhMO640ctXHj2+W9qrQwyC3zzhzRy326 TMkjhMlGYL2iXMYakeMCbQtzpQyzxpsD9o/7R8fCkgxN8nD8Y9t6yFyqFuAHVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795090706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lssb//ul4oRjiMSMolz5ZAKn8BF86h4Eay+rNW+IADk=; b=XxwTKpEXCtzCIUjGL7EkHDi+deXJzdXTEINfectWMKBreWf5tPrC0Dsvg0CSr6FaZUhGAF 9JHd2nZ55tAaRRd220anzDyTjHuH9v14O58V2n3FRXgJC7wn3MLDLvbaGn+ubwXJXLXVTJ YmYEDXd7nMVvCGwU3k1orknB2EAmAeiMTS9O5n9ShD6OZ2SMUP6XwvAvQmO0MmHP/rqvz/ nlMK07arQuOAq4ShchIiTqV8DFJSEf3S1NOsntnSYl8vizgXTh5WjfwC3CcKeB29NI4iF2 gB29KJc+sKBSb5DPvfdiD9OXmMOZOLcJyW/SYfGgA21d2dLUU+Q9qtRU+LpoPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jVcv60ngzz11J0 for ; Thu, 19 Nov 2026 12:18:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 171ae by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 19 Nov 2026 12:18:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 148d61e4d0ef - main - ffs_bdflush(): do not call VOP_FSYNC(devvp) for unlocked devvp List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 148d61e4d0efada9626f665e30beb28c1ec83748 Auto-Submitted: auto-generated Date: Thu, 19 Nov 2026 12:18:26 +0000 Message-Id: <6afee912.171ae.5e0937d0@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=148d61e4d0efada9626f665e30beb28c1ec83748 commit 148d61e4d0efada9626f665e30beb28c1ec83748 Author: Konstantin Belousov AuthorDate: 2026-11-17 19:20:48 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-19 12:17:46 +0000 ffs_bdflush(): do not call VOP_FSYNC(devvp) for unlocked devvp Instead, delegate the fsync to taskqueue, which can lock mntfs devvp. The asynchronous fsync there is fine because bdflush() is not guaranteed to write anything at all. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/ufs/ffs/ffs_extern.h | 1 + sys/ufs/ffs/ffs_snapshot.c | 27 +++++++++++++++++++++++---- sys/ufs/ffs/ffs_vfsops.c | 7 +++++++ sys/ufs/ufs/ufsmount.h | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 0dc52ee48b1e..8ac2a6c44809 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -228,6 +228,7 @@ void softdep_freework(struct workhead *); #define DATA_ONLY 0x00000002 int ffs_rdonly(struct inode *); +void ffs_devvp_bdflush_fsync(void *arg, int pending); TAILQ_HEAD(snaphead, inode); diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index f1170d822131..c32033f5b28f 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,11 @@ ffs_sync_snap(struct mount *mp, int waitfor) { } +void +ffs_devvp_bdflush_fsync(void *arg, int pending) +{ +} + #else FEATURE(ffs_snapshot, "FFS snapshot support"); @@ -2194,18 +2200,31 @@ ffs_bp_snapblk(struct vnode *devvp, struct buf *bp) return (0); } +void +ffs_devvp_bdflush_fsync(void *arg, int pending) +{ + struct ufsmount *ump; + struct vnode *devvp; + + ump = arg; + devvp = ump->um_devvp; + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); + (void)VOP_FSYNC(devvp, MNT_NOWAIT, curthread); + VOP_UNLOCK(devvp); + altbufferflushes++; +} + void ffs_bdflush(struct bufobj *bo, struct buf *bp) { - struct thread *td; struct vnode *vp, *devvp; struct buf *nbp; + struct ufsmount *ump; int bp_bdskip; if (bo->bo_dirty.bv_cnt <= dirtybufthresh) return; - td = curthread; vp = bp->b_vp; devvp = bo2vnode(bo); KASSERT(vp == devvp, ("devvp != vp %p %p", bo, bp)); @@ -2216,8 +2235,8 @@ ffs_bdflush(struct bufobj *bo, struct buf *bp) bdwriteskip++; VI_UNLOCK(devvp); if (bo->bo_dirty.bv_cnt > dirtybufthresh + 10 && !bp_bdskip) { - (void) VOP_FSYNC(vp, MNT_NOWAIT, td); - altbufferflushes++; + ump = VFSTOUFS((struct mount *)devvp->v_data); + taskqueue_enqueue(taskqueue_thread, &ump->um_devvp_fsync_task); } else { BO_LOCK(bo); /* diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index b692f9c49a2a..9f13f049f7a2 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -1144,6 +1145,9 @@ ffs_mountfs(struct vnode *odevvp, struct mount *mp, struct thread *td) #ifdef UFS_EXTATTR ufs_extattr_uepm_init(&ump->um_extattr); #endif + + TASK_INIT(&ump->um_devvp_fsync_task, 0, ffs_devvp_bdflush_fsync, ump); + /* * Set FS local "last mounted on" information (NULL pad) */ @@ -1202,6 +1206,8 @@ out: free(fs->fs_si, M_UFSMNT); free(fs, M_UFSMNT); } + if (ump != NULL) + taskqueue_drain(taskqueue_thread, &ump->um_devvp_fsync_task); if (cp != NULL) g_vfs_close_unlocked(cp); if (ump != NULL) { @@ -1317,6 +1323,7 @@ ffs_unmount(struct mount *mp, int mntflags) taskqueue_free(ump->um_trim_tq); free (ump->um_trimhash, M_TRIM); } + taskqueue_drain(taskqueue_thread, &ump->um_devvp_fsync_task); vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); g_topology_lock(); g_vfs_close(ump->um_cp); diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index d33b01e4425e..4f57ef715865 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -117,6 +117,7 @@ struct ufsmount { struct trimlist_hashhead *um_trimhash; /* (i) trimlist hash table */ u_long um_trimlisthashsize; /* (i) trim hash table size-1 */ /* (c) - below function ptrs */ + struct task um_devvp_fsync_task; int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **); int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);