diff options
author | Dan Williams <dan.j.williams@intel.com> | 2010-05-12 08:25:37 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-12 08:25:37 +1000 |
commit | e2218350465e7e0931676b4849b594c978437bce (patch) | |
tree | 395398081c277c533d28edd70d08a9394e7d8597 /drivers/md/md.c | |
parent | 627a2d3c29427637f4c5d31ccc7fcbd8d312cd71 (diff) | |
download | op-kernel-dev-e2218350465e7e0931676b4849b594c978437bce.zip op-kernel-dev-e2218350465e7e0931676b4849b594c978437bce.tar.gz |
md: set mddev readonly flag on blkdev BLKROSET ioctl
When the user sets the block device to readwrite then the mddev should
follow suit. Otherwise, the BUG_ON in md_write_start() will be set to
trigger.
The reverse direction, setting mddev->ro to match a set readonly
request, can be ignored because the blkdev level readonly flag precludes
the need to have mddev->ro set correctly. Nevermind the fact that
setting mddev->ro to 1 may fail if the array is in use.
Cc: <stable@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index a20a71e..08f6651 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5489,6 +5489,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, int err = 0; void __user *argp = (void __user *)arg; mddev_t *mddev = NULL; + int ro; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -5624,6 +5625,34 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, err = do_md_stop(mddev, 1, 1); goto done_unlock; + case BLKROSET: + if (get_user(ro, (int __user *)(arg))) { + err = -EFAULT; + goto done_unlock; + } + err = -EINVAL; + + /* if the bdev is going readonly the value of mddev->ro + * does not matter, no writes are coming + */ + if (ro) + goto done_unlock; + + /* are we are already prepared for writes? */ + if (mddev->ro != 1) + goto done_unlock; + + /* transitioning to readauto need only happen for + * arrays that call md_write_start + */ + if (mddev->pers) { + err = restart_array(mddev); + if (err == 0) { + mddev->ro = 2; + set_disk_ro(mddev->gendisk, 0); + } + } + goto done_unlock; } /* |