zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Fix long_free_dirty accounting for small files

Open tuxoko opened this issue 1 year ago • 1 comments

Motivation and Context

Description

For files smaller than recordsize, it's most likely that they don't have L1 blocks. However, current calculation will always return at least 1 L1 block.

In this change, we check dnode level to figure out if it has L1 blocks or not, and return 0 if it doesn't. This will reduce the chance of unnecessary throttling when deleting a large number of small files.

How Has This Been Tested?

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [x] Performance enhancement (non-breaking change which improves efficiency)
  • [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • [ ] Documentation (a change to man pages or other documentation)

Checklist:

  • [x] My code follows the OpenZFS code style requirements.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the contributing document.
  • [ ] I have added tests to cover my changes.
  • [ ] I have run the ZFS Test Suite with this change applied.
  • [x] All commit messages are properly formatted and contain Signed-off-by.

tuxoko avatar Jun 14 '24 00:06 tuxoko

It seems OK, but I think we could simplify it even more by checking dn->dn_nlevels <= 1 before doing any math at all, and just returning *start = minimum; and *l1blks = 0;.

I guess so. I'll change it then.

tuxoko avatar Jun 14 '24 18:06 tuxoko