* [PATCH] md:raid1/10: avoid unnecessary locking
@ 2017-05-10 15:52 shli
2017-05-11 22:29 ` NeilBrown
0 siblings, 1 reply; 2+ messages in thread
From: shli @ 2017-05-10 15:52 UTC (permalink / raw)
To: linux-raid; +Cc: Shaohua Li, NeilBrown
From: Shaohua Li <shli@fb.com>
If we add bios to block plugging list, locking is unnecessry, since the block
unplug is guaranteed not to run at that time.
Cc: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
---
drivers/md/raid1.c | 7 +++----
drivers/md/raid10.c | 7 +++----
2 files changed, 6 insertions(+), 8 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);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 6b86a0032cf8..4343d7ff9916 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -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);
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);
+ }
}
static void raid10_write_request(struct mddev *mddev, struct bio *bio,
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] md:raid1/10: avoid unnecessary locking
2017-05-10 15:52 [PATCH] md:raid1/10: avoid unnecessary locking shli
@ 2017-05-11 22:29 ` NeilBrown
0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2017-05-11 22:29 UTC (permalink / raw)
To: shli, linux-raid; +Cc: Shaohua Li
[-- Attachment #1: Type: text/plain, Size: 2293 bytes --]
On Wed, May 10 2017, shli@kernel.org wrote:
> From: Shaohua Li <shli@fb.com>
>
> If we add bios to block plugging list, locking is unnecessry, since the block
> unplug is guaranteed not to run at that time.
Yes, that make sense. Thanks
Reviewed-by: NeilBrown <neilb@suse.com>
>
> Cc: NeilBrown <neilb@suse.com>
> Signed-off-by: Shaohua Li <shli@fb.com>
> ---
> drivers/md/raid1.c | 7 +++----
> drivers/md/raid10.c | 7 +++----
> 2 files changed, 6 insertions(+), 8 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);
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 6b86a0032cf8..4343d7ff9916 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -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);
> 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);
> + }
> }
>
> static void raid10_write_request(struct mddev *mddev, struct bio *bio,
> --
> 2.11.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-11 22:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10 15:52 [PATCH] md:raid1/10: avoid unnecessary locking shli
2017-05-11 22:29 ` NeilBrown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox