From: Mike Snitzer <snitzer@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org,
James.Bottomley@hansenpartnership.com, jaxboe@fusionio.com,
dm-devel@redhat.com, michaelc@cs.wisc.edu,
Vivek Goyal <vgoyal@redhat.com>
Subject: Re: dm-io async WRITE_SAME results in iSCSI NULL pointer [was: Re: Write same support]
Date: Tue, 21 Feb 2012 01:55:04 -0500 [thread overview]
Message-ID: <20120221065504.GB468@redhat.com> (raw)
In-Reply-To: <yq1pqd825zt.fsf@sermon.lab.mkp.net>
On Mon, Feb 20 2012 at 10:57pm -0500,
Martin K. Petersen <martin.petersen@oracle.com> wrote:
> >>>>> "Mike" == Mike Snitzer <snitzer@redhat.com> writes:
>
> Mike,
>
> Mike> One, thing I noticed: bio_has_data returns false for
> Mike> REQ_WRITE_SAME. But REQ_WRITE_SAME does have data, and it really
> Mike> should be accounted no?:
>
> I decided against it. We don't count discards either and write sames are
> not really page-out types of activity. Happy to change it if people
> think this is something we should handle. But what do we actually count?
> A single logical block or the number of sectors written by the target
> device?
I'd say the single logical block.
> Mike> That aside, I tried your updated code and hit this BUG when I use
> Mike> the patch that has always worked (my dm-thin patch that uses the
> Mike> blkdev_issue_write_same() interface):
>
> Mike> ------------[ cut here ]------------ kernel BUG at
> Mike> drivers/scsi/scsi_lib.c:1116!
>
> That's the
>
> BUG_ON(!req->nr_phys_segments);
>
> in scsi_setup_blk_pc_cmnd(). We set nr_phys_segments to bi_phys_segments
> just before calling that function. So how did you end up with a
> zero-segment bio?
All I did was apply this patch to your writesame2 branch:
http://people.redhat.com/msnitzer/patches/upstream/dm-io-WRITE_SAME/dm-thin-use-WRITE_SAME-for-zeroing.patch
(and run the thinp-test-suite test I referenced in the other mail).
-- I'm just using the blkdev_issue_write_same() interface.. nothing special
I think the bio_has_data() change is at the heart of the BUG_ON().
Now this branch in blk_rq_bio_prep() is no longer taken:
if (bio_has_data(bio)) {
rq->nr_phys_segments = bio_phys_segments(q, bio);
rq->buffer = bio_data(bio);
}
This patch fixed the issue for me (though I'm still missing why
bio->bi_phys_segments was 0 given blkdev_issue_write_same() sets it):
Index: linux-2.6/drivers/scsi/sd.c
===================================================================
--- linux-2.6.orig/drivers/scsi/sd.c
+++ linux-2.6/drivers/scsi/sd.c
@@ -697,6 +697,7 @@ out:
static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)
{
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
+ struct request_queue *q = sdkp->disk->queue;
struct bio *bio = rq->bio;
sector_t sector = bio->bi_sector;
unsigned int nr_sectors = bio_sectors(bio);
@@ -711,7 +712,8 @@ static int sd_setup_write_same_cmnd(stru
rq->timeout = SD_WRITE_SAME_TIMEOUT;
rq->__data_len = rq->resid_len = sdp->sector_size;
- rq->nr_phys_segments = bio->bi_phys_segments;
+ rq->nr_phys_segments = bio_phys_segments(q, bio);
+ rq->buffer = bio_data(bio);
memset(rq->cmd, 0, rq->cmd_len);
if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) {
> PS. I was unsuccessful in getting the thinp test suite working. If you
> can come up with a simpler way for me to get DM to issue a write same
> then please share...
Any new block that gets provisioned will trigger zeroing (unless the
entire block will be consumed with data -- in that case the zero is
avoided). If you use the default thinp block size: a random IO
benchmark or a simple dd, of a partial block, should trigger zeroing.
Mike
next prev parent reply other threads:[~2012-02-21 6:55 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 0:31 Write same support Martin K. Petersen
2012-01-31 0:31 ` [PATCH 1/5] block: Implement support for WRITE SAME Martin K. Petersen
2012-02-07 21:40 ` Vivek Goyal
2012-02-13 22:19 ` Martin K. Petersen
2012-02-14 8:05 ` Rolf Eike Beer
2012-02-15 15:33 ` Vivek Goyal
2012-02-16 3:29 ` Martin K. Petersen
2012-02-16 17:16 ` Vivek Goyal
2012-02-16 19:12 ` Martin K. Petersen
2012-02-08 22:50 ` Mike Snitzer
2012-02-08 23:12 ` Martin K. Petersen
2012-02-09 3:33 ` Mike Snitzer
2012-02-09 3:40 ` Mike Snitzer
2012-01-31 0:31 ` [PATCH 2/5] block: Make blkdev_issue_zeroout use " Martin K. Petersen
2012-01-31 0:31 ` [PATCH 3/5] block: ioctl to zero block ranges Martin K. Petersen
2012-01-31 0:31 ` [PATCH 4/5] scsi: Add a report opcode helper Martin K. Petersen
2012-01-31 19:53 ` Jeff Garzik
2012-01-31 20:16 ` Martin K. Petersen
2012-01-31 0:31 ` [PATCH 5/5] sd: Implement support for WRITE SAME Martin K. Petersen
2012-02-20 16:16 ` Mike Snitzer
2012-02-20 17:36 ` Martin K. Petersen
2012-02-20 18:28 ` Mike Snitzer
2012-02-03 19:15 ` Write same support Mike Snitzer
2012-02-03 19:20 ` Roland Dreier
2012-02-16 20:02 ` Mike Snitzer
2012-02-16 20:46 ` Martin K. Petersen
2012-02-16 21:09 ` Mike Snitzer
2012-02-16 21:03 ` dm-io async WRITE_SAME results in iSCSI NULL pointer [was: Re: Write same support] Mike Snitzer
2012-02-16 21:25 ` Mike Christie
2012-02-16 21:35 ` Mike Snitzer
2012-02-20 17:44 ` Martin K. Petersen
2012-02-20 18:46 ` Mike Snitzer
2012-02-20 23:44 ` Mike Snitzer
2012-02-21 0:07 ` Martin K. Petersen
2012-02-21 3:18 ` Mike Snitzer
2012-02-21 3:57 ` Martin K. Petersen
2012-02-21 6:55 ` Mike Snitzer [this message]
2012-02-21 12:31 ` Martin K. Petersen
2012-02-21 14:42 ` Mike Snitzer
2012-02-21 19:33 ` Mike Snitzer
2012-02-21 21:31 ` Martin K. Petersen
2012-02-21 23:36 ` Mike Snitzer
2012-02-21 19:47 ` Vivek Goyal
2012-02-21 19:56 ` Martin K. Petersen
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=20120221065504.GB468@redhat.com \
--to=snitzer@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=dm-devel@redhat.com \
--cc=jaxboe@fusionio.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michaelc@cs.wisc.edu \
--cc=vgoyal@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.