From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: quwenruo@cn.fujitsu.com
Subject: [PATCH 1/1] btrfs: Do per-chunk check for mount time check
Date: Fri, 25 Sep 2015 16:23:05 +0800 [thread overview]
Message-ID: <1443169385-18173-1-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1442801443-5132-3-git-send-email-quwenruo@cn.fujtsu.com>
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
Now use the btrfs_check_degraded() to do mount time degraded check.
With this patch, now we can mount with the following case:
# mkfs.btrfs -f -m raid1 -d single /dev/sdb /dev/sdc
# wipefs -a /dev/sdc
# mount /dev/sdb /mnt/btrfs -o degraded
As the single data chunk is only in sdb, so it's OK to mount as
degraded, as missing one device is OK for RAID1.
But still fail with the following case as expected:
# mkfs.btrfs -f -m raid1 -d single /dev/sdb /dev/sdc
# wipefs -a /dev/sdb
# mount /dev/sdc /mnt/btrfs -o degraded
As the data chunk is only in sdb, so it's not OK to mount it as
degraded.
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>
Btrfs: use btrfs_error instead of btrfs_err during mount
fix up on top of the patch
[PATCH 1/1] Btrfs: consolidate btrfs_error() to btrfs_std_error()
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/disk-io.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index ccb1f28..ae7b180 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2863,6 +2863,16 @@ int open_ctree(struct super_block *sb,
goto fail_tree_roots;
}
+ ret = btrfs_check_degradable(fs_info, fs_info->sb->s_flags);
+ if (ret < 0) {
+ btrfs_err(fs_info, "degraded writable mount failed %d", ret);
+ goto fail_tree_roots;
+ } else if (ret > 0 && !btrfs_test_opt(chunk_root, DEGRADED)) {
+ btrfs_warn(fs_info,
+ "Some device missing, but still degraded mountable, please mount with -o degraded option");
+ ret = -EACCES;
+ goto fail_tree_roots;
+ }
/*
* keep the device that is marked to be the target device for the
* dev_replace procedure
@@ -2940,14 +2950,6 @@ retry_root_backup:
}
fs_info->num_tolerated_disk_barrier_failures =
btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
- if (fs_info->fs_devices->missing_devices >
- fs_info->num_tolerated_disk_barrier_failures &&
- !(sb->s_flags & MS_RDONLY)) {
- pr_warn("BTRFS: missing devices(%llu) exceeds the limit(%d), writeable mount is not allowed\n",
- fs_info->fs_devices->missing_devices,
- fs_info->num_tolerated_disk_barrier_failures);
- goto fail_sysfs;
- }
fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
"btrfs-cleaner");
--
2.4.1
parent reply other threads:[~2015-09-25 8:24 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1442801443-5132-3-git-send-email-quwenruo@cn.fujtsu.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443169385-18173-1-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).