Page MenuHomeFreeBSD

tmpfs: implement FIOSEEKDATA and FIOSEEKHOLE
ClosedPublic

Authored by kib on Oct 17 2022, 7:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 3 2024, 9:49 AM
Unknown Object (File)
Dec 23 2023, 1:36 AM
Unknown Object (File)
Dec 12 2023, 6:08 PM
Unknown Object (File)
Aug 27 2023, 12:25 AM
Unknown Object (File)
Jul 5 2023, 4:01 AM
Unknown Object (File)
Jul 5 2023, 4:00 AM
Unknown Object (File)
Jul 5 2023, 3:59 AM
Unknown Object (File)
Jul 2 2023, 1:43 PM
Subscribers

Diff Detail

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

Event Timeline

kib requested review of this revision.Oct 17 2022, 7:26 PM
sys/fs/tmpfs/tmpfs_vnops.c
1851 ↗(On Diff #111870)

You could optimize for the case where no pages are swapped: check if the swap block trie is empty, and if so use vm_page_find_least(). With a bit more work, the swap pager could find the next block after a given pindex.

I remember that we needed similar optimizations to UFS to avoid pathological behaviour found by syzkaller. It would create a giant sparse file, then FIOSEEKDATA would spend eternity checking each block one by one in an unkillable loop.

1852 ↗(On Diff #111870)

I'd avoid accessing vm_page fields like this, and instead write m != NULL && !vm_page_none_valid(m)). And maybe add vm_page_any_valid() so that we don't need a double negative.

kib marked 2 inline comments as done.

Make tmpfs_seek_data_locked() loop-less (I do not see a way to avoid walking the object page queue in tmpfs_seek_hole_locked()).
Add vm_page_any_valid() and use helpers in more places.

In D37024#841021, @kib wrote:

(I do not see a way to avoid walking the object page queue in tmpfs_seek_hole_locked()).

Yes, for SEEKHOLE we need to check each index.

Add vm_page_any_valid() and use helpers in more places.

Thanks.

sys/fs/tmpfs/tmpfs_vnops.c
1841 ↗(On Diff #111914)
This revision is now accepted and ready to land.Oct 18 2022, 2:28 PM
kib marked an inline comment as done.Oct 18 2022, 2:35 PM