public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Christof Schmitt <christof.schmitt@de.ibm.com>
Subject: [patch 1/1] block: Apply segment size and boundary limits to integrity data
Date: Thu, 15 Jul 2010 17:34:11 +0200	[thread overview]
Message-ID: <20100715154547.485829000@de.ibm.com> (raw)
In-Reply-To: 20100715153410.774329000@de.ibm.com

[-- Attachment #1: linux-2.6.34-blk-integrity-fix.diff --]
[-- Type: text/plain, Size: 1594 bytes --]

From: Christof Schmitt <christof.schmitt@de.ibm.com>

Apply the conditions used in __blk_recalc_rq_segments also to
integrity data: Adhere to the maximum segment size and the segment
boundary set by the driver. Without this change, a driver would
receive integrity data blocks that do not adhere to the limits set for
the request queue.

Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
 block/blk-integrity.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -41,15 +41,22 @@ int blk_rq_count_integrity_sg(struct req
 {
 	struct bio_vec *iv, *ivprv;
 	struct req_iterator iter;
-	unsigned int segments;
+	unsigned int segments, seg_size;
 
 	ivprv = NULL;
 	segments = 0;
+	seg_size = 0;
 
 	rq_for_each_integrity_segment(iv, rq, iter) {
 
-		if (!ivprv || !BIOVEC_PHYS_MERGEABLE(ivprv, iv))
+		if (!ivprv ||
+		    !BIOVEC_PHYS_MERGEABLE(ivprv, iv) ||
+		    seg_size + iv->bv_len > queue_max_segment_size(rq->q) ||
+		    !BIOVEC_SEG_BOUNDARY(rq->q, ivprv, iv)) {
 			segments++;
+			seg_size = iv->bv_len;
+		} else
+			seg_size += iv->bv_len;
 
 		ivprv = iv;
 	}
@@ -81,9 +88,16 @@ int blk_rq_map_integrity_sg(struct reque
 	rq_for_each_integrity_segment(iv, rq, iter) {
 
 		if (ivprv) {
+			if (sg->length + iv->bv_len
+				    > queue_max_segment_size(rq->q))
+				goto new_segment;
+
 			if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv))
 				goto new_segment;
 
+			if (!BIOVEC_SEG_BOUNDARY(rq->q, ivprv, iv))
+				goto new_segment;
+
 			sg->length += iv->bv_len;
 		} else {
 new_segment:

  reply	other threads:[~2010-07-15 15:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-15 15:34 [patch 0/1] Apply segment size and segment boundary to integrity data Christof Schmitt
2010-07-15 15:34 ` Christof Schmitt [this message]
2010-07-15 15:53   ` [patch 1/1] block: Apply segment size and boundary limits " Jens Axboe
2010-07-15 16:03 ` [patch 0/1] Apply segment size and segment boundary " Martin K. Petersen
2010-07-15 16:14   ` Jens Axboe
2010-07-15 16:35     ` Martin K. Petersen
2010-07-15 16:40       ` Jens Axboe
2010-07-16  8:30   ` Christof Schmitt
2010-07-20  4:45     ` Martin K. Petersen
2010-07-20  9:28       ` Christof Schmitt
2010-07-21  4:20         ` Martin K. Petersen
2010-08-02 11:05           ` Christof Schmitt
2010-08-03  4:44             ` Martin K. Petersen
2010-08-11  8:07               ` Christof Schmitt

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=20100715154547.485829000@de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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