Page MenuHomeFreeBSD

Add vnode_pager_purge_range(9) KPI
ClosedPublic

Authored by khng on Nov 12 2020, 4:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 15, 6:28 AM
Unknown Object (File)
Sat, Nov 9, 9:51 PM
Unknown Object (File)
Tue, Oct 29, 12:07 PM
Unknown Object (File)
Tue, Oct 29, 2:33 AM
Unknown Object (File)
Thu, Oct 24, 8:11 AM
Unknown Object (File)
Thu, Oct 24, 6:45 AM
Unknown Object (File)
Thu, Oct 24, 2:31 AM
Unknown Object (File)
Sat, Oct 19, 4:54 PM

Details

Summary

This KPI is created in addition to the existing vnode_pager_setsize(9)
KPI. The KPI is intended for file systems that are able to turn a range
of file into sparse range, also known as hole-punching.

Submitted by: Ka Ho Ng <khng@freebsdfoundation.org>
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37243
Build 34132: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
sys/vm/vnode_pager.c
568

Suppose (startoff & PAGE_MASK) != 0. Note that OFF_TO_IDX(startoff) == OFF_TO_IDX(startoff & ~PAGE_MASK). Finally suppose that the page at OFF_TO_IDX(startoff) is resident in the object. vm_object_page_remove() will free the page at this index, so we will throw away data that is outside the requested range. In other words, I believe this vm_page_grab() call will always return NULL.

637

I think this block of code is asking to be moved into a subroutine, otherwise it is duplicated three times in this file.

khng marked 2 inline comments as done.Jan 29 2021, 6:20 AM
  • Minor changes in vnode_pager_purge_range to unnecessary vm_object_page_remove
khng planned changes to this revision.Feb 1 2021, 7:16 AM
  • vnode_pager_purge_range fixes on non-existing page (m == NULL)

Rebased on top of freebsd/main

Rebased onto D27194

  • Add fspacectl(2) and VOP_FDEALLOCATE(9).
  • Regen.
  • Wire up OpenZFS with VOP_DEALLOCATE(9)

Fixes cross-referencing D28347

  • Add vnode_pager_purge_range(9) KPI
  • vnode_pager_purge_range comments updated
  • Add vnode_pager_purge_range.9
  • vnode_pager_purge_range.9 linting and style fixes
  • Update wording
  • Two fixes:
  • Minor changes in vnode_pager_purge_range to unnecessary vm_object_page_remove
  • vnode_pager_purge_range fixes on non-existing page (m == NULL)

Rebased on top of freebsd/main

  • Add vnode_pager_purge_range(9) KPI
  • vnode_pager_purge_range comments updated
  • Add vnode_pager_purge_range.9
  • vnode_pager_purge_range.9 linting and style fixes
  • Update wording
  • Two fixes:
  • Minor changes in vnode_pager_purge_range to unnecessary vm_object_page_remove
  • vnode_pager_purge_range fixes on non-existing page (m == NULL)

Rebased

  • Add vnode_pager_purge_range(9) KPI
  • vnode_pager_purge_range comments updated
  • Add vnode_pager_purge_range.9
  • vnode_pager_purge_range.9 linting and style fixes
  • Update wording
  • Two fixes:
  • Minor changes in vnode_pager_purge_range to unnecessary vm_object_page_remove
  • vnode_pager_purge_range fixes on non-existing page (m == NULL)

Updated to tools/tools/git/git-arc.sh workflow

  • cpucontrol(8): Fix display.
  • grep: fix null pattern and empty pattern file behavior
  • grep: turn off -w if -x is specified
  • Add vnode_pager_purge_range(9) KPI
  • vnode_pager_purge_range comments updated
  • Add vnode_pager_purge_range.9
  • vnode_pager_purge_range.9 linting and style fixes
  • Update wording
  • Two fixes:
  • Minor changes in vnode_pager_purge_range to unnecessary vm_object_page_remove
  • vnode_pager_purge_range fixes on non-existing page (m == NULL)
  • Add fspacectl(2) and VOP_FDEALLOCATE(9).
  • Regen.
  • Wire up OpenZFS with VOP_DEALLOCATE(9)

Manual: fix missing includes

gbe added a subscriber: gbe.

LGTM for the man page part.

khng planned changes to this revision.Aug 2 2021, 7:53 PM
  • Cleanups on naming
  • Handle case for a possible wraparound when start near the UINT64_MAX
  • Add 'end' == 0 support to allow cleaning the object all the way to the end
  • Manpage update due to 'end' == 0 support.
share/man/man9/vnode_pager_purge_range.9
36

I would suggest "invalidate the cached contents within the given byte range" here and below.

58

Replace "operation" by "affected".

60
61
66
67
71
khng marked 7 inline comments as done.

vnode_pager_purge_range.9: Wording fixes from alc@.

share/man/man9/vnode_pager_purge_range.9
36

That sounds better to me.

sys/vm/vnode_pager.c
430

Assert that end > base, and that end <= PAGE_SIZE?

550

'VM object in vnode' is usuall written as v_object.
The lock is not held, it is taken internally, but I am not sure why is this important for the caller to know.

OTOH, I expect that caller is required to own at least the vnode lock. This should be expressed by an assert.

563

Could this line be unwrapped?

565

() is excessive.

579

Again, as with shm case, if there is no resident page but file does not have a hole in the partial page' range, you need to clear the data. If this is supposed to be handled by the caller (ie. by fs), then documentation must be very clear about it.

sys/vm/vnode_pager.c
563

Longer than 80/81 cols for this one to be unwrapped.

579

This is supposed to be handled by the caller.

khng marked 5 inline comments as done.
  • Manpage updates.
  • styles.
  • asserts in the vnode_pager_subpage_purge function.
kib added inline comments.
sys/vm/vnode_pager.c
559

I wonder if you should require exclusive lock on the vnode.

This revision is now accepted and ready to land.Aug 3 2021, 4:13 PM
sys/vm/vnode_pager.c
559

It is for file systems allowing MNTK_SHARED_WRITES, such as zfs.

This revision was automatically updated to reflect the committed changes.