From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: Jens Axboe <jens.axboe@oracle.com>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
James.Bottomley@SteelEye.com
Subject: [PATCH 04/33] scsi: convert to using sg helpers
Date: Mon, 16 Jul 2007 11:47:18 +0200 [thread overview]
Message-ID: <11845792672912-git-send-email-jens.axboe@oracle.com> (raw)
In-Reply-To: <11845792671245-git-send-email-jens.axboe@oracle.com>
This converts the SCSI mid layer to using the sg helpers for looking up
sg elements, instead of doing it manually.
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James.Bottomley@SteelEye.com
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
drivers/scsi/scsi_lib.c | 21 ++++++++++++---------
include/scsi/scsi_cmnd.h | 2 +-
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 1f5a07b..9fe66f8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -17,6 +17,7 @@
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/hardirq.h>
+#include <linux/scatterlist.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -302,14 +303,15 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
struct request_queue *q = rq->q;
int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
unsigned int data_len = 0, len, bytes, off;
+ struct scatterlist *sg;
struct page *page;
struct bio *bio = NULL;
int i, err, nr_vecs = 0;
- for (i = 0; i < nsegs; i++) {
- page = sgl[i].page;
- off = sgl[i].offset;
- len = sgl[i].length;
+ for_each_sg(sgl, sg, nsegs, i) {
+ page = sg->page;
+ off = sg->offset;
+ len = sg->length;
data_len += len;
while (len > 0) {
@@ -2240,18 +2242,19 @@ EXPORT_SYMBOL_GPL(scsi_target_unblock);
*
* Returns virtual address of the start of the mapped page
*/
-void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
+void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
size_t *offset, size_t *len)
{
int i;
size_t sg_len = 0, len_complete = 0;
+ struct scatterlist *sg;
struct page *page;
WARN_ON(!irqs_disabled());
- for (i = 0; i < sg_count; i++) {
+ for_each_sg(sgl, sg, sg_count, i) {
len_complete = sg_len; /* Complete sg-entries */
- sg_len += sg[i].length;
+ sg_len += sg->length;
if (sg_len > *offset)
break;
}
@@ -2265,10 +2268,10 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
}
/* Offset starting from the beginning of first page in this sg-entry */
- *offset = *offset - len_complete + sg[i].offset;
+ *offset = *offset - len_complete + sg->offset;
/* Assumption: contiguous pages can be accessed as "page + i" */
- page = nth_page(sg[i].page, (*offset >> PAGE_SHIFT));
+ page = nth_page(sg->page, (*offset >> PAGE_SHIFT));
*offset &= ~PAGE_MASK;
/* Bytes in this sg-entry from *offset to the end of the page */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 53e1705..a059f1b 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -153,6 +153,6 @@ static inline int scsi_get_resid(struct scsi_cmnd *cmd)
}
#define scsi_for_each_sg(cmd, sg, nseg, __i) \
- for (__i = 0, sg = scsi_sglist(cmd); __i < (nseg); __i++, (sg)++)
+ for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
#endif /* _SCSI_SCSI_CMND_H */
--
1.5.3.rc0.90.gbaa79
next prev parent reply other threads:[~2007-07-16 9:50 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 9:47 [PATCH 00/33] SG table chaining support Jens Axboe
2007-07-16 9:47 ` [PATCH 01/33] crypto: don't pollute the global namespace with sg_next() Jens Axboe
2007-07-16 9:47 ` [PATCH 02/33] Add sg helpers for iterating over a scatterlist table Jens Axboe
2007-07-16 9:47 ` [PATCH 03/33] block: convert to using sg helpers Jens Axboe
2007-07-16 19:21 ` Bartlomiej Zolnierkiewicz
2007-07-16 19:14 ` Jens Axboe
2007-07-16 9:47 ` Jens Axboe [this message]
2007-07-16 9:47 ` [PATCH 05/33] Add chained sg support to linux/scatterlist.h Jens Axboe
2007-07-16 19:21 ` Bartlomiej Zolnierkiewicz
2007-07-16 19:15 ` Jens Axboe
2007-07-16 9:47 ` [PATCH 06/33] i386 dma_map_sg: convert to using sg helpers Jens Axboe
2007-07-16 9:47 ` [PATCH 07/33] i386: enable sg chaining Jens Axboe
2007-07-16 9:47 ` [PATCH 08/33] swiotlb: sg chaining support Jens Axboe
2007-07-16 9:47 ` [PATCH 09/33] x86-64: update iommu/dma mapping functions to sg helpers Jens Axboe
2007-07-16 20:06 ` Andrew Morton
2007-07-16 20:10 ` Jens Axboe
2007-07-16 20:34 ` Andrew Morton
2007-07-16 22:08 ` Muli Ben-Yehuda
2007-07-17 7:38 ` Jens Axboe
2007-07-17 8:49 ` Muli Ben-Yehuda
2007-07-17 8:51 ` Jens Axboe
2007-07-17 9:00 ` Muli Ben-Yehuda
2007-07-17 7:02 ` Jens Axboe
2007-07-17 7:56 ` Jens Axboe
2007-07-17 11:03 ` Muli Ben-Yehuda
2007-07-17 11:05 ` Jens Axboe
2007-07-17 11:10 ` Muli Ben-Yehuda
2007-07-16 9:47 ` [PATCH 10/33] x86-64: enable sg chaining Jens Axboe
2007-07-16 9:47 ` [PATCH 11/33] IA64: sg chaining support Jens Axboe
2007-07-16 9:47 ` [PATCH 12/33] PPC: " Jens Axboe
2007-07-16 9:47 ` [PATCH 13/33] SPARC: " Jens Axboe
2007-07-16 11:29 ` David Miller
2007-07-16 9:47 ` [PATCH 14/33] SPARC64: " Jens Axboe
2007-07-16 11:29 ` David Miller
2007-07-16 9:47 ` [PATCH 15/33] scsi: simplify scsi_free_sgtable() Jens Axboe
2007-07-16 9:47 ` [PATCH 16/33] SCSI: support for allocating large scatterlists Jens Axboe
2007-07-16 9:47 ` [PATCH 17/33] ll_rw_blk: temporarily enable max_segments tweaking Jens Axboe
2007-07-16 9:47 ` [PATCH 18/33] libata: convert to using sg helpers Jens Axboe
2007-07-16 9:47 ` [PATCH 19/33] scsi_debug: support sg chaining Jens Axboe
2007-07-16 9:47 ` [PATCH 20/33] scsi generic: sg chaining support Jens Axboe
2007-07-16 9:47 ` [PATCH 21/33] qla1280: " Jens Axboe
2007-07-16 9:47 ` [PATCH 22/33] aic94xx: " Jens Axboe
2007-07-16 9:47 ` [PATCH 23/33] qlogicpti: " Jens Axboe
2007-07-16 9:47 ` [PATCH 24/33] ide-scsi: " Jens Axboe
2007-07-18 21:03 ` Bartlomiej Zolnierkiewicz
2007-07-16 9:47 ` [PATCH 25/33] gdth: " Jens Axboe
2007-07-16 9:47 ` [PATCH 26/33] aha1542: convert to use the data buffer accessors Jens Axboe
2007-07-16 9:47 ` [PATCH 27/33] advansys: " Jens Axboe
2007-07-16 9:47 ` [PATCH 28/33] ia64 simscsi: convert to use " Jens Axboe
2007-07-16 9:47 ` [PATCH 29/33] infiniband: sg chaining support Jens Axboe
2007-07-16 13:21 ` FUJITA Tomonori
2007-07-16 13:26 ` Jens Axboe
2007-07-16 9:47 ` [PATCH 30/33] USB storage: " Jens Axboe
2007-07-17 6:12 ` Greg KH
2007-07-17 7:01 ` Jens Axboe
2007-07-17 7:05 ` Greg KH
2007-07-17 7:07 ` Jens Axboe
2007-07-16 9:47 ` [PATCH 31/33] Fusion: " Jens Axboe
2007-07-16 13:20 ` FUJITA Tomonori
2007-07-16 13:25 ` Jens Axboe
2007-07-16 9:47 ` [PATCH 32/33] i2o: " Jens Axboe
2007-07-16 9:47 ` [PATCH 33/33] IDE: " Jens Axboe
2007-07-18 20:56 ` Bartlomiej Zolnierkiewicz
2007-07-19 6:19 ` Jens Axboe
2007-07-16 13:19 ` [PATCH 00/33] SG table " FUJITA Tomonori
2007-07-16 13:23 ` Jens Axboe
2007-07-16 13:19 ` FUJITA Tomonori
2007-07-16 13:24 ` Jens Axboe
2007-07-16 14:05 ` John Stoffel
2007-07-16 14:23 ` Martin K. Petersen
2007-07-16 14:43 ` Jens Axboe
2007-07-16 16:02 ` Kai Makisara
2007-07-16 16:43 ` 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=11845792672912-git-send-email-jens.axboe@oracle.com \
--to=jens.axboe@oracle.com \
--cc=James.Bottomley@SteelEye.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®