diff mbox series

[05/11] btrfs-progs: tune: check for missing device

Message ID 3b6a812b25429342811a22687245c9732a715a8f.1688724045.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: fix bugs and CHANGING_FSID_V2 flag | expand

Commit Message

Anand Jain July 7, 2023, 3:52 p.m. UTC
If btrfstune is executed on a filesystem that contains a missing device,
the command will now fail.

It is ok fail when any of the options supported by btrfstune are used.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tune/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

David Sterba July 13, 2023, 6:49 p.m. UTC | #1
On Fri, Jul 07, 2023 at 11:52:35PM +0800, Anand Jain wrote:
> If btrfstune is executed on a filesystem that contains a missing device,
> the command will now fail.
> 
> It is ok fail when any of the options supported by btrfstune are used.

Why? btrfstune has options that only change the superblock, like
feature enable/disable -e, -r, -x and -S. A missing device could be
problem for others but it should be checked only when it's relevant.
Anand Jain July 17, 2023, 7:02 p.m. UTC | #2
On 14/07/2023 02:49, David Sterba wrote:
> On Fri, Jul 07, 2023 at 11:52:35PM +0800, Anand Jain wrote:
>> If btrfstune is executed on a filesystem that contains a missing device,
>> the command will now fail.
>>
>> It is ok fail when any of the options supported by btrfstune are used.
> 
> Why? btrfstune has options that only change the superblock, like
> feature enable/disable -e, -r, -x and -S. A missing device could be
> problem for others but it should be checked only when it's relevant.


If the missing device generation number is greater than the one
provided here, the btrfstune may not be effective in the kernel
if devices are assembled. So just block those scenario.

Or we can be keep it open and block it based on the use case feedback.

Thanks.
diff mbox series

Patch

diff --git a/tune/main.c b/tune/main.c
index 570e3908ef8a..dc72944a2b67 100644
--- a/tune/main.c
+++ b/tune/main.c
@@ -330,6 +330,13 @@  int BOX_MAIN(btrfstune)(int argc, char *argv[])
 		goto free_out;
 	}
 
+	if (root->fs_info->fs_devices->missing) {
+		error("missing %d device(s), failing the command",
+		       root->fs_info->fs_devices->missing);
+		ret = 1;
+		goto free_out;
+	}
+
  	if (to_bg_tree) {
 		if (to_extent_tree) {
 			error("option --convert-to-block-group-tree conflicts with --convert-from-block-group-tree");