Commit 23b245c0 authored by Shaohua Li's avatar Shaohua Li

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: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent bb3338d3
...@@ -1529,18 +1529,17 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, ...@@ -1529,18 +1529,17 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
plug = container_of(cb, struct raid1_plug_cb, cb); plug = container_of(cb, struct raid1_plug_cb, cb);
else else
plug = NULL; plug = NULL;
spin_lock_irqsave(&conf->device_lock, flags);
if (plug) { if (plug) {
bio_list_add(&plug->pending, mbio); bio_list_add(&plug->pending, mbio);
plug->pending_cnt++; plug->pending_cnt++;
} else { } else {
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio); bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++; conf->pending_count++;
}
spin_unlock_irqrestore(&conf->device_lock, flags); spin_unlock_irqrestore(&conf->device_lock, flags);
if (!plug)
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
} }
}
r1_bio_write_done(r1_bio); r1_bio_write_done(r1_bio);
......
...@@ -1282,17 +1282,16 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, ...@@ -1282,17 +1282,16 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
plug = container_of(cb, struct raid10_plug_cb, cb); plug = container_of(cb, struct raid10_plug_cb, cb);
else else
plug = NULL; plug = NULL;
spin_lock_irqsave(&conf->device_lock, flags);
if (plug) { if (plug) {
bio_list_add(&plug->pending, mbio); bio_list_add(&plug->pending, mbio);
plug->pending_cnt++; plug->pending_cnt++;
} else { } else {
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio); bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++; conf->pending_count++;
}
spin_unlock_irqrestore(&conf->device_lock, flags); spin_unlock_irqrestore(&conf->device_lock, flags);
if (!plug)
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
}
} }
static void raid10_write_request(struct mddev *mddev, struct bio *bio, static void raid10_write_request(struct mddev *mddev, struct bio *bio,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment