Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Lukas Herbolt <lukas@herbolt.com>
Cc: linux-xfs@vger.kernel.org, cem@kernel.org
Subject: Re: [PATCH] xfs: Use xarray to track SB UUIDs instead of plain array.
Date: Sun, 1 Feb 2026 23:37:24 -0800	[thread overview]
Message-ID: <aYBUNFoHNo58kgjO@infradead.org> (raw)
In-Reply-To: <20260130154206.1368034-4-lukas@herbolt.com>

> +STATIC int

We're phasing out the magic STATIC, so pleae just use plain static
here.

> +xfs_uuid_insert(uuid_t *uuid)

The somewhat unique XFS coding style uses separate lines for each
argument:

static int
xfs_uuid_insert(
	uuid_t			*uuid)

> +{
> +	uint32_t index = 0;

.. and aligns the variables the same way:

{
	uint32_t		index = 0;

Although this one will go away with Darrick's suggestion anyway.

> +
> +	return xa_alloc(&xfs_uuid_table, &index, uuid,
> +			xa_limit_32b, GFP_KERNEL);
> +}
> +
> +STATIC uuid_t
> +*xfs_uuid_search(uuid_t *new_uuid)

The * for pointers goes with the type:

static uuid_t *
xfs_uuid_search(
	uuid_t			*new_uuid)

> +	uuid_t *uuid = NULL;

no need to initialize the iterator to NULL before xa_for_each.

> +STATIC void
> +xfs_uuid_delete(uuid_t *uuid)
> +{
> +	unsigned long index = 0;
> +
> +	xa_for_each(&xfs_uuid_table, index, uuid) {
> +		xa_erase(&xfs_uuid_table, index);
> +	}

I don't think this works as expected, as it just erases all uuids in the
table.

> +}
>  
>  void
> -xfs_uuid_table_free(void)
> +xfs_uuid_table_destroy(void)

I'd drop this rename.  Free works just fine here as a name.

> +	if (!xfs_uuid_search(uuid))
> +		return xfs_uuid_insert(uuid);
>  
>  	xfs_warn(mp, "Filesystem has duplicate UUID %pU - can't mount", uuid);
>  	return -EINVAL;

Just return an error here if xfs_uuid_search finds something, and then
open code the insert in the straight line path.

> @@ -110,22 +119,12 @@ xfs_uuid_unmount(
>  	struct xfs_mount	*mp)
>  {
>  	uuid_t			*uuid = &mp->m_sb.sb_uuid;
>  
>  	if (xfs_has_nouuid(mp))
>  		return;
> +	xfs_uuid_delete(uuid);
> +	return;

No need for the last return.  Also I think you can just open code
xfs_uuid_delete here.


  parent reply	other threads:[~2026-02-02  7:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 15:42 [PATCH 0/1] xfs: Use xarray to track SB UUIDs instead of plain array Lukas Herbolt
2026-01-30 15:42 ` [PATCH] " Lukas Herbolt
2026-01-30 16:55   ` Darrick J. Wong
2026-02-02  7:31     ` Christoph Hellwig
2026-02-02  9:37       ` Lukas Herbolt
2026-02-02 18:50         ` Darrick J. Wong
2026-02-03  5:17           ` Christoph Hellwig
2026-02-03  7:23             ` Darrick J. Wong
2026-02-02  7:37   ` Christoph Hellwig [this message]
2026-02-02  9:38     ` Lukas Herbolt

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=aYBUNFoHNo58kgjO@infradead.org \
    --to=hch@infradead.org \
    --cc=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lukas@herbolt.com \
    /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