lkml.org 
[lkml]   [2010]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 067/164] md: set mddev readonly flag on blkdev BLKROSET ioctl
    2.6.33-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Dan Williams <dan.j.williams@intel.com>

    commit e2218350465e7e0931676b4849b594c978437bce upstream.

    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.

    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    drivers/md/md.c | 29 +++++++++++++++++++++++++++++
    1 file changed, 29 insertions(+)

    --- a/drivers/md/md.c
    +++ b/drivers/md/md.c
    @@ -5516,6 +5516,7 @@ static int md_ioctl(struct block_device
    int err = 0;
    void __user *argp = (void __user *)arg;
    mddev_t *mddev = NULL;
    + int ro;

    if (!capable(CAP_SYS_ADMIN))
    return -EACCES;
    @@ -5651,6 +5652,34 @@ static int md_ioctl(struct block_device
    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;
    }

    /*



    \
     
     \ /
      Last update: 2010-07-02 00:13    [W:2.455 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site