linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs-progs: Remove redundant fs uuid validation from make_btrf
@ 2022-01-10  9:01 Nikolay Borisov
  2022-01-11 17:03 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2022-01-10  9:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

cfg->fs_uuid is either 0 or set to the value of the -U parameter
passed to mkfs.btrfs. However the value of the latter is already being
validated in the main mkfs function. Just remove the duplicated checks
in make_btrfs as they effectively can never be executed.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

v2:
 * Properly "copy" the cfg->fs_uuid into the superblock's fsid field. This fixes
 a failure in 002-uuid-rewrite.

 mkfs/common.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/mkfs/common.c b/mkfs/common.c
index fec23e64b2b2..9608d27f73e7 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -260,20 +260,11 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
 	memset(&super, 0, sizeof(super));

 	num_bytes = (cfg->num_bytes / cfg->sectorsize) * cfg->sectorsize;
-	if (*cfg->fs_uuid) {
-		if (uuid_parse(cfg->fs_uuid, super.fsid) != 0) {
-			error("cannot not parse UUID: %s", cfg->fs_uuid);
-			ret = -EINVAL;
-			goto out;
-		}
-		if (!test_uuid_unique(cfg->fs_uuid)) {
-			error("non-unique UUID: %s", cfg->fs_uuid);
-			ret = -EBUSY;
-			goto out;
-		}
-	} else {
+	if (!*cfg->fs_uuid) {
 		uuid_generate(super.fsid);
 		uuid_unparse(super.fsid, cfg->fs_uuid);
+	} else {
+		uuid_parse(cfg->fs_uuid, super.fsid);
 	}
 	uuid_generate(super.dev_item.uuid);
 	uuid_generate(chunk_tree_uuid);
--
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] btrfs-progs: Remove redundant fs uuid validation from make_btrf
  2022-01-10  9:01 [PATCH v2] btrfs-progs: Remove redundant fs uuid validation from make_btrf Nikolay Borisov
@ 2022-01-11 17:03 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-01-11 17:03 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Mon, Jan 10, 2022 at 11:01:55AM +0200, Nikolay Borisov wrote:
> cfg->fs_uuid is either 0 or set to the value of the -U parameter
> passed to mkfs.btrfs. However the value of the latter is already being
> validated in the main mkfs function. Just remove the duplicated checks
> in make_btrfs as they effectively can never be executed.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> 
> v2:
>  * Properly "copy" the cfg->fs_uuid into the superblock's fsid field. This fixes
>  a failure in 002-uuid-rewrite.

Added to devel, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-11 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10  9:01 [PATCH v2] btrfs-progs: Remove redundant fs uuid validation from make_btrf Nikolay Borisov
2022-01-11 17:03 ` David Sterba

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).