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)
Tue, Mar 19, 3:18 AM
Unknown Object (File)
Tue, Mar 19, 2:54 AM
Unknown Object (File)
Thu, Mar 14, 11:15 PM
Unknown Object (File)
Fri, Mar 8, 12:21 PM
Unknown Object (File)
Thu, Mar 7, 3:07 PM
Unknown Object (File)
Wed, Mar 6, 4:48 AM
Unknown Object (File)
Feb 21 2024, 5:21 PM
Unknown Object (File)
Feb 12 2024, 8: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 36498
Build 33387: 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
555

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.

624

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
35 ↗(On Diff #93141)

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

57 ↗(On Diff #93141)

Replace "operation" by "affected".

59 ↗(On Diff #93141)
60 ↗(On Diff #93141)
65 ↗(On Diff #93141)
66 ↗(On Diff #93141)
70 ↗(On Diff #93141)
khng marked 7 inline comments as done.

vnode_pager_purge_range.9: Wording fixes from alc@.

share/man/man9/vnode_pager_purge_range.9
35 ↗(On Diff #93141)

That sounds better to me.

sys/vm/vnode_pager.c
430

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

537

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

550

Could this line be unwrapped?

552

() is excessive.

566

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
550

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

566

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
546

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
546

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

This revision was automatically updated to reflect the committed changes.