All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@fb.com>
Cc: Dexuan Cui <decui@microsoft.com>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-nvme@lists.infradead.org
Subject: [PATCH 1/4] block: add blk_rq_payload_bytes
Date: Fri, 13 Jan 2017 12:29:10 +0100	[thread overview]
Message-ID: <1484306953-3194-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1484306953-3194-1-git-send-email-hch@lst.de>

Add a helper to calculate the actual data transfer size for special
payload requests.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/blkdev.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ff3d774..1ca8e8f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
 	return blk_rq_cur_bytes(rq) >> 9;
 }
 
+/*
+ * Some commands like WRITE SAME have a payload or data transfer size which
+ * is different from the size of the request.  Any driver that supports such
+ * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to
+ * calculate the data transfer size.
+ */
+static inline unsigned int blk_rq_payload_bytes(struct request *rq)
+{
+	if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
+		return rq->special_vec.bv_len;
+	return blk_rq_bytes(rq);
+}
+
 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
 						     int op)
 {
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 1/4] block: add blk_rq_payload_bytes
Date: Fri, 13 Jan 2017 12:29:10 +0100	[thread overview]
Message-ID: <1484306953-3194-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1484306953-3194-1-git-send-email-hch@lst.de>

Add a helper to calculate the actual data transfer size for special
payload requests.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 include/linux/blkdev.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ff3d774..1ca8e8f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
 	return blk_rq_cur_bytes(rq) >> 9;
 }
 
+/*
+ * Some commands like WRITE SAME have a payload or data transfer size which
+ * is different from the size of the request.  Any driver that supports such
+ * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to
+ * calculate the data transfer size.
+ */
+static inline unsigned int blk_rq_payload_bytes(struct request *rq)
+{
+	if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
+		return rq->special_vec.bv_len;
+	return blk_rq_bytes(rq);
+}
+
 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
 						     int op)
 {
-- 
2.1.4

  reply	other threads:[~2017-01-13 11:29 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13 11:29 fix data transfer size caculation for special payload requests Christoph Hellwig
2017-01-13 11:29 ` Christoph Hellwig
2017-01-13 11:29 ` Christoph Hellwig [this message]
2017-01-13 11:29   ` [PATCH 1/4] block: add blk_rq_payload_bytes Christoph Hellwig
2017-01-13 11:43   ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 21:52   ` Sagi Grimberg
2017-01-13 21:52     ` Sagi Grimberg
2017-01-13 11:29 ` [PATCH 2/4] scsi: use blk_rq_payload_bytes Christoph Hellwig
2017-01-13 11:29   ` Christoph Hellwig
2017-01-13 11:43   ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 21:52   ` Sagi Grimberg
2017-01-13 21:52     ` Sagi Grimberg
2017-01-13 11:29 ` [PATCH 3/4] nvme: " Christoph Hellwig
2017-01-13 11:29   ` Christoph Hellwig
2017-01-13 11:43   ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 11:43     ` Hannes Reinecke
2017-01-13 21:54   ` Sagi Grimberg
2017-01-13 21:54     ` Sagi Grimberg
2017-01-17 20:06   ` Sagi Grimberg
2017-01-17 20:06     ` Sagi Grimberg
2017-01-17 20:06     ` Sagi Grimberg
2017-01-18  9:09     ` Christoph Hellwig
2017-01-18  9:09       ` Christoph Hellwig
2017-01-19  7:54       ` Sagi Grimberg
2017-01-19  7:54         ` Sagi Grimberg
2017-01-13 11:29 ` [PATCH 4/4] sd: remove __data_len hack for WRITE SAME Christoph Hellwig
2017-01-13 11:29   ` Christoph Hellwig
2017-01-13 11:44   ` Hannes Reinecke
2017-01-13 11:44     ` Hannes Reinecke
2017-01-13 11:44     ` Hannes Reinecke
2017-01-13 21:56   ` Sagi Grimberg
2017-01-13 21:56     ` Sagi Grimberg
2017-01-13 22:17 ` fix data transfer size caculation for special payload requests Jens Axboe
2017-01-13 22:17   ` Jens Axboe

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=1484306953-3194-2-git-send-email-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@fb.com \
    --cc=decui@microsoft.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@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 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.