1 From: http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/63be3e5e2f1a
2 # HG changeset 805+806 patch
3 # User Keir Fraser <keir.fraser@citrix.com>
5 # Node ID 63be3e5e2f1a132ce062c446a7d742e3523cf16b
6 # Parent f3de83c4677ff77eaf445b3182f00169f6982ce3
7 Subject: linux/blkfront: use blk_rq_map_sg to generate ring entries
11 Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
12 Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
13 Signed-off-by: Jan Beulich <jbeulich@novell.com>
15 From: http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/0430b1dbfb3a
16 blkfront: Fix the build by expanding sg_init_table() in place.
18 Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
20 --- sle11-2009-03-24.orig/drivers/xen/blkfront/blkfront.c 2009-03-24 10:00:15.000000000 +0100
21 +++ sle11-2009-03-24/drivers/xen/blkfront/blkfront.c 2009-03-05 15:42:00.000000000 +0100
23 #include <linux/cdrom.h>
24 #include <linux/sched.h>
25 #include <linux/interrupt.h>
26 +#include <linux/scatterlist.h>
27 #include <scsi/scsi.h>
28 #include <xen/evtchn.h>
29 #include <xen/xenbus.h>
30 @@ -232,6 +233,8 @@ static int setup_blkring(struct xenbus_d
31 SHARED_RING_INIT(sring);
32 FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
34 + memset(info->sg, 0, sizeof(info->sg));
36 err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
38 free_page((unsigned long)sring);
39 @@ -587,13 +590,11 @@ static int blkif_queue_request(struct re
40 struct blkfront_info *info = req->rq_disk->private_data;
41 unsigned long buffer_mfn;
42 blkif_request_t *ring_req;
44 - struct bio_vec *bvec;
47 unsigned int fsect, lsect;
50 grant_ref_t gref_head;
51 + struct scatterlist *sg;
53 if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
55 @@ -622,14 +623,13 @@ static int blkif_queue_request(struct re
56 if (blk_barrier_rq(req))
57 ring_req->operation = BLKIF_OP_WRITE_BARRIER;
59 - ring_req->nr_segments = 0;
60 - rq_for_each_bio (bio, req) {
61 - bio_for_each_segment (bvec, bio, idx) {
62 - BUG_ON(ring_req->nr_segments
63 - == BLKIF_MAX_SEGMENTS_PER_REQUEST);
64 - buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
65 - fsect = bvec->bv_offset >> 9;
66 - lsect = fsect + (bvec->bv_len >> 9) - 1;
67 + ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
68 + BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
69 + for (i = 0; i < ring_req->nr_segments; ++i) {
71 + buffer_mfn = page_to_phys(sg->page) >> PAGE_SHIFT;
72 + fsect = sg->offset >> 9;
73 + lsect = fsect + (sg->length >> 9) - 1;
74 /* install a grant reference. */
75 ref = gnttab_claim_grant_reference(&gref_head);
76 BUG_ON(ref == -ENOSPC);
77 @@ -640,17 +640,12 @@ static int blkif_queue_request(struct re
79 rq_data_dir(req) ? GTF_readonly : 0 );
81 - info->shadow[id].frame[ring_req->nr_segments] =
82 - mfn_to_pfn(buffer_mfn);
84 - ring_req->seg[ring_req->nr_segments] =
85 + info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
87 (struct blkif_request_segment) {
92 - ring_req->nr_segments++;
96 info->ring.req_prod_pvt++;
97 --- sle11-2009-03-24.orig/drivers/xen/blkfront/block.h 2009-03-24 10:00:15.000000000 +0100
98 +++ sle11-2009-03-24/drivers/xen/blkfront/block.h 2009-03-05 15:42:00.000000000 +0100
99 @@ -103,6 +103,7 @@ struct blkfront_info
102 blkif_front_ring_t ring;
103 + struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
105 struct xlbd_major_info *mi;