public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Mika Eloranta <mel@ohmu.fi>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] mkfs.xfs: option for using a pre-defined filesystem UUID
Date: Wed, 23 Sep 2015 08:34:02 +1000	[thread overview]
Message-ID: <20150922223402.GN19114@dastard> (raw)
In-Reply-To: <1442924691-42001-1-git-send-email-mel@ohmu.fi>

On Tue, Sep 22, 2015 at 03:24:51PM +0300, Mika Eloranta wrote:
> Usage: mkfs.xfs -m uuid=<uuid> <device>
> 
> The filesystem UUID can now be optionally specified during filesystem
> creation. The default behavior is still to generate a random UUID.
> 
> Allows using pre-generated UUIDs for identifying a filesystem based
> on the metadata stored inside the filesystem. Filesystem labels can
> be used for the same purpose, but are limited by their length
> (12 chars in the case of xfs) whereas the UUID field can store an
> entire 128bit UUID, which is plenty for e.g. random ID collision
> avoidance.
> 
> Random UUID generated during the creation of the filesystem is not
> always feasible when an external DB or other system is used to track
> the created filesystem, e.g. in automated VM provisioning systems,
> as this would require a feedback mechanism which is not always
> available. In these cases the best approach often is to generate
> a random UUID for the filesystem before the filesystem even exists,
> store it in the tracking DB and later create the filesystem directly
> with the correct UUID (instead of "mkfs.xfs + xfs_admin -U <new_uuid>").

Much nicer! Just needs a signed-off-by tag now...

> @@ -948,6 +950,7 @@ main(
>  	bool			finobtflag;
>  	int			spinodes;
>  
> +	platform_uuid_clear(&uuid);
>  	progname = basename(argv[0]);
>  	setlocale(LC_ALL, "");
>  	bindtextdomain(PACKAGE, LOCALEDIR);

You can just call platform_uuid_generate(&uuid) here.

> @@ -1488,6 +1491,12 @@ main(
>  					finobt = c;
>  					finobtflag = true;
>  					break;
> +				case M_UUID:
> +					if (!value || *value == '\0')
> +						reqval('m', mopts, M_UUID);
> +					if (platform_uuid_parse(value, &uuid))
> +						illegal(optarg, "m uuid");
> +					break;

This will overwrite the pre-generated uuid if it is specified.

>  				default:
>  					unknown('m', value);
>  				}
> @@ -2550,7 +2559,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_dblocks = dblocks;
>  	sbp->sb_rblocks = rtblocks;
>  	sbp->sb_rextents = rtextents;
> -	platform_uuid_generate(&uuid);
> +	if (platform_uuid_is_null(&uuid)) {
> +	    platform_uuid_generate(&uuid);
> +	}

And this code can go away completely as we are guaranteed to have a
valid uuid by this point.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-09-22 22:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 12:24 [PATCH] mkfs.xfs: option for using a pre-defined filesystem UUID Mika Eloranta
2015-09-22 22:34 ` Dave Chinner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-09-23  6:16 Mika Eloranta

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=20150922223402.GN19114@dastard \
    --to=david@fromorbit.com \
    --cc=mel@ohmu.fi \
    --cc=xfs@oss.sgi.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