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)
Fri, Nov 15, 7:49 PM
Unknown Object (File)
Fri, Nov 15, 7:38 AM
Unknown Object (File)
Thu, Nov 14, 6:49 PM
Unknown Object (File)
Wed, Nov 13, 3:38 AM
Unknown Object (File)
Mon, Nov 11, 9:43 AM
Unknown Object (File)
Tue, Oct 29, 5:39 PM
Unknown Object (File)
Oct 5 2024, 4:38 PM
Unknown Object (File)
Oct 5 2024, 3:36 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 Skipped
Unit
Tests Skipped

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