public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Carlos Maiolino <cem@kernel.org>, xfs <linux-xfs@vger.kernel.org>,
	Andrey Albershteyn <aalbersh@redhat.com>
Subject: Re: [PATCH] xfs: speed up parent pointer operations
Date: Tue, 6 Jan 2026 16:09:07 -0800	[thread overview]
Message-ID: <20260107000907.GM191501@frogsfrogsfrogs> (raw)
In-Reply-To: <aVzE-5gMi1IHOLTW@infradead.org>

On Tue, Jan 06, 2026 at 12:16:59AM -0800, Christoph Hellwig wrote:
> On Fri, Dec 19, 2025 at 07:41:54AM -0800, Darrick J. Wong wrote:
> > Now parent pointers only increase the system time by 8% for creation and
> > 19% for deletion.  Wall time increases by 5% and 9%.
> 
> Nice!
> 
> > @@ -202,6 +203,16 @@ xfs_parent_addname(
> >  	xfs_inode_to_parent_rec(&ppargs->rec, dp);
> >  	xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child,
> >  			child->i_ino, parent_name);
> > +
> > +	if (xfs_inode_has_attr_fork(child) &&
> > +	    xfs_attr_is_shortform(child)) {
> > +		ppargs->args.op_flags |= XFS_DA_OP_ADDNAME;
> > +
> > +		error = xfs_attr_try_sf_addname(&ppargs->args);
> > +		if (error != -ENOSPC)
> > +			return error;
> > +	}
> > +
> >  	xfs_attr_defer_add(&ppargs->args, XFS_ATTR_DEFER_SET);
> 
> We should be able to do this for all attrs, not just parent pointers,
> right?

In principle, yes.  For a generic xattr version you'd probably want to
check for a large valuelen on the set side so that we don't waste time
scanning the sf structure when we're just going to end up in remote
value territory anyway.

>         It might be nice to just do this for set and remove in
> xfs_attr_defer_add and have it handle all attr operations.

Yeah.  I think it's more logical to put these new shortcut calls in
xfs_attr_set because we're be deciding /not/ to invoke the deferred
xattr mechanism.

> > +	if (xfs_attr_is_shortform(child)) {
> > +		ppargs->args.op_flags |= XFS_DA_OP_ADDNAME | XFS_DA_OP_REPLACE;
> > +
> > +		error = xfs_attr_sf_removename(&ppargs->args);
> > +		if (error)
> > +			return error;
> > +
> > +		xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->new_rec,
> > +				child, child->i_ino, new_name);
> > +		ppargs->args.op_flags |= XFS_DA_OP_ADDNAME;
> > +
> > +		error = xfs_attr_try_sf_addname(&ppargs->args);
> > +		if (error == -ENOSPC) {
> > +			xfs_attr_defer_add(&ppargs->args, XFS_ATTR_DEFER_SET);
> > +			return 0;
> > +		}
> 
> And for replace we should be able to optimize this even further
> by adding a new xfs_attr_sf_replacename that just checks if the new
> version would fit, and then memmove everything behind the changed
> attr and update it in place.  This should improve the operation a lot
> more.

That would depends on the frequency of non-parent pointer xattr
operations where the value doesn't change size modulo the rounding
factor.

I also wonder how much benefit anyone really gets from doing this to
regular xattrs, but once I'm more convinced that it's solid w.r.t.
parent pointers it's trivial to move it to xattrs too.

--D

  reply	other threads:[~2026-01-07  0:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19 15:41 [PATCH] xfs: speed up parent pointer operations Darrick J. Wong
2026-01-06  8:16 ` Christoph Hellwig
2026-01-07  0:09   ` Darrick J. Wong [this message]
2026-01-07  6:04     ` Christoph Hellwig
2026-01-07 18:22       ` Darrick J. Wong
2026-01-08  9:30         ` Christoph Hellwig
2026-01-08 17:03           ` Darrick J. Wong

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=20260107000907.GM191501@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@redhat.com \
    --cc=cem@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    /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