summaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown2016-11-04 06:46:03 +0100
committerShaohua Li2016-11-08 00:08:23 +0100
commit060b0689f5df7e87641c820a605c779149da33ef (patch)
tree712abb7179be07c99ed4bc408859622f5440eb6e /drivers/md/md.c
parentraid5-cache: restrict the use area of the log_offset variable (diff)
downloadkernel-qcow2-linux-060b0689f5df7e87641c820a605c779149da33ef.tar.gz
kernel-qcow2-linux-060b0689f5df7e87641c820a605c779149da33ef.tar.xz
kernel-qcow2-linux-060b0689f5df7e87641c820a605c779149da33ef.zip
md: perform async updates for metadata where possible.
When adding devices to, or removing device from, an array we need to update the metadata. However we don't need to do it synchronously as data integrity doesn't depend on these changes being recorded instantly. So avoid the synchronous call to md_update_sb and just set a flag so that the thread will do it. This can reduce the number of updates performed when lots of devices are being added or removed. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 22c9efd86b0d..f389d8abe137 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2599,8 +2599,10 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
if (err == 0) {
md_kick_rdev_from_array(rdev);
- if (mddev->pers)
- md_update_sb(mddev, 1);
+ if (mddev->pers) {
+ set_bit(MD_CHANGE_DEVS, &mddev->flags);
+ md_wakeup_thread(mddev->thread);
+ }
md_new_event(mddev);
}
}
@@ -6175,7 +6177,11 @@ kick_rdev:
md_cluster_ops->remove_disk(mddev, rdev);
md_kick_rdev_from_array(rdev);
- md_update_sb(mddev, 1);
+ set_bit(MD_CHANGE_DEVS, &mddev->flags);
+ if (mddev->thread)
+ md_wakeup_thread(mddev->thread);
+ else
+ md_update_sb(mddev, 1);
md_new_event(mddev);
return 0;
@@ -6240,7 +6246,9 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev)
rdev->raid_disk = -1;
- md_update_sb(mddev, 1);
+ set_bit(MD_CHANGE_DEVS, &mddev->flags);
+ if (!mddev->thread)
+ md_update_sb(mddev, 1);
/*
* Kick recovery, maybe this spare has to be added to the
* array immediately.