Page MenuHomeFreeBSD

tmpfs: implement FIOSEEKDATA and FIOSEEKHOLE
ClosedPublic

Authored by kib on Oct 17 2022, 7:26 PM.
Tags
None
Referenced Files
F109383961: D37024.diff
Tue, Feb 4, 8:53 AM
Unknown Object (File)
Sat, Jan 25, 3:25 AM
Unknown Object (File)
Thu, Jan 9, 5:12 PM
Unknown Object (File)
Wed, Jan 8, 6:42 PM
Unknown Object (File)
Dec 1 2024, 10:28 PM
Unknown Object (File)
Nov 25 2024, 12:56 PM
Unknown Object (File)
Nov 23 2024, 7:32 AM
Unknown Object (File)
Nov 20 2024, 11:28 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