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)
Wed, May 8, 8:07 AM
Unknown Object (File)
Wed, May 8, 8:06 AM
Unknown Object (File)
Wed, May 8, 8:06 AM
Unknown Object (File)
Wed, May 8, 8:06 AM
Unknown Object (File)
Wed, May 8, 5:15 AM
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
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Oct 17 2022, 7:26 PM
sys/fs/tmpfs/tmpfs_vnops.c
1852

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.

1853

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
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