Page MenuHomeFreeBSD

tmpfs: reimplement the mtime scan to use the lazy list
AbandonedPublic

Authored by mjg on Jan 30 2020, 4:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 9:44 AM
Unknown Object (File)
Mar 18 2024, 9:03 AM
Unknown Object (File)
Nov 8 2023, 1:42 PM
Unknown Object (File)
Nov 7 2023, 4:39 PM
Unknown Object (File)
Nov 6 2023, 4:11 AM
Unknown Object (File)
Nov 5 2023, 4:26 PM
Unknown Object (File)
Oct 27 2023, 10:39 PM
Unknown Object (File)
Oct 27 2023, 9:36 PM

Details

Reviewers
kib
jeff
Summary

Vast majority of vnodes are not mmaped for writing and the entire list scan is highly wasteful.

Keep a hold on the vnode to prevent it from disappearing before we managed to inspect it.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/fs/tmpfs/tmpfs_vnops.c
1487

I think that good enough substitute for this flag is just tn_obj->ref_count > 1. It might be slightly too aggressive causing false positives (both transient and e.g. CoW ro) but it has a nice property of reducing to false for non-reclaimed vnode when the last mapping is destroyed.

sys/fs/tmpfs/tmpfs_vnops.c
1487

you mean to denote the extra hold with increased obj->ref_count? i don't see how to verify we got it against said counter.

BTW, why not use lazy list processing for mtime update, and remove tmpfs_update_mtime() ?

sys/fs/tmpfs/tmpfs_vnops.c
1487

No, I mean that use obj->ref_count > 1 as the indicator of the presence of a mapping, instead of the flag.

So the original code had:

+               /*
+                * Handle lazy updates of mtime from writes to mmaped
+                * regions.  Use MNT_VNODE_FOREACH_ALL instead of
+                * MNT_VNODE_FOREACH_ACTIVE, since unmap of the
+                * tmpfs-backed vnode does not call vinactive(), due
+                * to vm object type is OBJT_SWAP.
+                */

In the patch the problem is combated with putting the vnode on the lazy list with an explicit hold. Should the mapping disappear, we will find it anyway and remove the extra attachment. However, the vnode may be put on the list for other reasons (in particular just being opened for writing) and consequently there needs to be a way to denote that there is an extra hold. As such, inspecting the write count is in my opinion insufficient.