linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: dsterba@suse.cz, linux-btrfs <linux-btrfs@vger.kernel.org>,
	jshubin@redhat.com
Subject: Re: [PATCH V2] mkfs.btrfs: allow UUID specification at mkfs time
Date: Wed, 14 May 2014 11:09:28 -0500	[thread overview]
Message-ID: <53739538.2030507@redhat.com> (raw)
In-Reply-To: <20140514160133.GN6917@twin.jikos.cz>

On 5/14/14, 11:01 AM, David Sterba wrote:
> Thanks for adding the uuid uniqueness check, that was my major
> objection for previous patch iterations,
> 
> http://www.spinics.net/lists/linux-btrfs/msg30572.html

Ah, thanks, I didn't know about that history, I'm sorry.

I'm not sure if my duplicate-check is over the top, you had suggested

	blkid_probe_lookup_value()

before, maybe that's simpler.  I'm not a blkid expert... but it seems to work.

> we can now use it for convert as well (to generate or copy the uuid).

woo ;)

-Eric

> On Wed, May 14, 2014 at 10:35:05AM -0500, Eric Sandeen wrote:
>> @@ -125,7 +154,19 @@ int make_btrfs(int fd, const char *device, const char *label,
>>  	memset(&super, 0, sizeof(super));
>>  
>>  	num_bytes = (num_bytes / sectorsize) * sectorsize;
>> -	uuid_generate(super.fsid);
>> +	if (fs_uuid) {
>> +		if (uuid_parse(fs_uuid, super.fsid) != 0) {
>> +			fprintf(stderr, "could not parse UUID: %s\n", fs_uuid);
>> +			ret = -EINVAL;
>> +			goto out;
> 
> I think the uuid validity check comes too late, IMHO it should be done
> after the while/getopt block outside of make_btrfs. At this point eg.
> the discard or device zeroing is already done.
> 
> I would not mind to keep the check here as well as a last sanity check,
> though the number of mkfs_btrfs callers is 1 and the function is not
> exported to the library.
> 
>> +		}
>> +		if (!test_uuid_unique(fs_uuid)) {
>> +			fprintf(stderr, "non-unique UUID: %s\n", fs_uuid);
>> +			ret = -EBUSY;
>> +			goto out;
>> +		}
>> +	} else
>> +		uuid_generate(super.fsid);
>>  	uuid_generate(super.dev_item.uuid);
>>  	uuid_generate(chunk_tree_uuid);


  reply	other threads:[~2014-05-14 16:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14  1:18 [PATCH] mkfs.btrfs: allow UUID specification at mkfs time Eric Sandeen
2014-05-14  7:31 ` Wang Shilong
2014-05-14 12:25   ` Brendan Hide
2014-05-14 13:34     ` Duncan
2014-05-14 14:42     ` James Shubin
2014-05-14 13:28   ` Eric Sandeen
2014-05-14 13:34   ` David Pottage
2014-05-14 14:39 ` Goffredo Baroncelli
2014-05-14 14:41   ` Eric Sandeen
2014-05-14 15:14     ` Goffredo Baroncelli
2014-05-14 15:27     ` David Sterba
2014-05-14 14:47   ` James Shubin
2014-05-14 15:35 ` [PATCH V2] " Eric Sandeen
2014-05-14 16:01   ` David Sterba
2014-05-14 16:09     ` Eric Sandeen [this message]
2014-05-14 16:52     ` Goffredo Baroncelli
2014-05-14 17:39   ` PATCH V3] " Eric Sandeen
2014-05-14 22:04     ` Goffredo Baroncelli
2014-05-14 22:07       ` Eric Sandeen
2014-05-15 17:39         ` David Sterba
2014-05-15 17:53           ` Eric Sandeen
2014-05-16 17:24             ` David Sterba

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=53739538.2030507@redhat.com \
    --to=sandeen@redhat.com \
    --cc=dsterba@suse.cz \
    --cc=jshubin@redhat.com \
    --cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).