]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.xen/805-blkfront-map-sg.patch
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.xen / 805-blkfront-map-sg.patch
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>
4 # Date 1236264120 0
5 # Node ID 63be3e5e2f1a132ce062c446a7d742e3523cf16b
6 # Parent f3de83c4677ff77eaf445b3182f00169f6982ce3
7 Subject: linux/blkfront: use blk_rq_map_sg to generate ring entries
8 Patch-mainline: 2.6.29
9 References: bnc#470238
10
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>
14
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.
17
18 Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
19
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
22 @@ -40,6 +40,7 @@
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);
33
34 + memset(info->sg, 0, sizeof(info->sg));
35 +
36 err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
37 if (err < 0) {
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;
43 - struct bio *bio;
44 - struct bio_vec *bvec;
45 - int idx;
46 unsigned long id;
47 unsigned int fsect, lsect;
48 - int ref;
49 + int i, ref;
50 grant_ref_t gref_head;
51 + struct scatterlist *sg;
52
53 if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
54 return 1;
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;
58
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) {
70 + sg = info->sg + 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
78 buffer_mfn,
79 rq_data_dir(req) ? GTF_readonly : 0 );
80
81 - info->shadow[id].frame[ring_req->nr_segments] =
82 - mfn_to_pfn(buffer_mfn);
83 -
84 - ring_req->seg[ring_req->nr_segments] =
85 + info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
86 + ring_req->seg[i] =
87 (struct blkif_request_segment) {
88 .gref = ref,
89 .first_sect = fsect,
90 .last_sect = lsect };
91 -
92 - ring_req->nr_segments++;
93 - }
94 }
95
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
100 int connected;
101 int ring_ref;
102 blkif_front_ring_t ring;
103 + struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
104 unsigned int irq;
105 struct xlbd_major_info *mi;
106 request_queue_t *rq;