linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs: Do per-chunk degrade mode check at mount time
@ 2015-09-16  3:43 Qu Wenruo
  2015-09-16  3:43 ` [PATCH 2/2] btrfs: Remove unneeded missing device number check Qu Wenruo
  2015-09-17  1:48 ` [PATCH 1/2] btrfs: Do per-chunk degrade mode check at mount time Qu Wenruo
  0 siblings, 2 replies; 12+ messages in thread
From: Qu Wenruo @ 2015-09-16  3:43 UTC (permalink / raw)
  To: linux-btrfs

Btrfs supports different raid profile for meta/data/sys, and as
different profile support different tolerated missing device, it's
better to check if it can be mounted degraded at a per-chunk base.

So this patch will add check for read_one_chunk() against its profile,
other than checking it against with the lowest duplication profile.

Reported-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reported-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 fs/btrfs/volumes.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 644e070..3272187 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6164,12 +6164,15 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
 			  struct btrfs_chunk *chunk)
 {
 	struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree;
+	struct super_block *sb = root->fs_info->sb;
 	struct map_lookup *map;
 	struct extent_map *em;
 	u64 logical;
 	u64 length;
 	u64 devid;
 	u8 uuid[BTRFS_UUID_SIZE];
+	int missing = 0;
+	int max_tolerated;
 	int num_stripes;
 	int ret;
 	int i;
@@ -6238,7 +6241,21 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
 			btrfs_warn(root->fs_info, "devid %llu uuid %pU is missing",
 						devid, uuid);
 		}
+		if (map->stripes[i].dev->missing)
+			missing++;
 		map->stripes[i].dev->in_fs_metadata = 1;
+
+	}
+
+	/* XXX: Why the function name is SO LOOOOOOOOOOOOOOOOONG?! */
+	max_tolerated =
+		btrfs_get_num_tolerated_disk_barrier_failures(map->type);
+	if (missing > max_tolerated && !(sb->s_flags & MS_RDONLY)) {
+		free_extent_map(em);
+		btrfs_error(root->fs_info, -EIO,
+			"missing device(%d) exceeds the limit(%d), writeable mount is not allowed\n",
+			missing, max_tolerated);
+		return -EIO;
 	}
 
 	write_lock(&map_tree->map_tree.lock);
-- 
2.5.2


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

end of thread, other threads:[~2015-09-21  2:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16  3:43 [PATCH 1/2] btrfs: Do per-chunk degrade mode check at mount time Qu Wenruo
2015-09-16  3:43 ` [PATCH 2/2] btrfs: Remove unneeded missing device number check Qu Wenruo
2015-09-17  9:43   ` Anand Jain
2015-09-17 10:01     ` Qu Wenruo
2015-09-18  1:47       ` Anand Jain
2015-09-18  2:06         ` Qu Wenruo
2015-09-18  6:45           ` Anand Jain
2015-09-20  0:31             ` Qu Wenruo
2015-09-20  5:37               ` Anand Jain
2015-09-21  2:09                 ` Qu Wenruo
2015-09-17  1:48 ` [PATCH 1/2] btrfs: Do per-chunk degrade mode check at mount time Qu Wenruo
2015-09-17  9:37   ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).