File 0007-btrfs-progs-convert-refuse-to-convert-filesystem-wit.patch of Package btrfsprogs.23274

From f89f3398fc7f2d56ec12da3813d9dbcd568a0cbe Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.com>
Date: Wed, 10 Mar 2021 16:16:25 +0100
Subject: [PATCH 7/7] btrfs-progs: convert: refuse to convert filesystem with
 'needs_recovery' set

As Chris reports: This ext4 file system has 'needs_recovery' feature set, and
if mounted rw, log replay happens. But btrfs-convert doesn't check for it and
converts anyway. It probably shouldn't.

  # debugfs -R stats /dev/loop0
  debugfs 1.45.6 (20-Mar-2020)
  Filesystem volume name:   <none>
  Last mounted on:          /mnt/0
  Filesystem UUID:          d3e3862e-f892-4ab7-ae91-84eb4be4a3ef
  Filesystem magic number:  0xEF53
  Filesystem revision #:    1 (dynamic)
  Filesystem features:      has_journal ext_attr resize_inode dir_index
			    filetype needs_recovery extent 64bit flex_bg
			    sparse_super large_file huge_file dir_nlink
			    extra_isize metadata_csum
  Filesystem flags:         signed_directory_hash
  Default mount options:    user_xattr acl
  Filesystem state:         clean
  Errors behavior:          Continue
  ...

Then 'btrfs-convert' proceeds, while 'e2fsck -fvn /dev/loop1' finds some
problems and wants to fix them.

Add a check for the 'needs_recovery' incompat bit set and don't convert
the filesystem.

Issue: #348
Signed-off-by: David Sterba <dsterba@suse.com>
---
 convert/source-ext2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index 291347a..813abc9 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -43,6 +43,12 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name)
 			fprintf(stderr, "ext2fs_open: %s\n", error_message(ret));
 		return -1;
 	}
+
+	if (ext2_fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
+		error("source filesystem requires recovery, run e2fsck first");
+		goto fail;
+	}
+
 	/*
 	 * We need to know exactly the used space, some RO compat flags like
 	 * BIGALLOC will affect how used space is present.
-- 
2.26.2

openSUSE Build Service is sponsored by