Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Chris Wiseman" <chriswiseman@google.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] ext4: free HTree fname rb-tree at EOF in ext4_dx_readdir()
Date: Mon, 16 Nov 2026 02:30:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-216081@kernel.org> (raw)
In-Reply-To: <18e865672dda2d41.3137322e32332e3235332e313736.36f4d7.0000sendgmr@google.com>

> When ext4_dx_readdir() finishes scanning the last HTree leaf block of
> an indexed directory, ext4_htree_fill_tree() sets info->next_hash to
> ~0.  On the final iteration, once rb_next(info->curr_node) returns NULL,
> ext4_dx_readdir() sets ctx->pos to ext4_get_htree_eof(file) and breaks
> out of the loop without calling free_rb_tree_fname(&info->root).
> 
> While ext4_dx_readdir() frees info->root when advancing across leaf
> blocks or resetting on seek, reaching EOF leaves the final leaf block's
> red-black tree of struct fname nodes pinned in file->private_data until
> the directory fd is closed in ext4_release_dir().  Processes and daemons
> that keep directory descriptors open after reading to EOF retain those
> slab allocations for the lifetime of the open fd.
> 
> Free info->root before returning EOF when info->next_hash == ~0.  If the
> caller later seeks back, the existing !info->curr_node check at the top
> of the loop repopulates the tree on demand.
> 
> Benchmark results (/proc/allocinfo, 256 open HTree dirs at EOF):
> 
>   Metric                                  Before        After     Delta
>   ----------------------------------  -----------  ----------  --------
>   ext4_htree_store_dirent live slab   1,007,616 B         0 B   -100.0%
>   ext4_htree_store_dirent live objs        10,496           0   -100.0%
>   /proc/meminfo SUnreclaim delta        +1,246 kB     +133 kB    -89.3%
> 
> Signed-off-by: Chris Wiseman <chriswiseman@google.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/18e865672dda2d41.3137322e32332e3235332e313736.36f4d7.0000sendgmr@google.com?part=1


      reply	other threads:[~2026-11-16  2:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  2:25 [PATCH] ext4: free HTree fname rb-tree at EOF in ext4_dx_readdir() Chris Wiseman
2026-11-16  2:30 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-216081@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=chriswiseman@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox