From: Christoph Hellwig <hch@infradead.org>
To: Jens Axboe <jaxboe@fusionio.com>
Cc: Christoph Hellwig <hch@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: merging discard request in the block layer
Date: Tue, 3 May 2011 14:05:26 -0400 [thread overview]
Message-ID: <20110503180526.GA2127@infradead.org> (raw)
In-Reply-To: <4D88FE5E.1010204@fusionio.com>
I finally maged to debug this a bit further and can have found a cure
for the null pointer derefences I got on recent kernels.
The problem is that bio_has_data thinks discard requests have a payload
and thus tries to poke into it's pages when trying to merge requests.
Taking the REQ_DISCARD check in to bio_has_data fixes that. I've also
tried to special case discard requests in bio_cur_bytes, but that
doesn't fix the botched requests messages yet. I suspect the merging
code might need some additions to update the bio_size for discard
requests that it currently skips.
Index: xfs/block/blk-core.c
===================================================================
--- xfs.orig/block/blk-core.c 2011-05-03 19:45:51.980219652 +0200
+++ xfs/block/blk-core.c 2011-05-03 19:47:51.756237436 +0200
@@ -1645,7 +1645,7 @@ void submit_bio(int rw, struct bio *bio)
* If it's a regular read/write or a barrier with data attached,
* go through the normal accounting stuff before submission.
*/
- if (bio_has_data(bio) && !(rw & REQ_DISCARD)) {
+ if (bio_has_data(bio)) {
if (rw & WRITE) {
count_vm_events(PGPGOUT, count);
} else {
Index: xfs/include/linux/bio.h
===================================================================
--- xfs.orig/include/linux/bio.h 2011-05-03 19:43:28.537663414 +0200
+++ xfs/include/linux/bio.h 2011-05-03 19:48:18.632758500 +0200
@@ -69,7 +69,7 @@
static inline unsigned int bio_cur_bytes(struct bio *bio)
{
- if (bio->bi_vcnt)
+ if (bio->bi_vcnt && !(bio->bi_rw & REQ_DISCARD))
return bio_iovec(bio)->bv_len;
else /* dataless requests such as discard */
return bio->bi_size;
@@ -368,7 +368,7 @@ static inline char *__bio_kmap_irq(struc
*/
static inline int bio_has_data(struct bio *bio)
{
- return bio && bio->bi_io_vec != NULL;
+ return bio && bio->bi_io_vec != NULL && !(bio->bi_rw & REQ_DISCARD);
}
/*
prev parent reply other threads:[~2011-05-03 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-22 19:47 merging discard request in the block layer Christoph Hellwig
2011-03-22 19:54 ` Jens Axboe
2011-03-22 21:00 ` Christoph Hellwig
2011-03-22 21:03 ` Jens Axboe
2011-03-23 13:01 ` Christoph Hellwig
2011-03-23 15:26 ` Jens Axboe
2011-03-30 14:16 ` Christoph Hellwig
2011-05-03 18:05 ` Christoph Hellwig [this message]
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=20110503180526.GA2127@infradead.org \
--to=hch@infradead.org \
--cc=jaxboe@fusionio.com \
--cc=linux-kernel@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