diff options
author | Shaohua Li <shli@fb.com> | 2017-05-10 08:47:11 -0700 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-05-11 15:32:17 -0700 |
commit | 23b245c04d0ef408087430dd4d1b214a5da1eb78 (patch) | |
tree | 229ffbbf1bb96ef604d59c4af9ed28d062c1d566 /drivers/md/raid1.c | |
parent | bb3338d3474e0329918fda9dae2c52751731eb58 (diff) |
md/raid1/10: avoid unnecessary locking
If we add bios to block plugging list, locking is unnecessry, since the block
unplug is guaranteed not to run at that time.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7c1f73398800..a17ed6218d51 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1529,17 +1529,16 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, plug = container_of(cb, struct raid1_plug_cb, cb); else plug = NULL; - spin_lock_irqsave(&conf->device_lock, flags); if (plug) { bio_list_add(&plug->pending, mbio); plug->pending_cnt++; } else { + spin_lock_irqsave(&conf->device_lock, flags); bio_list_add(&conf->pending_bio_list, mbio); conf->pending_count++; - } - spin_unlock_irqrestore(&conf->device_lock, flags); - if (!plug) + spin_unlock_irqrestore(&conf->device_lock, flags); md_wakeup_thread(mddev->thread); + } } r1_bio_write_done(r1_bio); |