ia64/linux-2.6.18-xen.hg

changeset 805:63be3e5e2f1a

linux/blkfront: use blk_rq_map_sg to generate ring entries

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 05 14:42:00 2009 +0000 (2009-03-05)
parents f3de83c4677f
children 0430b1dbfb3a
files drivers/xen/blkfront/blkfront.c drivers/xen/blkfront/block.h
line diff
     1.1 --- a/drivers/xen/blkfront/blkfront.c	Thu Mar 05 14:40:35 2009 +0000
     1.2 +++ b/drivers/xen/blkfront/blkfront.c	Thu Mar 05 14:42:00 2009 +0000
     1.3 @@ -40,6 +40,7 @@
     1.4  #include <linux/cdrom.h>
     1.5  #include <linux/sched.h>
     1.6  #include <linux/interrupt.h>
     1.7 +#include <linux/scatterlist.h>
     1.8  #include <scsi/scsi.h>
     1.9  #include <xen/evtchn.h>
    1.10  #include <xen/xenbus.h>
    1.11 @@ -232,6 +233,8 @@ static int setup_blkring(struct xenbus_d
    1.12  	SHARED_RING_INIT(sring);
    1.13  	FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
    1.14  
    1.15 +	sg_init_table(info->sg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
    1.16 +
    1.17  	err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
    1.18  	if (err < 0) {
    1.19  		free_page((unsigned long)sring);
    1.20 @@ -587,13 +590,11 @@ static int blkif_queue_request(struct re
    1.21  	struct blkfront_info *info = req->rq_disk->private_data;
    1.22  	unsigned long buffer_mfn;
    1.23  	blkif_request_t *ring_req;
    1.24 -	struct bio *bio;
    1.25 -	struct bio_vec *bvec;
    1.26 -	int idx;
    1.27  	unsigned long id;
    1.28  	unsigned int fsect, lsect;
    1.29 -	int ref;
    1.30 +	int i, ref;
    1.31  	grant_ref_t gref_head;
    1.32 +	struct scatterlist *sg;
    1.33  
    1.34  	if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
    1.35  		return 1;
    1.36 @@ -622,14 +623,13 @@ static int blkif_queue_request(struct re
    1.37  	if (blk_barrier_rq(req))
    1.38  		ring_req->operation = BLKIF_OP_WRITE_BARRIER;
    1.39  
    1.40 -	ring_req->nr_segments = 0;
    1.41 -	rq_for_each_bio (bio, req) {
    1.42 -		bio_for_each_segment (bvec, bio, idx) {
    1.43 -			BUG_ON(ring_req->nr_segments
    1.44 -			       == BLKIF_MAX_SEGMENTS_PER_REQUEST);
    1.45 -			buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
    1.46 -			fsect = bvec->bv_offset >> 9;
    1.47 -			lsect = fsect + (bvec->bv_len >> 9) - 1;
    1.48 +	ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
    1.49 +	BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
    1.50 +	for (i = 0; i < ring_req->nr_segments; ++i) {
    1.51 +			sg = info->sg + i;
    1.52 +			buffer_mfn = page_to_phys(sg->page) >> PAGE_SHIFT;
    1.53 +			fsect = sg->offset >> 9;
    1.54 +			lsect = fsect + (sg->length >> 9) - 1;
    1.55  			/* install a grant reference. */
    1.56  			ref = gnttab_claim_grant_reference(&gref_head);
    1.57  			BUG_ON(ref == -ENOSPC);
    1.58 @@ -640,17 +640,12 @@ static int blkif_queue_request(struct re
    1.59  				buffer_mfn,
    1.60  				rq_data_dir(req) ? GTF_readonly : 0 );
    1.61  
    1.62 -			info->shadow[id].frame[ring_req->nr_segments] =
    1.63 -				mfn_to_pfn(buffer_mfn);
    1.64 -
    1.65 -			ring_req->seg[ring_req->nr_segments] =
    1.66 +			info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
    1.67 +			ring_req->seg[i] =
    1.68  				(struct blkif_request_segment) {
    1.69  					.gref       = ref,
    1.70  					.first_sect = fsect,
    1.71  					.last_sect  = lsect };
    1.72 -
    1.73 -			ring_req->nr_segments++;
    1.74 -		}
    1.75  	}
    1.76  
    1.77  	info->ring.req_prod_pvt++;
     2.1 --- a/drivers/xen/blkfront/block.h	Thu Mar 05 14:40:35 2009 +0000
     2.2 +++ b/drivers/xen/blkfront/block.h	Thu Mar 05 14:42:00 2009 +0000
     2.3 @@ -103,6 +103,7 @@ struct blkfront_info
     2.4  	int connected;
     2.5  	int ring_ref;
     2.6  	blkif_front_ring_t ring;
     2.7 +	struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     2.8  	unsigned int irq;
     2.9  	struct xlbd_major_info *mi;
    2.10  	request_queue_t *rq;