WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] linux/blkfront: use blk_rq_map_sg to

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] linux/blkfront: use blk_rq_map_sg to generate ring entries
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 07 Mar 2009 06:35:41 -0800
Delivery-date: Sat, 07 Mar 2009 06:37:03 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1236264120 0
# Node ID 63be3e5e2f1a132ce062c446a7d742e3523cf16b
# Parent  f3de83c4677ff77eaf445b3182f00169f6982ce3
linux/blkfront: use blk_rq_map_sg to generate ring entries

Signed-off-by: Jens Axboe <jens.axboe@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 drivers/xen/blkfront/blkfront.c |   33 ++++++++++++++-------------------
 drivers/xen/blkfront/block.h    |    1 +
 2 files changed, 15 insertions(+), 19 deletions(-)

diff -r f3de83c4677f -r 63be3e5e2f1a drivers/xen/blkfront/blkfront.c
--- a/drivers/xen/blkfront/blkfront.c   Thu Mar 05 14:40:35 2009 +0000
+++ b/drivers/xen/blkfront/blkfront.c   Thu Mar 05 14:42:00 2009 +0000
@@ -40,6 +40,7 @@
 #include <linux/cdrom.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
+#include <linux/scatterlist.h>
 #include <scsi/scsi.h>
 #include <xen/evtchn.h>
 #include <xen/xenbus.h>
@@ -231,6 +232,8 @@ static int setup_blkring(struct xenbus_d
        }
        SHARED_RING_INIT(sring);
        FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
+
+       sg_init_table(info->sg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
 
        err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
        if (err < 0) {
@@ -587,13 +590,11 @@ static int blkif_queue_request(struct re
        struct blkfront_info *info = req->rq_disk->private_data;
        unsigned long buffer_mfn;
        blkif_request_t *ring_req;
-       struct bio *bio;
-       struct bio_vec *bvec;
-       int idx;
        unsigned long id;
        unsigned int fsect, lsect;
-       int ref;
+       int i, ref;
        grant_ref_t gref_head;
+       struct scatterlist *sg;
 
        if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
                return 1;
@@ -622,14 +623,13 @@ static int blkif_queue_request(struct re
        if (blk_barrier_rq(req))
                ring_req->operation = BLKIF_OP_WRITE_BARRIER;
 
-       ring_req->nr_segments = 0;
-       rq_for_each_bio (bio, req) {
-               bio_for_each_segment (bvec, bio, idx) {
-                       BUG_ON(ring_req->nr_segments
-                              == BLKIF_MAX_SEGMENTS_PER_REQUEST);
-                       buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
-                       fsect = bvec->bv_offset >> 9;
-                       lsect = fsect + (bvec->bv_len >> 9) - 1;
+       ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
+       BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
+       for (i = 0; i < ring_req->nr_segments; ++i) {
+                       sg = info->sg + i;
+                       buffer_mfn = page_to_phys(sg->page) >> PAGE_SHIFT;
+                       fsect = sg->offset >> 9;
+                       lsect = fsect + (sg->length >> 9) - 1;
                        /* install a grant reference. */
                        ref = gnttab_claim_grant_reference(&gref_head);
                        BUG_ON(ref == -ENOSPC);
@@ -640,17 +640,12 @@ static int blkif_queue_request(struct re
                                buffer_mfn,
                                rq_data_dir(req) ? GTF_readonly : 0 );
 
-                       info->shadow[id].frame[ring_req->nr_segments] =
-                               mfn_to_pfn(buffer_mfn);
-
-                       ring_req->seg[ring_req->nr_segments] =
+                       info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
+                       ring_req->seg[i] =
                                (struct blkif_request_segment) {
                                        .gref       = ref,
                                        .first_sect = fsect,
                                        .last_sect  = lsect };
-
-                       ring_req->nr_segments++;
-               }
        }
 
        info->ring.req_prod_pvt++;
diff -r f3de83c4677f -r 63be3e5e2f1a drivers/xen/blkfront/block.h
--- a/drivers/xen/blkfront/block.h      Thu Mar 05 14:40:35 2009 +0000
+++ b/drivers/xen/blkfront/block.h      Thu Mar 05 14:42:00 2009 +0000
@@ -103,6 +103,7 @@ struct blkfront_info
        int connected;
        int ring_ref;
        blkif_front_ring_t ring;
+       struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        unsigned int irq;
        struct xlbd_major_info *mi;
        request_queue_t *rq;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] linux/blkfront: use blk_rq_map_sg to generate ring entries, Xen patchbot-linux-2.6.18-xen <=