Page MenuHomeFreeBSD

FIOSEEKHOLE/FIOSEEKDATA: correct constistency for bmap-based implementation

Authored by kib on Feb 4 2023, 1:28 AM.
Referenced Files
Unknown Object (File)
Tue, Mar 21, 6:53 AM
Unknown Object (File)
Sat, Mar 18, 6:02 AM
Unknown Object (File)
Thu, Mar 9, 8:46 PM
Unknown Object (File)
Mon, Feb 27, 10:46 PM
Unknown Object (File)
Feb 10 2023, 7:48 PM
Unknown Object (File)
Feb 4 2023, 1:34 AM


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

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

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

Zap unneeded VOP_FDATASYNC


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.

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