Bug 238565 - panic: vinvalbuf: dirty bufs during unmount if clustered writes return errors
Summary: panic: vinvalbuf: dirty bufs during unmount if clustered writes return errors
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-fs mailing list
Depends on:
Reported: 2019-06-14 18:05 UTC by Alan Somers
Modified: 2019-07-01 14:04 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer 2019-06-14 18:05:17 UTC
It seems that if a clustered write experiences an error while fsyncing during unmount, vinvalbuf will panic.  This only happens with clustered writes, not normal writes.  So far I've only been able to reproduce it on fusefs, but I suspect that all file systems which use clustering (UFS, ext2, msdosfs, fusefs) are affected.  The problem is easiest to reproduce with fusefs just because fuse makes it easy to inject errors at any point.

The panic can be reproduced on the projects/fuse2 branch by doing the following:
$ sudo sysctl sysctl vfs.fusefs.data_cache_mode=2
$ cd /usr/tests/sys/fs/fusefs
$ ./write --gtest_also_run_disabled_tests  --gtest_filter=WriteCluster.DISABLED_cluster_write_err -v

fsync: giving up on dirty (error = 5) 0xfffff80049732960: tag fuse, type VREG
    usecount 0, writecount 0, refcount 5
    v_object 0xfffff80049318900 ref 0 pages 48 cleanbuf 0 dirtybuf 3
    lock type fuse: EXCL by thread 0xfffff8000337f5a0 (pid 3944, write, tid 100085)
nodeid: 42, parent nodeid: 0, nlookup: 1, flag: 0
panic: vinvalbuf: dirty bufs
cpuid = 0
time = 1560534385
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0031dd84c0
vpanic() at vpanic+0x19d/frame 0xfffffe0031dd8510
panic() at panic+0x43/frame 0xfffffe0031dd8570
bufobj_invalbuf() at bufobj_invalbuf+0x2ca/frame 0xfffffe0031dd85d0
vgonel() at vgonel+0x15e/frame 0xfffffe0031dd8640
vflush() at vflush+0x22c/frame 0xfffffe0031dd8790
fuse_vfsop_unmount() at fuse_vfsop_unmount+0xad/frame 0xfffffe0031dd8800
dounmount() at dounmount+0x4ae/frame 0xfffffe0031dd8860
sys_unmount() at sys_unmount+0x300/frame 0xfffffe0031dd8990
amd64_syscall() at amd64_syscall+0x276/frame 0xfffffe0031dd8ab0
fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe0031dd8ab0
--- syscall (22, FreeBSD ELF64, sys_unmount), rip = 0x80052d9aa, rsp = 0x7fffffffe6e8, rbp = 0x7fffffffe700 ---
KDB: enter: panic
Comment 1 commit-hook freebsd_committer 2019-06-14 18:15:38 UTC
A commit references this bug:

Author: asomers
Date: Fri Jun 14 18:14:53 UTC 2019
New revision: 349036
URL: https://svnweb.freebsd.org/changeset/base/349036

  fusefs: enable write clustering

  Enable write clustering in fusefs whenever cache mode is set to writeback
  and the "async" mount option is used.  With default values for MAXPHYS,
  DFLTPHYS, and the fuse max_write mount parameter, that means sequential
  writes will now be written 128KB at a time instead of 64KB.

  Also, add a regression test for PR 238565, a panic during unmount that
  probably affects UFS, ext2, and msdosfs as well as fusefs.

  PR:		238565
  Sponsored by:	The FreeBSD Foundation