Re: [PATCH 02/10] Btrfs: don't write any data into a readonly device when scrub

2014-07-25 Thread Anand Jain



On 07/24/2014 11:37 AM, Miao Xie wrote:

We should not write data into a readonly device especially seed device when
doing scrub, skip those devices.


Reviewed-by: Anand Jain anand.j...@oracle.com

Signed-off-by: Miao Xie mi...@cn.fujitsu.com
---
  fs/btrfs/scrub.c | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b6d198f..23d3f6e 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,
struct scrub_ctx *sctx;
int ret;
struct btrfs_device *dev;
+   struct rcu_string *name;

if (btrfs_fs_closing(fs_info))
return -EINVAL;
@@ -2965,6 +2966,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 
devid, u64 start,
return -ENODEV;
}

+   if (!is_dev_replace  !readonly  !dev-writeable) {


 just reading the commit message would ask question what
 about readonly scrub anyway. Nice readonly scrub case
 is taken care as well.



+   mutex_unlock(fs_info-fs_devices-device_list_mutex);
+   rcu_read_lock();
+   name = rcu_dereference(dev-name);
+   btrfs_err(fs_info, scrub: device %s is not writable,
+ name-str);
+   rcu_read_unlock();
+   return -EROFS;
+   }
+
mutex_lock(fs_info-scrub_lock);
if (!dev-in_fs_metadata || dev-is_tgtdev_for_dev_replace) {
mutex_unlock(fs_info-scrub_lock);


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/10] Btrfs: don't write any data into a readonly device when scrub

2014-07-24 Thread David Sterba
On Thu, Jul 24, 2014 at 11:37:07AM +0800, Miao Xie wrote:
 We should not write data into a readonly device especially seed device when
 doing scrub, skip those devices.
 
 Signed-off-by: Miao Xie mi...@cn.fujitsu.com

Reviewed-by: David Sterba dste...@suse.cz

One minor comment below.

 @@ -2904,6 +2904,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 
 devid, u64 start,
   struct scrub_ctx *sctx;
   int ret;
   struct btrfs_device *dev;
 + struct rcu_string *name;
  
 + if (!is_dev_replace  !readonly  !dev-writeable) {

You can define 'name' within the block.

 + mutex_unlock(fs_info-fs_devices-device_list_mutex);
 + rcu_read_lock();
 + name = rcu_dereference(dev-name);
 + btrfs_err(fs_info, scrub: device %s is not writable,
 +   name-str);
 + rcu_read_unlock();
 + return -EROFS;
 + }
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html