Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FreeBSD] vn_flush_cached_data: observe vnode locking contract #14079

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

avg-I
Copy link
Contributor

@avg-I avg-I commented Oct 24, 2022

vm_object_page_clean() expects that the associated vnode is locked as VOP_PUTPAGES() may get called on the vnode.
Without this fix I got a panic on a system with DEBUG_VFS_LOCKS enabled in kernel configuration.

The panic output:

KDB: stack backtrace:
db_trace_self_wrapper() at 0xffffffff80614ddb = db_trace_self_wrapper+0x2b/frame 0xfffffe021e5d66f0
kdb_backtrace() at 0xffffffff80941b17 = kdb_backtrace+0x37/frame 0xfffffe021e5d67a0
assert_vop_locked() at 0xffffffff809d1275 = assert_vop_locked+0x55/frame 0xfffffe021e5d67d0
VOP_PUTPAGES_APV() at 0xffffffff80cbb7a2 = VOP_PUTPAGES_APV+0x82/frame 0xfffffe021e5d67f0
vnode_pager_putpages() at 0xffffffff80bb6a66 = vnode_pager_putpages+0x96/frame 0xfffffe021e5d6860
vm_pageout_flush() at 0xffffffff80ba8e25 = vm_pageout_flush+0xf5/frame 0xfffffe021e5d68f0
vm_object_page_collect_flush() at 0xffffffff80b9b473 = vm_object_page_collect_flush+0x273/frame 0xfffffe021e5d6a60
vm_object_page_clean() at 0xffffffff80b9b0a4 = vm_object_page_clean+0x184/frame 0xfffffe021e5d6ac0
zfs_holey() at 0xffffffff804ffc9b = zfs_holey+0xcb/frame 0xfffffe021e5d6b20
zfs_freebsd_ioctl() at 0xffffffff80397c3f = zfs_freebsd_ioctl+0x4f/frame 0xfffffe021e5d6b50
VOP_IOCTL_APV() at 0xffffffff80cb7c46 = VOP_IOCTL_APV+0x96/frame 0xfffffe021e5d6b70
vn_ioctl() at 0xffffffff809e8a1f = vn_ioctl+0x12f/frame 0xfffffe021e5d6c80
vn_seek() at 0xffffffff809e8fe3 = vn_seek+0x1b3/frame 0xfffffe021e5d6da0
kern_lseek() at 0xffffffff809e2779 = kern_lseek+0x69/frame 0xfffffe021e5d6de0
sys_lseek() at 0xffffffff809e2704 = sys_lseek+0x14/frame 0xfffffe021e5d6df0
amd64_syscall() at 0xffffffff80c2b836 = amd64_syscall+0x186/frame 0xfffffe021e5d6f30
fast_syscall_common() at 0xffffffff80c0240b = fast_syscall_common+0xf8/frame 0xfffffe021e5d6f30
--- syscall (478, FreeBSD ELF64, sys_lseek), rip = 0x36f419e1b73a, rsp = 0x36f416fe9458, rbp = 0x36f416fe97d0 ---
vnode 0xfffff801cd140b70: type VREG
    usecount 3, writecount 2, refcount 2 seqc users 0
    hold count flags ()
    flags ()
    v_object 0xfffff802057fb738 ref 1 pages 8 cleanbuf 0 dirtybuf 0
    lock type zfs: UNLOCKED
VOP_PUTPAGES: 0xfffff801cd140b70 is not locked but should be
KDB: enter: lock violation

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Signed-off-by: Andriy Gapon <[email protected]>
@avg-I avg-I force-pushed the fbsd-vn_flush_cached_data-fix branch from 3355a3a to 2ea0bcb Compare October 24, 2022 15:28
@ghost ghost added the Status: Accepted Ready to integrate (reviewed, tested) label Oct 26, 2022
@behlendorf behlendorf merged commit 41133c9 into openzfs:master Oct 26, 2022
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Oct 27, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
ghost pushed a commit to truenas/zfs that referenced this pull request Oct 27, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
(cherry picked from commit 41133c9)
ghost pushed a commit to truenas/zfs that referenced this pull request Oct 27, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
(cherry picked from commit 41133c9)
behlendorf pushed a commit that referenced this pull request Oct 27, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes #14079
(cherry picked from commit 41133c9)
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Nov 9, 2022
vm_object_page_clean() expects that the associated vnode is locked
as VOP_PUTPAGES() may get called on the vnode.

Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Andriy Gapon <[email protected]>
Closes openzfs#14079
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants