From: NeilBrown <neilb@suse.de>
To: linux-raid@vger.kernel.org
Subject: [md PATCH 12/26] md: level_store: group all important changes into one place.
Date: Wed, 04 Feb 2015 08:42:29 +1100 [thread overview]
Message-ID: <20150203214229.3448.51698.stgit@notabene.brown> (raw)
In-Reply-To: <20150203213948.3448.80258.stgit@notabene.brown>
Gather all the changes that can happen atomically and might
be relevant to other code into one place. This will
make it easier to refine the locking.
Note that this puts quite a few things between mddev_detach()
and ->free(). Enabling this was the point of some recent patches.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/md/md.c | 62 ++++++++++++++++++++++++++++---------------------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2920fd004865..58f531f8dcc2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3280,9 +3280,9 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
{
char clevel[16];
ssize_t rv = len;
- struct md_personality *pers;
+ struct md_personality *pers, *oldpers;
long level;
- void *priv;
+ void *priv, *oldpriv;
struct md_rdev *rdev;
if (mddev->pers == NULL) {
@@ -3374,9 +3374,35 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
/* Looks like we have a winner */
mddev_suspend(mddev);
mddev_detach(mddev);
- mddev->pers->free(mddev, mddev->private);
+ oldpers = mddev->pers;
+ oldpriv = mddev->private;
+ mddev->pers = pers;
+ mddev->private = priv;
+ strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
+ mddev->level = mddev->new_level;
+ mddev->layout = mddev->new_layout;
+ mddev->chunk_sectors = mddev->new_chunk_sectors;
+ mddev->delta_disks = 0;
+ mddev->reshape_backwards = 0;
+ mddev->degraded = 0;
+
+ if (oldpers->sync_request == NULL &&
+ mddev->external) {
+ /* We are converting from a no-redundancy array
+ * to a redundancy array and metadata is managed
+ * externally so we need to be sure that writes
+ * won't block due to a need to transition
+ * clean->dirty
+ * until external management is started.
+ */
+ mddev->in_sync = 0;
+ mddev->safemode_delay = 0;
+ mddev->safemode = 0;
+ }
- if (mddev->pers->sync_request == NULL &&
+ oldpers->free(mddev, oldpriv);
+
+ if (oldpers->sync_request == NULL &&
pers->sync_request != NULL) {
/* need to add the md_redundancy_group */
if (sysfs_create_group(&mddev->kobj, &md_redundancy_group))
@@ -3385,27 +3411,13 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
mdname(mddev));
mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, "sync_action");
}
- if (mddev->pers->sync_request != NULL &&
+ if (oldpers->sync_request != NULL &&
pers->sync_request == NULL) {
/* need to remove the md_redundancy_group */
if (mddev->to_remove == NULL)
mddev->to_remove = &md_redundancy_group;
}
- if (mddev->pers->sync_request == NULL &&
- mddev->external) {
- /* We are converting from a no-redundancy array
- * to a redundancy array and metadata is managed
- * externally so we need to be sure that writes
- * won't block due to a need to transition
- * clean->dirty
- * until external management is started.
- */
- mddev->in_sync = 0;
- mddev->safemode_delay = 0;
- mddev->safemode = 0;
- }
-
rdev_for_each(rdev, mddev) {
if (rdev->raid_disk < 0)
continue;
@@ -3431,17 +3443,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
}
}
- module_put(mddev->pers->owner);
- mddev->pers = pers;
- mddev->private = priv;
- strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
- mddev->level = mddev->new_level;
- mddev->layout = mddev->new_layout;
- mddev->chunk_sectors = mddev->new_chunk_sectors;
- mddev->delta_disks = 0;
- mddev->reshape_backwards = 0;
- mddev->degraded = 0;
- if (mddev->pers->sync_request == NULL) {
+ if (pers->sync_request == NULL) {
/* this is now an array without redundancy, so
* it must always be in_sync
*/
next prev parent reply other threads:[~2015-02-03 21:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-03 21:42 [md PATCH 00/26] Pending md patches NeilBrown
2015-02-03 21:42 ` [md PATCH 04/26] md/raid5: need_this_block: start simplifying the last two conditions NeilBrown
2015-02-03 21:42 ` [md PATCH 06/26] md: rename mddev->write_lock to mddev->lock NeilBrown
2015-02-03 21:42 ` [md PATCH 02/26] md/raid5: separate large if clause out of fetch_block() NeilBrown
2015-02-03 21:42 ` [md PATCH 01/26] md: do_release_stripe(): No need to call md_wakeup_thread() twice NeilBrown
2015-02-03 21:42 ` [md PATCH 03/26] md/raid5: separate out the easy conditions in need_this_block NeilBrown
2015-02-03 21:42 ` [md PATCH 05/26] md/raid5: need_this_block: tidy/fix last condition NeilBrown
2015-02-03 21:42 ` NeilBrown [this message]
2015-02-03 21:42 ` [md PATCH 10/26] md: split detach operation out from ->stop NeilBrown
2015-02-03 21:42 ` [md PATCH 13/26] md: protect ->pers changes with mddev->lock NeilBrown
2015-02-03 21:42 ` [md PATCH 14/26] md/bitmap: protect clearing of ->bitmap by mddev->lock NeilBrown
2015-02-03 21:42 ` [md PATCH 16/26] md/raid5: use ->lock to protect accessing raid5 sysfs attributes NeilBrown
2015-02-03 21:42 ` [md PATCH 19/26] md: remove unnecessary 'buf' from get_bitmap_file NeilBrown
2015-02-03 21:42 ` [md PATCH 07/26] md: make ->congested robust against personality changes NeilBrown
2015-02-03 21:42 ` [md PATCH 11/26] md: rename ->stop to ->free NeilBrown
2015-02-03 21:42 ` [md PATCH 17/26] md: remove mddev_lock() from md_attr_show() NeilBrown
2015-02-03 21:42 ` [md PATCH 09/26] md/linear: remove rcu protections in favour of suspend/resume NeilBrown
2015-02-03 21:42 ` [md PATCH 15/26] md: remove need for mddev_lock() in md_seq_show() NeilBrown
2015-02-03 21:42 ` [md PATCH 08/26] md: make merge_bvec_fn more robust in face of personality changes NeilBrown
2015-02-03 21:42 ` [md PATCH 20/26] md: tidy up set_bitmap_file NeilBrown
2015-02-03 21:42 ` [md PATCH 18/26] md: remove mddev_lock from rdev_attr_show() NeilBrown
2015-02-03 21:42 ` [md PATCH 23/26] md: use mddev->lock to protect updates to resync_{min, max} NeilBrown
2015-02-03 21:42 ` [md PATCH 24/26] md: move mddev_lock and related to md.h NeilBrown
2015-02-03 21:42 ` [md PATCH 25/26] md: make reconfig_mutex optional for writes to md sysfs files NeilBrown
2015-02-03 21:42 ` [md PATCH 22/26] md: minor cleanup in safe_delay_store NeilBrown
2015-02-03 21:42 ` [md PATCH 21/26] md: move GET_BITMAP_FILE ioctl out from mddev_lock NeilBrown
2015-02-03 21:42 ` [md PATCH 26/26] md: wakeup thread upon rdev_dec_pending() NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150203214229.3448.51698.stgit@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).