NetBSD Problem Report #58564
From bad@bsd.de Thu Aug 8 21:33:55 2024
Return-Path: <bad@bsd.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 302A01A923E
for <gnats-bugs@gnats.NetBSD.org>; Thu, 8 Aug 2024 21:33:55 +0000 (UTC)
Message-Id: <20240808213350.GO9440@irregular-apocalypse.k.bsd.de>
Date: Thu, 8 Aug 2024 23:33:50 +0200
From: Christoph Badura <bad@bsd.de>
Reply-To: Christoph Badura <bad@bsd.de>
To: gnats-bugs@NetBSD.org
Subject: async mounts revert to being synced after failed unmount
X-Send-Pr-Version: 3.95
>Number: 58564
>Category: kern
>Synopsis: when unmount an async mount fails the mount point erroneously gets put on the kernel syncer's worklist.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bad
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 08 21:35:00 +0000 2024
>Closed-Date: Sun Aug 11 14:03:05 +0000 2024
>Last-Modified: Sun Aug 11 14:03:05 +0000 2024
>Originator: Christoph Badura <bad@bsd.de>
>Release: NetBSD 10.99.11
>Organization:
Bozotic Software Testing Labs
<organization of PR author (multiple lines)>
>Environment:
<The following information is extracted from your kernel. Please>
<append output of "ldd", "ident" where relevant (multiple lines).>
System: NetBSD nbcurrent 10.99.11 NetBSD 10.99.11 (GENERIC) #4: Mon Jul 29 18:24:41 CEST 2024 bad@inspiral-coalescence-ringdown:/Users/bad/netbsd-gsoc/obj/obj.amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
sys/kern/vfs_mount.c:dounmount()
before calling the VFS_SYNC() and VFS_UNMOUNT() ops, dounmount removes the
MNT_ASYNC flag from mp->mnt_flag. (Apparently so that the bwrite()s don't
get converted into delayed writes.
https://nxr.netbsd.org/xref/src/sys/kern/vfs_bio.c#862)
If either VFS op errors, dounmount() it restores the aysnc flag setting.
Alas only after the test to put the mount point on the vfs syncer worklist,
which checks if the that flag is set in mp->mnt_flag.
Hence, an async-mounted file system that fails to unmount reverts to having
it's dirty buffers periodically synced.
Found during random code inspection:
https://nxr.netbsd.org/xref/src/sys/kern/vfs_mount.c?r=1.105#980
976 if (error) {
977 mp->mnt_iflag &= ~IMNT_UNMOUNT;
978 if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0)
979 vfs_syncer_add_to_worklist(mp);
980 mp->mnt_flag |= async;
<precise description of the problem (multiple lines)>
>How-To-Repeat:
mount -t tmpfs -oasync tmpfs /mnt
cd /mnt
umount /mnt
<code/input/activities to reproduce the problem (multiple lines)>
>Fix:
Obvious.
<how to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
From: "Christoph Badura" <bad@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58564 CVS commit: src
Date: Fri, 9 Aug 2024 23:24:15 +0000
Module Name: src
Committed By: bad
Date: Fri Aug 9 23:24:15 UTC 2024
Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/kernel: Makefile
Added Files:
src/tests/kernel: t_unmount.c
Log Message:
add tests/kernel/t_umount.c: test case for unmount(2)
demonstrate that failing to umount and async mounted file system causes the
kernel syncer to start flushing dirty buffers for it.
PR kern/58564: async mounts revert to being synced after failed unmount
To generate a diff of this commit:
cvs rdiff -u -r1.440 -r1.441 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1328 -r1.1329 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.78 -r1.79 src/tests/kernel/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/t_unmount.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Christoph Badura" <bad@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58564 CVS commit: src
Date: Sun, 11 Aug 2024 12:58:10 +0000
Module Name: src
Committed By: bad
Date: Sun Aug 11 12:58:10 UTC 2024
Modified Files:
src/sys/kern: vfs_mount.c
src/tests/kernel: t_unmount.c
Log Message:
vfs_subr.c: in dounmount restore the async flag before checking it
This avoids the file system being put on the syncer work list and future
modified buffers being flushed to disk by the synce after an attempt to
unmount it fails.
Adjust the test case to not expect a failure.
fixes PR kern/58564.
To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.2 -r1.3 src/tests/kernel/t_unmount.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Christoph Badura" <bad@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58564 CVS commit: src/sys/kern
Date: Sun, 11 Aug 2024 13:09:58 +0000
Module Name: src
Committed By: bad
Date: Sun Aug 11 13:09:58 UTC 2024
Modified Files:
src/sys/kern: vfs_mount.c vfs_syscalls.c
Log Message:
explain why MNT_ASYNC is temporarily cleared
related to PR kern/58564.
To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.566 -r1.567 src/sys/kern/vfs_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: bad@NetBSD.org
State-Changed-When: Sun, 11 Aug 2024 14:03:05 +0000
State-Changed-Why:
the bug has been fixed.
>Unformatted:
<Please check that the above is correct for the bug being reported,>
<and append source date of snapshot, if applicable (one line).>
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.