aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-07-23 23:37:07 -0400
committerChris Mason <clm@fb.com>2014-08-19 11:52:17 -0400
commit5d68da3b8ee6eb2257aa4b8d885581782278ae93 (patch)
tree0656b0f5fa96f81c042467ee971a1cedeb1320f9 /fs
parentff61d17c6324d1b483fbbc5144f09668c24ff60c (diff)
Btrfs: don't write any data into a readonly device when scrub
We should not write data into a readonly device especially seed device when doing scrub, skip those devices. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/scrub.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b6d198f5181e..23d3f6e6a482 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2904,6 +2904,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
2904 struct scrub_ctx *sctx; 2904 struct scrub_ctx *sctx;
2905 int ret; 2905 int ret;
2906 struct btrfs_device *dev; 2906 struct btrfs_device *dev;
2907 struct rcu_string *name;
2907 2908
2908 if (btrfs_fs_closing(fs_info)) 2909 if (btrfs_fs_closing(fs_info))
2909 return -EINVAL; 2910 return -EINVAL;
@@ -2965,6 +2966,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
2965 return -ENODEV; 2966 return -ENODEV;
2966 } 2967 }
2967 2968
2969 if (!is_dev_replace && !readonly && !dev->writeable) {
2970 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
2971 rcu_read_lock();
2972 name = rcu_dereference(dev->name);
2973 btrfs_err(fs_info, "scrub: device %s is not writable",
2974 name->str);
2975 rcu_read_unlock();
2976 return -EROFS;
2977 }
2978
2968 mutex_lock(&fs_info->scrub_lock); 2979 mutex_lock(&fs_info->scrub_lock);
2969 if (!dev->in_fs_metadata || dev->is_tgtdev_for_dev_replace) { 2980 if (!dev->in_fs_metadata || dev->is_tgtdev_for_dev_replace) {
2970 mutex_unlock(&fs_info->scrub_lock); 2981 mutex_unlock(&fs_info->scrub_lock);