Skip to content

Commit 065e519

Browse files
NeilBrownshligit
authored andcommitted
md: MD_CLOSING needs to be cleared after called md_set_readonly or do_md_stop
if called md_set_readonly and set MD_CLOSING bit, the mddev cannot be opened any more due to the MD_CLOING bit wasn't cleared. Thus it needs to be cleared in md_ioctl after any call to md_set_readonly() or do_md_stop(). Signed-off-by: NeilBrown <neilb@suse.com> Fixes: af8d8e6 ("md: changes for MD_STILL_CLOSED flag") Cc: stable@vger.kernel.org (v4.9+) Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 6f287ca commit 065e519

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/md/md.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6925,6 +6925,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
69256925
void __user *argp = (void __user *)arg;
69266926
struct mddev *mddev = NULL;
69276927
int ro;
6928+
bool did_set_md_closing = false;
69286929

69296930
if (!md_ioctl_valid(cmd))
69306931
return -ENOTTY;
@@ -7014,7 +7015,9 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
70147015
err = -EBUSY;
70157016
goto out;
70167017
}
7018+
WARN_ON_ONCE(test_bit(MD_CLOSING, &mddev->flags));
70177019
set_bit(MD_CLOSING, &mddev->flags);
7020+
did_set_md_closing = true;
70187021
mutex_unlock(&mddev->open_mutex);
70197022
sync_blockdev(bdev);
70207023
}
@@ -7207,6 +7210,8 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
72077210
mddev->hold_active = 0;
72087211
mddev_unlock(mddev);
72097212
out:
7213+
if(did_set_md_closing)
7214+
clear_bit(MD_CLOSING, &mddev->flags);
72107215
return err;
72117216
}
72127217
#ifdef CONFIG_COMPAT

0 commit comments

Comments
 (0)