Thread (5 messages) 5 messages, 3 authors, 2022-01-06

Re: [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf

From: Anand Jain <hidden>
Date: 2021-12-16 11:54:16

On 16/12/2021 18:00, 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 <redacted>
Reviewed-by: Anand Jain <redacted>

--Anand
quoted hunk ↗ jump to hunk
---
  mkfs/common.c | 13 +------------
  1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/mkfs/common.c b/mkfs/common.c
index fec23e64b2b2..72e84bc01712 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -260,18 +260,7 @@ 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);
  	}
--
2.17.1
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help