From: NeilBrown <neilb@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 001 of 3] md: Remove bi_end_io call out from under a spinlock.
Date: Fri, 24 Mar 2006 16:59:28 +1100 [thread overview]
Message-ID: <1060324055928.2444@suse.de> (raw)
In-Reply-To: 20060324165531.2372.patches@notabene
raid5 overloads bi_phys_segments to count the number of blocks that
the request was broken in to so that it knows when the bio is completely handled.
Accessing this must always be done under a spinlock. In one case we
also call bi_end_io under that spinlock, which probably isn't ideal as
bi_end_io could be expensive (even though it isn't allowed to sleep).
So we reducde the range of the spinlock to just accessing bi_phys_segments.
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./drivers/md/raid5.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff ./drivers/md/raid5.c~current~ ./drivers/md/raid5.c
--- ./drivers/md/raid5.c~current~ 2006-03-24 14:01:30.000000000 +1100
+++ ./drivers/md/raid5.c 2006-03-24 14:06:47.000000000 +1100
@@ -1743,6 +1743,7 @@ static int make_request(request_queue_t
sector_t logical_sector, last_sector;
struct stripe_head *sh;
const int rw = bio_data_dir(bi);
+ int remaining;
if (unlikely(bio_barrier(bi))) {
bio_endio(bi, bi->bi_size, -EOPNOTSUPP);
@@ -1852,7 +1853,9 @@ static int make_request(request_queue_t
}
spin_lock_irq(&conf->device_lock);
- if (--bi->bi_phys_segments == 0) {
+ remaining = --bi->bi_phys_segments;
+ spin_unlock_irq(&conf->device_lock);
+ if (remaining == 0) {
int bytes = bi->bi_size;
if ( bio_data_dir(bi) == WRITE )
@@ -1860,7 +1863,6 @@ static int make_request(request_queue_t
bi->bi_size = 0;
bi->bi_end_io(bi, bytes, 0);
}
- spin_unlock_irq(&conf->device_lock);
return 0;
}
next prev parent reply other threads:[~2006-03-24 5:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-24 5:58 [PATCH 000 of 3] md: Introduction - 3 assorted md fixes NeilBrown
2006-03-24 5:59 ` NeilBrown [this message]
2006-03-24 6:00 ` [PATCH 002 of 3] md: Fix md grow/size code to correctly find the maximum available space NeilBrown
2006-03-24 6:00 ` [PATCH 003 of 3] md: Restore 'remaining' count when retrying an write operation 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=1060324055928.2444@suse.de \
--to=neilb@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--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).