linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: jaxboe@fusionio.com, James.Bottomley@hansenpartnership.com,
	snitzer@redhat.com, michaelc@cs.wisc.edu,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 6/7] sd: Implement support for WRITE SAME
Date: Mon, 5 Mar 2012 10:07:28 -0500	[thread overview]
Message-ID: <20120305150728.GA18546@redhat.com> (raw)
In-Reply-To: <1330658571-12958-7-git-send-email-martin.petersen@oracle.com>

On Thu, Mar 01, 2012 at 10:22:50PM -0500, Martin K. Petersen wrote:

[..]
> +/**
> + * sd_setup_write_same_cmnd - write the same data to multiple blocks
> + * @sdp: scsi device to operate one
> + * @rq: Request to prepare
> + *
> + * Will issue either WRITE SAME(10) or WRITE SAME(16) depending on
> + * preference indicated by target device.
> + **/
> +static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)
> +{
> +	struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
> +	struct bio *bio = rq->bio;
> +	sector_t sector = bio->bi_sector;
> +	unsigned int nr_sectors = bio_sectors(bio);
> +
> +	if (sdkp->device->no_write_same)
> +		return BLKPREP_KILL;
> +
> +	BUG_ON(bio_offset(bio) || bio_iovec(bio)->bv_len != sdp->sector_size);
> +
> +	sector >>= ilog2(sdp->sector_size) - 9;
> +	nr_sectors >>= ilog2(sdp->sector_size) - 9;
> +
> +	rq->timeout = SD_WRITE_SAME_TIMEOUT;
> +	memset(rq->cmd, 0, rq->cmd_len);
> +
> +	if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) {
> +		rq->cmd_len = 16;
> +		rq->cmd[0] = WRITE_SAME_16;
> +		put_unaligned_be64(sector, &rq->cmd[2]);
> +		put_unaligned_be32(nr_sectors, &rq->cmd[10]);
> +	} else {
> +		rq->cmd_len = 10;
> +		rq->cmd[0] = WRITE_SAME;
> +		put_unaligned_be32(sector, &rq->cmd[2]);
> +		put_unaligned_be16(nr_sectors, &rq->cmd[7]);
> +	}
> +
> +	blk_add_request_payload(rq, bio_page(bio), sdp->sector_size);

Hi Martin,

I was just curious about what above function is doing. This is strange is
that we already have the bio->io_vec initialized and we are reusing that
to overwrite same bio with same information and trying to update rq again
with same information.

Given the fact at the request submission time we had a fully formed bio
(with payload page already there), shouldn't init_request_from_bio() and
blk_rq_bio_prep() take care of all the preprations?

IOW, I don't udnerstand, what this function is doing which needs to be
done now and couldn't have been done eariler before request was handed
over to scsi.

Even if we end up using blk_add_request_payload(), can we update the
comment in blk_add_request_payload() which says it is a hack only for
discard requets. 

Thanks
Vivek

  reply	other threads:[~2012-03-05 15:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02  3:22 Write same support v3 Martin K. Petersen
2012-03-02  3:22 ` [PATCH 1/7] block: Clean up merge logic Martin K. Petersen
2012-03-02 20:21   ` Vivek Goyal
2012-03-06 17:42     ` Martin K. Petersen
2012-03-07 16:52       ` Vivek Goyal
2012-03-08  4:41         ` Martin K. Petersen
2012-03-02 21:36   ` Vivek Goyal
2012-03-06 17:43     ` Martin K. Petersen
2012-03-02  3:22 ` [PATCH 2/7] block: Implement support for WRITE SAME Martin K. Petersen
2012-03-02 22:08   ` Vivek Goyal
2012-03-06 17:54     ` Martin K. Petersen
2012-03-07 17:03       ` DISCARD/WRITE_SAME request accounting (Was: Re: [PATCH 2/7] block: Implement support for WRITE SAME) Vivek Goyal
2012-03-08 10:48         ` Lukas Czerner
2012-03-09 16:54           ` Vivek Goyal
2012-03-02  3:22 ` [PATCH 3/7] block: Make blkdev_issue_zeroout use WRITE SAME Martin K. Petersen
2012-03-09 18:05   ` Paolo Bonzini
2012-03-13  2:30     ` Martin K. Petersen
2012-03-02  3:22 ` [PATCH 4/7] block: ioctl to zero block ranges Martin K. Petersen
2012-03-02  3:22 ` [PATCH 5/7] scsi: Add a report opcode helper Martin K. Petersen
2012-03-02  4:08   ` Jeff Garzik
2012-03-02  3:22 ` [PATCH 6/7] sd: Implement support for WRITE SAME Martin K. Petersen
2012-03-05 15:07   ` Vivek Goyal [this message]
2012-03-06 17:58     ` Martin K. Petersen
2012-03-02  3:22 ` [PATCH 7/7] sd: Use sd_ prefix for flush and discard functions Martin K. Petersen
2012-03-02 14:24 ` [PATCH] dm kcopyd: add WRITE SAME support to dm_kcopyd_zero Mike Snitzer
  -- strict thread matches above, loose matches on Subject: below --
2012-03-16 18:43 Write same support v4 Martin K. Petersen
2012-03-16 18:43 ` [PATCH 6/7] sd: Implement support for WRITE SAME 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=20120305150728.GA18546@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michaelc@cs.wisc.edu \
    --cc=snitzer@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 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).