Page MenuHomeFreeBSD

FIOSEEKHOLE/FIOSEEKDATA: correct constistency for bmap-based implementation
ClosedPublic

Authored by kib on Feb 4 2023, 1:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 8:16 AM
Unknown Object (File)
Mar 16 2024, 10:42 PM
Unknown Object (File)
Mar 16 2024, 10:42 PM
Unknown Object (File)
Mar 16 2024, 10:42 PM
Unknown Object (File)
Mar 14 2024, 6:38 AM
Unknown Object (File)
Mar 10 2024, 10:29 PM
Unknown Object (File)
Feb 20 2024, 5:24 PM
Unknown Object (File)
Jan 22 2024, 4:01 PM
Subscribers

Details

Summary
Writes on UFS through a mapped region do not allocate disk blocks in
holes immediately. The blocks are allocated when the pages are first
time paged out.

This breaks the algorithm in vn_bmap_seekhole() and ufs_bmap_seekdata(),
because VOP_BMAP() report hole for the place which already contains a
valid data.

Clean pages before doing VOP_BMAP() in the affected functions.  In
principle, we could clean less by only requesting clean starting from
the offset, but it is probably not very important.

PR:     269261
Reported by:    asomers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Feb 4 2023, 1:28 AM

Zap unneeded VOP_FDATASYNC

sys/kern/vfs_vnops.c
2568

Why exactly do we need the exclusive lock? VOP_PUTPAGES doesn't formally require it.

kib marked an inline comment as done.Feb 4 2023, 2:11 AM
kib added inline comments.
sys/kern/vfs_vnops.c
2568

The call chain is vm_object_page_clean()->vm_object_page_collect_flush()->vm_pageout_flush()->vm_pager_put_pages()->vnode_pager_putpages()->VOP_PUTPAGES()->vnode_pager_generic_putpages()->VOP_WRITE()

VOP_PUTPAGES() only requires locked vnode because some filesystems (zfs) only required read-locked vnode for write. But for UFS, VOP_WRITE() must be provided with exclusively-locked vp.

LGTM and it fixes the tests for UFS, though I'm not an expert in this area. The problem with fusefs has a different cause; I'll discuss on bugzilla.

This revision is now accepted and ready to land.Feb 4 2023, 5:01 PM