Page MenuHomeFreeBSD

vfs: add vn_getsize
ClosedPublic

Authored by mjg on Dec 27 2022, 9:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 2:16 AM
Unknown Object (File)
Thu, Oct 9, 5:00 PM
Unknown Object (File)
Sep 12 2025, 11:15 AM
Unknown Object (File)
Sep 8 2025, 5:51 PM
Unknown Object (File)
Sep 3 2025, 5:27 PM
Unknown Object (File)
Aug 21 2025, 12:48 AM
Unknown Object (File)
Aug 3 2025, 7:13 AM
Unknown Object (File)
Aug 2 2025, 5:48 PM

Details

Summary

getattr is very expensive and in important cases only gets called to get the size. This can be optimized with a dedicated routine which obtains that statistic.

As a step towards there make size-only consumers use a dedicated routine.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Dec 27 2022, 9:45 PM
This revision is now accepted and ready to land.Dec 28 2022, 3:11 AM
This revision was automatically updated to reflect the committed changes.

Hi @mjg & @kib, if the plan was to eventually add a VOP_GETSIZE(), I would suggest getting it done in the next few weeks, before we branch stable/15. Do you have something planned already or would you like me to cook up a patch?

In D37885#1165729, @des wrote:

Hi @mjg & @kib, if the plan was to eventually add a VOP_GETSIZE(), I would suggest getting it done in the next few weeks, before we branch stable/15. Do you have something planned already or would you like me to cook up a patch?

For stable. we have reserved VOP slots that can be used, but usually we do not consider VFS to fall under the stable branch ABI stability guarantee (same as VM).

That said, I generally do not like the proliferation of specialized VOPs duplicating existing interfaces. We already have VOP_GETATTR(), and VOP_STAT(). To add VOP_GETSIZE(), we need a clear indication that it is significant improvement in some load. I suspect it would be only tmpfs, with specific usage, if anything.

Well then what was the point of adding vn_getsize() if it wasn't eventually going to be backed by a VOP?

In D37885#1166278, @des wrote:

Well then what was the point of adding vn_getsize() if it wasn't eventually going to be backed by a VOP?

It is a convenient wrapper, requiring less ceremony to get the vnode size.
Also, if there is indeed a (significant) performance gain, VOP_GETSIZE() would be justified.