All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid()
@ 2018-04-19  9:38 Qu Wenruo
  2018-04-19  9:38 ` [PATCH 2/3] btrfs: Add csum type " Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Qu Wenruo @ 2018-04-19  9:38 UTC (permalink / raw)
  To: linux-btrfs

Although we have already checked incompat flags manually before really
mounting it, we could still enhance btrfs_check_super_valid() to check
incompat flags for later write time super block validation check.

This patch adds such incompat flags check for btrfs_check_super_valid(),
currently it won't be triggered, but provides the basis for later write
time check.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/disk-io.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 60caa68c3618..ec123158f051 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4104,6 +4104,19 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info)
 		ret = -EINVAL;
 	}
 
+	/*
+	 * Before calling btrfs_check_super_valid() we have already checked
+	 * incompat flags. So if we developr new incompat flags, it's must be
+	 * some corruption.
+	 */
+	if (btrfs_super_incompat_flags(sb) & ~BTRFS_FEATURE_INCOMPAT_SUPP) {
+		btrfs_err(fs_info,
+		"corrupted incompat flags detected 0x%llx, supported 0x%llx",
+			  btrfs_super_incompat_flags(sb),
+			  BTRFS_FEATURE_INCOMPAT_SUPP);
+		ret = -EINVAL;
+	}
+
 	/*
 	 * The generation is a global counter, we'll trust it more than the others
 	 * but it's still possible that it's the one that's wrong.
-- 
2.17.0


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

end of thread, other threads:[~2018-04-21  5:16 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19  9:38 [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid() Qu Wenruo
2018-04-19  9:38 ` [PATCH 2/3] btrfs: Add csum type " Qu Wenruo
2018-04-19 10:09   ` David Sterba
2018-04-19 10:24     ` Qu Wenruo
2018-04-19  9:38 ` [PATCH 3/3] btrfs: Do super block verification before writing it to disk Qu Wenruo
2018-04-19 10:16   ` David Sterba
2018-04-19 10:32     ` Qu Wenruo
2018-04-20 14:46   ` Anand Jain
2018-04-19 10:59 ` [PATCH 1/3] btrfs: Add incompat flags check for btrfs_check_super_valid() Nikolay Borisov
2018-04-19 11:10   ` Qu Wenruo
2018-04-19 15:31     ` David Sterba
2018-04-19 16:24       ` Nikolay Borisov
2018-04-20 13:04         ` David Sterba
2018-04-20 14:32 ` Anand Jain
2018-04-20 15:15   ` David Sterba
2018-04-21  2:38     ` Anand Jain
2018-04-21  2:43       ` Qu Wenruo
2018-04-21  5:18         ` Anand Jain

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.