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@xxxxxxxxxxxxx _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs