Skip to contentSkip to conversation

Patch "md: MD_CLOSING needs to be cleared after called md_set_readonly or do_md_stop" has been added to the 4.11-stable tree

PATCH [email protected] 1 participant 1 message May 22, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

md: MD_CLOSING needs to be cleared after called md_set_readonly or do_md_stop

to the 4.11-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
md-md_closing-needs-to-be-cleared-after-called-md_set_readonly-or-do_md_stop.patch
and it can be found in the queue-4.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 065e519e71b2c1f41936cce75b46b5ab34adb588 Mon Sep 17 00:00:00 2001

From: NeilBrown <[email protected]>
Date: Thu, 6 Apr 2017 11:16:33 +0800
Subject: md: MD_CLOSING needs to be cleared after called md_set_readonly or do_md_stop

From: NeilBrown <[email protected]>

commit 065e519e71b2c1f41936cce75b46b5ab34adb588 upstream.

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().

Fixes af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag")
---
 drivers/md/md.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/md/md.c +5 -0
@@ -6776,6 +6776,7 @@ static int md_ioctl(struct block_device
 	void __user *argp = (void __user *)arg;
 	struct mddev *mddev = NULL;
 	int ro;
+	bool did_set_md_closing = false;
 
 	if (!md_ioctl_valid(cmd))
 		return -ENOTTY;
@@ -6865,7 +6866,9 @@ static int md_ioctl(struct block_device
 			err = -EBUSY;
 			goto out;
 		}
+		WARN_ON_ONCE(test_bit(MD_CLOSING, &mddev->flags));
 		set_bit(MD_CLOSING, &mddev->flags);
+		did_set_md_closing = true;
 		mutex_unlock(&mddev->open_mutex);
 		sync_blockdev(bdev);
 	}
@@ -7058,6 +7061,8 @@ unlock:
 		mddev->hold_active = 0;
 	mddev_unlock(mddev);
 out:
+	if(did_set_md_closing)
+		clear_bit(MD_CLOSING, &mddev->flags);
 	return err;
 }
 #ifdef CONFIG_COMPAT

Patches currently in stable-queue which might be from [email protected] are

queue-4.11/md-md_closing-needs-to-be-cleared-after-called-md_set_readonly-or-do_md_stop.patch queue-4.11/md-update-slab_cache-before-releasing-new-stripes-when-stripes-resizing.patch