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: Wed, 7 Jan 2026 10:22:42 -0800 [thread overview]
Message-ID: <20260107182242.GB15583@frogsfrogsfrogs> (raw)
In-Reply-To: <aV33flV7zsiAeh7C@infradead.org>
On Tue, Jan 06, 2026 at 10:04:46PM -0800, Christoph Hellwig wrote:
> On Tue, Jan 06, 2026 at 04:09:07PM -0800, Darrick J. Wong wrote:
> > 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.
>
> Yeah.
>
> >
> > > 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.
>
> Or that, yes.
It turns out that for replace, it's more convenient to do it separately
in the xattr and parent pointer code because parent pointer replacements
require switching new_name -> name and new_value -> value after the
remove step; and the rename optimization is different for parent
pointers vs. every other xattr.
> > > 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.
>
> Well, the same applies to value changes - in the shortform format name
> and value are basically one blob, split by namelen. So anything
> replacing an existing attr with a new one, either due to a name change
> for parent pointers, or due to a value change otherwise can just move
> things beyond the attribute and update in place trivially. For
> replacing values with values of the same size things are even simpler.
Yes it is pretty simple:
int
xfs_attr_shortform_replace(
struct xfs_da_args *args)
{
struct xfs_attr_sf_entry *sfe;
ASSERT(args->dp->i_af.if_format == XFS_DINODE_FMT_LOCAL);
trace_xfs_attr_sf_replace(args);
sfe = xfs_attr_sf_findname(args);
if (!sfe)
return -ENOATTR;
if (sfe->valuelen != args->valuelen)
return -ENOSPC;
memcpy(&sfe->nameval[sfe->namelen], args->value, args->valuelen);
xfs_trans_log_inode(args->trans, args->dp,
XFS_ILOG_CORE | XFS_ILOG_ADATA);
return 0;
}
(parent pointers are a tad more difficult because we have to copy the
new name as well as the new value)
IIRC there's no rounding applied to shortform attr entries, so we have
to have an exact match on the value length.
> > 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.
>
> Not sure what counts as regular, but I'm pretty sure it would help
> quite a bit for inheriting xattrs or other security attributes.
Here, by "regular" I meant "not parent pointers" but yeah. It'll
probably help everyone to implement the shortcuts.
--D
next prev parent reply other threads:[~2026-01-07 18:22 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
2026-01-07 6:04 ` Christoph Hellwig
2026-01-07 18:22 ` Darrick J. Wong [this message]
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=20260107182242.GB15583@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