Skip to contentSkip to conversation

btrfs-progs: convert, warn if converting a fs which won't mount

PATCH Superseded Anand Jain 5 participants 11 messages Feb 28, 2020 – Mar 4, 2020 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

PATCH 1/1 btrfs-progs: convert, warn if converting a fs which won't mount

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

So in this case during convert provide a warning and a 10s delay to terminate the command.

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536,
converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it.
10 9 8 7 6 5 4^C

---
 convert/main.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
convert/main.c +15 -0
index a04ec7a36abf..f936ec37d30a 100644
@@ -1140,6 +1140,21 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
 		error("block size is too small: %u < 4096", blocksize);
 		goto fail;
 	}
+	if (blocksize != getpagesize()) {
+		int delay = 10;
+
+		warning("Blocksize %u is not equal to the pagesize %u,\n\
+         converted filesystem won't mount on this system.\n\
+         The operation will start in %d seconds. Use Ctrl-C to stop it.",
+			blocksize, getpagesize(), delay);
+
+		while (delay) {
+			printf("%2d", delay--);
+			fflush(stdout);
+			sleep(1);
+		}
+	}
+
 	if (btrfs_check_nodesize(nodesize, blocksize, features))
 		goto fail;
 	fd = open(devname, O_RDWR);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

So in this case during convert provide a warning and a 10s delay to terminate the command.

Quoted 6 lines

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536,
converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it.
10 9 8 7 6 5 4^C

What's the point of the delay? Just refuse to start the operation and quit.

Quoted 33 lines
---
 convert/main.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
convert/main.c +15 -0
index a04ec7a36abf..f936ec37d30a 100644
@@ -1140,6 +1140,21 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
 		error("block size is too small: %u < 4096", blocksize);
 		goto fail;
 	}
+	if (blocksize != getpagesize()) {
+		int delay = 10;
+
+		warning("Blocksize %u is not equal to the pagesize %u,\n\
+         converted filesystem won't mount on this system.\n\
+         The operation will start in %d seconds. Use Ctrl-C to stop it.",
+			blocksize, getpagesize(), delay);
+
+		while (delay) {
+			printf("%2d", delay--);
+			fflush(stdout);
+			sleep(1);
+		}
+	}
+
 	if (btrfs_check_nodesize(nodesize, blocksize, features))
 		goto fail;
 	fd = open(devname, O_RDWR);
#2 lore raw
Quoted 12 lines · On Fri, 28 Feb 2020 10:13:41 +0200 Nikolay Borisov <[email protected]> wrote:
Quoted 9 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

So in this case during convert provide a warning and a 10s delay to terminate the command.

Quoted 8 lines
Quoted 6 lines

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536,
converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it.
10 9 8 7 6 5 4^C

What's the point of the delay? Just refuse to start the operation and quit.

IMO there should be a way to proceed with convert, if the user knows what they are doing; maybe refuse the operation, but provide an "-f" "--force" option to proceed anyway?

As for these 10 second delays, they always seemed a bit odd and unusual among Linux filesystem tools or Unix CLI software in general.

Signature · 2 lines
With respect,
Roman
#3 lore raw
In reply to Anand Jain
Quoted 8 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

Thanks,
Qu

Quoted 40 lines

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536,
converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it.
10 9 8 7 6 5 4^C

---
 convert/main.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
convert/main.c +15 -0
index a04ec7a36abf..f936ec37d30a 100644
@@ -1140,6 +1140,21 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
 		error("block size is too small: %u < 4096", blocksize);
 		goto fail;
 	}
+	if (blocksize != getpagesize()) {
+		int delay = 10;
+
+		warning("Blocksize %u is not equal to the pagesize %u,\n\
+         converted filesystem won't mount on this system.\n\
+         The operation will start in %d seconds. Use Ctrl-C to stop it.",
+			blocksize, getpagesize(), delay);
+
+		while (delay) {
+			printf("%2d", delay--);
+			fflush(stdout);
+			sleep(1);
+		}
+	}
+
 	if (btrfs_check_nodesize(nodesize, blocksize, features))
 		goto fail;
 	fd = open(devname, O_RDWR);
author
#4 lore raw
Quoted 9 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

Quoted 9 lines
Quoted 2 lines

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

I have equal weight-age on the choices if blocksize != pagesize viz..
delay and warn (this patch)
quit (Nikolay).
keep it as it is without warning (Qu).

Here we are dealing with already user data. Should it be different from mkfs?
Quit is fine, but convert tool should it be system neutral?

I am not sure.

David, any idea?

Thanks, Anand

Quoted 44 lines

Thanks,
Qu

Quoted 40 lines

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536,
converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it.
10 9 8 7 6 5 4^C

---
  convert/main.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
convert/main.c +15 -0
index a04ec7a36abf..f936ec37d30a 100644
@@ -1140,6 +1140,21 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
  		error("block size is too small: %u < 4096", blocksize);
  		goto fail;
  	}
+	if (blocksize != getpagesize()) {
+		int delay = 10;
+
+		warning("Blocksize %u is not equal to the pagesize %u,\n\
+         converted filesystem won't mount on this system.\n\
+         The operation will start in %d seconds. Use Ctrl-C to stop it.",
+			blocksize, getpagesize(), delay);
+
+		while (delay) {
+			printf("%2d", delay--);
+			fflush(stdout);
+			sleep(1);
+		}
+	}
+
  	if (btrfs_check_nodesize(nodesize, blocksize, features))
  		goto fail;
  	fd = open(devname, O_RDWR);
#5 lore raw
Quoted 23 lines · Anand Jain
Quoted 10 lines · Qu Wenruo
Quoted 7 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

  BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

Quoted 9 lines
Quoted 2 lines

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

Quoted 8 lines

I have equal weight-age on the choices if blocksize != pagesize viz.. delay and warn (this patch)
  quit (Nikolay).
  keep it as it is without warning (Qu).

 Here we are dealing with already user data. Should it be different from mkfs?
 Quit is fine, but convert tool should it be system neutral?

If we can't mount, btrfs-convert can easily do a revert without anything touched for the original fs.

And, convert tool is not that system neutral.
It needs the source fs has a sector size that matches btrfs.

E.g. ext2 with 512/1K/2K sector size can't be supported by btrfs-convert at all.

Thanks,
Qu

Quoted 53 lines

 I am not sure.

 David, any idea?

Thanks, Anand

Quoted 46 lines

Thanks,
Qu

Quoted 42 lines

For example:

WARNING: Blocksize 4096 is not equal to the pagesize 65536, converted filesystem won't mount on this system. The operation will start in 10 seconds. Use Ctrl-c to stop it. 10 9 8 7 6 5 4^C

---
  convert/main.c | 15 +++++++++++++++

  1 file changed, 15 insertions(+)
convert/main.c +15 -0
index a04ec7a36abf..f936ec37d30a 100644
@@ -1140,6 +1140,21 @@ static int do_convert(const char *devname, u32
 convert_flags, u32 nodesize,
           error("block size is too small: %u < 4096", blocksize);
           goto fail;
       }
+    if (blocksize != getpagesize()) {
+        int delay = 10;
+
+        warning("Blocksize %u is not equal to the pagesize %u,\n\
+         converted filesystem won't mount on this system.\n\
+         The operation will start in %d seconds. Use Ctrl-C to stop
 it.",
+            blocksize, getpagesize(), delay);
+
+        while (delay) {
+            printf("%2d", delay--);
+            fflush(stdout);
+            sleep(1);
+        }
+    }
+
       if (btrfs_check_nodesize(nodesize, blocksize, features))

          goto fail;
      fd = open(devname, O_RDWR);

#6 lore raw
In reply to Anand Jain
Quoted 18 lines · Anand Jain
Quoted 7 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

Quoted 9 lines
Quoted 2 lines

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

Quoted 8 lines

I have equal weight-age on the choices if blocksize != pagesize viz..
delay and warn (this patch)
quit (Nikolay).
keep it as it is without warning (Qu).

Here we are dealing with already user data. Should it be different from mkfs?
Quit is fine, but convert tool should it be system neutral?

The delays should be used in exceptional cases, now we have it for check --repair and for unfiltered balance. Both on user request because expecting users to know everything in advance what the commands do has shown to be too optimistic.

Refusing to allow the conversion does not make much sense for usability, mising the unmounted and mounted constraints.

A warning might be in place but there's nothing wrong to let the user do the conversion.

I've tried mkfs.ext4 with 64k block size and it warns and in the interactive session wants to confirm that by the user:

  $ mkfs.ext4 -b 64k img
  Warning: blocksize 65536 not usable on most systems.
  mke2fs 1.45.5 (07-Jan-2020)
  img contains a ext4 file system
	  created on Tue Mar  3 18:41:46 2020
  Proceed anyway? (y,N) y
  mkfs.ext4: 65536-byte blocks too big for system (max 4096)
  Proceed anyway? (y,N) y
  Warning: 65536-byte blocks too big for system (max 4096), forced to continue
  Creating filesystem with 32768 64k blocks and 32768 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

author
#7 lore raw
Quoted 53 lines · David Sterba
Quoted 18 lines · Anand Jain
Quoted 7 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

Quoted 9 lines
Quoted 2 lines

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

Quoted 8 lines

I have equal weight-age on the choices if blocksize != pagesize viz..
delay and warn (this patch)
quit (Nikolay).
keep it as it is without warning (Qu).

Here we are dealing with already user data. Should it be different from mkfs?
Quit is fine, but convert tool should it be system neutral?

The delays should be used in exceptional cases, now we have it for check --repair and for unfiltered balance. Both on user request because expecting users to know everything in advance what the commands do has shown to be too optimistic.

Refusing to allow the conversion does not make much sense for usability, mising the unmounted and mounted constraints.

A warning might be in place but there's nothing wrong to let the user do the conversion.

I've tried mkfs.ext4 with 64k block size and it warns and in the interactive session wants to confirm that by the user:

   $ mkfs.ext4 -b 64k img
   Warning: blocksize 65536 not usable on most systems.
   mke2fs 1.45.5 (07-Jan-2020)
   img contains a ext4 file system
	  created on Tue Mar  3 18:41:46 2020
   Proceed anyway? (y,N) y
   mkfs.ext4: 65536-byte blocks too big for system (max 4096)
   Proceed anyway? (y,N) y
   Warning: 65536-byte blocks too big for system (max 4096), forced to continue
   Creating filesystem with 32768 64k blocks and 32768 inodes
Quoted 5 lines

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Just warn is reasonable. But I don't think you meant to introduce interactive part similar to mkfs.ext4 in btrfs-convert? we don't have it anywhere in btrfs-progs. As the btrfs-convert is not an exceptional case (though it deals with the user data) removing the delay makes sense, mover over the conversion and the rollback does not take much time in general.

Thanks, Anand

#8 lore raw
Quoted 64 lines · Anand Jain
Quoted 55 lines · David Sterba
Quoted 19 lines · Anand Jain
Quoted 8 lines · Qu Wenruo
Quoted 7 lines · Anand Jain

On aarch64 with pagesize 64k, btrfs-convert of ext4 is successful, but it won't mount because we don't yet support subpage blocksize/ sectorsize.

   BTRFS error (device vda): sectorsize 4096 not supported yet, only support 65536

Quoted 9 lines
Quoted 2 lines

So in this case during convert provide a warning and a 10s delay to terminate the command.

This is no different than calling mkfs.btrfs -s 64k on x86 system. And I see no warning from mkfs.btrfs.

Thus I don't see the point of only introducing such warning to btrfs-convert.

Quoted 8 lines

I have equal weight-age on the choices if blocksize != pagesize viz.. delay and warn (this patch)
    quit (Nikolay).
    keep it as it is without warning (Qu).

   Here we are dealing with already user data. Should it be different from mkfs?
   Quit is fine, but convert tool should it be system neutral?

The delays should be used in exceptional cases, now we have it for check --repair and for unfiltered balance. Both on user request because expecting users to know everything in advance what the commands do has shown to be too optimistic.

Refusing to allow the conversion does not make much sense for usability, mising the unmounted and mounted constraints.

A warning might be in place but there's nothing wrong to let the user do the conversion.

I've tried mkfs.ext4 with 64k block size and it warns and in the interactive session wants to confirm that by the user:

   $ mkfs.ext4 -b 64k img
   Warning: blocksize 65536 not usable on most systems.
   mke2fs 1.45.5 (07-Jan-2020)
   img contains a ext4 file system
      created on Tue Mar  3 18:41:46 2020
   Proceed anyway? (y,N) y
   mkfs.ext4: 65536-byte blocks too big for system (max 4096)
   Proceed anyway? (y,N) y
   Warning: 65536-byte blocks too big for system (max 4096), forced to
continue
   Creating filesystem with 32768 64k blocks and 32768 inodes
Quoted 5 lines

   Allocating group tables: done
   Writing inode tables: done
   Creating journal (4096 blocks): done
   Writing superblocks and filesystem accounting information: done

Quoted 8 lines

Just warn is reasonable. But I don't think you meant to introduce interactive part similar to mkfs.ext4 in btrfs-convert? we don't have it anywhere in btrfs-progs. As the btrfs-convert is not an exceptional case (though it deals with the user data) removing the delay makes sense, mover over the conversion and the rollback does not take much time in general.

Thanks, Anand

+1 for warning only, especially when btrfs-convert is revertable, unlike mkfs.

Thanks,
Qu

#9 lore raw
In reply to Anand Jain
Quoted 16 lines · Anand Jain
Quoted 16 lines

the conversion.

I've tried mkfs.ext4 with 64k block size and it warns and in the interactive session wants to confirm that by the user:

   $ mkfs.ext4 -b 64k img
   Warning: blocksize 65536 not usable on most systems.
   mke2fs 1.45.5 (07-Jan-2020)
   img contains a ext4 file system
	  created on Tue Mar  3 18:41:46 2020
   Proceed anyway? (y,N) y
   mkfs.ext4: 65536-byte blocks too big for system (max 4096)
   Proceed anyway? (y,N) y
   Warning: 65536-byte blocks too big for system (max 4096), forced to continue
   Creating filesystem with 32768 64k blocks and 32768 inodes
Quoted 8 lines
Quoted 5 lines

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Just warn is reasonable. But I don't think you meant to introduce interactive part similar to mkfs.ext4 in btrfs-convert?

No I haven't meant that. So let's go with the warning.

author
#10 lore raw
Quoted 23 lines · David Sterba
Quoted 22 lines · Anand Jain
Quoted 21 lines

the conversion.

I've tried mkfs.ext4 with 64k block size and it warns and in the interactive session wants to confirm that by the user:

    $ mkfs.ext4 -b 64k img
    Warning: blocksize 65536 not usable on most systems.
    mke2fs 1.45.5 (07-Jan-2020)
    img contains a ext4 file system
	  created on Tue Mar  3 18:41:46 2020
    Proceed anyway? (y,N) y
    mkfs.ext4: 65536-byte blocks too big for system (max 4096)
    Proceed anyway? (y,N) y
    Warning: 65536-byte blocks too big for system (max 4096), forced to continue
    Creating filesystem with 32768 64k blocks and 32768 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Quoted 5 lines
Quoted 2 lines

Just warn is reasonable. But I don't think you meant to introduce interactive part similar to mkfs.ext4 in btrfs-convert?

No I haven't meant that. So let's go with the warning.

Ok. Patch v2 is in ML.

Thanks, Anand