From 154a8b3fe9d06fe7e0143a212305bae8f9df45c5 Mon Sep 17 00:00:00 2001 From: Chunwei Chen Date: Fri, 14 Jun 2024 00:22:26 +0000 Subject: [PATCH] Fix long_free_dirty accounting for small files 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. Signed-off-by: Chunwei Chen --- module/zfs/dmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 8b440aafba43..0c8d10114829 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -827,6 +827,9 @@ get_next_chunk(dnode_t *dn, uint64_t *start, uint64_t minimum, uint64_t *l1blks) if (total_l1blks <= maxblks) { *l1blks = total_l1blks; *start = minimum; + /* Don't count when we don't have L1 blocks */ + if (dn->dn_nlevels <= 1) + *l1blks = 0; return (0); } ASSERT(ISP2(iblkrange));