All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf
@ 2021-12-16 10:00 Nikolay Borisov
  2021-12-16 11:53 ` Anand Jain
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nikolay Borisov @ 2021-12-16 10:00 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>
---
 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


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

* Re: [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf
  2021-12-16 10:00 [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf Nikolay Borisov
@ 2021-12-16 11:53 ` Anand Jain
  2021-12-16 11:58 ` Nikolay Borisov
  2022-01-04 18:48 ` David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2021-12-16 11:53 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs

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 <nborisov@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

--Anand

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


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

* Re: [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf
  2021-12-16 10:00 [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf Nikolay Borisov
  2021-12-16 11:53 ` Anand Jain
@ 2021-12-16 11:58 ` Nikolay Borisov
  2022-01-04 18:48 ` David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: Nikolay Borisov @ 2021-12-16 11:58 UTC (permalink / raw)
  To: linux-btrfs



On 16.12.21 г. 12: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.

Actually the checks are executed but can never fail because they've
already succeeded before calling them for the 2nd time here :). David
you might want to amend this when committing.

> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  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
> 

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

* Re: [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf
  2021-12-16 10:00 [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf Nikolay Borisov
  2021-12-16 11:53 ` Anand Jain
  2021-12-16 11:58 ` Nikolay Borisov
@ 2022-01-04 18:48 ` David Sterba
  2022-01-06 14:46   ` David Sterba
  2 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2022-01-04 18:48 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Thu, Dec 16, 2021 at 12:00:12PM +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>

Added to devel, thanks.

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

* Re: [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf
  2022-01-04 18:48 ` David Sterba
@ 2022-01-06 14:46   ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2022-01-06 14:46 UTC (permalink / raw)
  To: dsterba, Nikolay Borisov, linux-btrfs; +Cc: anand.jain

On Tue, Jan 04, 2022 at 07:48:02PM +0100, David Sterba wrote:
> On Thu, Dec 16, 2021 at 12:00:12PM +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>
> 
> Added to devel, thanks.

And removed again, tests don't pass:

 $ make TEST=002-uuid-rewrite test-misc
 FAIL: current UUID mismatch
 test failed for case 002-uuid-rewrite
 make: *** [Makefile:457: test-misc] Error 1

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

end of thread, other threads:[~2022-01-06 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 10:00 [PATCH] btrfs-progs: remove redundant fs uuid validation from make_btrf Nikolay Borisov
2021-12-16 11:53 ` Anand Jain
2021-12-16 11:58 ` Nikolay Borisov
2022-01-04 18:48 ` David Sterba
2022-01-06 14:46   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.