Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block

* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
xen/blkfront: use blk_rq_map_sg to generate ring entries
block: reduce stack footprint of blk_recount_segments()
cciss: shorten 30s timeout on controller reset
block: add documentation for register_blkdev()
block: fix bogus gcc warning for uninitialized var usage

+94 -60
+53 -41
block/blk-merge.c
··· 38 38 } 39 39 } 40 40 41 - void blk_recalc_rq_segments(struct request *rq) 41 + static unsigned int __blk_recalc_rq_segments(struct request_queue *q, 42 + struct bio *bio, 43 + unsigned int *seg_size_ptr) 42 44 { 43 - int nr_phys_segs; 44 45 unsigned int phys_size; 45 46 struct bio_vec *bv, *bvprv = NULL; 46 - int seg_size; 47 - int cluster; 48 - struct req_iterator iter; 49 - int high, highprv = 1; 50 - struct request_queue *q = rq->q; 47 + int cluster, i, high, highprv = 1; 48 + unsigned int seg_size, nr_phys_segs; 49 + struct bio *fbio; 51 50 52 - if (!rq->bio) 53 - return; 51 + if (!bio) 52 + return 0; 54 53 54 + fbio = bio; 55 55 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 56 56 seg_size = 0; 57 57 phys_size = nr_phys_segs = 0; 58 - rq_for_each_segment(bv, rq, iter) { 59 - /* 60 - * the trick here is making sure that a high page is never 61 - * considered part of another segment, since that might 62 - * change with the bounce page. 63 - */ 64 - high = page_to_pfn(bv->bv_page) > q->bounce_pfn; 65 - if (high || highprv) 66 - goto new_segment; 67 - if (cluster) { 68 - if (seg_size + bv->bv_len > q->max_segment_size) 58 + for_each_bio(bio) { 59 + bio_for_each_segment(bv, bio, i) { 60 + /* 61 + * the trick here is making sure that a high page is 62 + * never considered part of another segment, since that 63 + * might change with the bounce page. 64 + */ 65 + high = page_to_pfn(bv->bv_page) > q->bounce_pfn; 66 + if (high || highprv) 69 67 goto new_segment; 70 - if (!BIOVEC_PHYS_MERGEABLE(bvprv, bv)) 71 - goto new_segment; 72 - if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv)) 73 - goto new_segment; 68 + if (cluster) { 69 + if (seg_size + bv->bv_len > q->max_segment_size) 70 + goto new_segment; 71 + if (!BIOVEC_PHYS_MERGEABLE(bvprv, bv)) 72 + goto new_segment; 73 + if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv)) 74 + goto new_segment; 74 75 75 - seg_size += bv->bv_len; 76 - bvprv = bv; 77 - continue; 78 - } 76 + seg_size += bv->bv_len; 77 + bvprv = bv; 78 + continue; 79 + } 79 80 new_segment: 80 - if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size) 81 - rq->bio->bi_seg_front_size = seg_size; 81 + if (nr_phys_segs == 1 && seg_size > 82 + fbio->bi_seg_front_size) 83 + fbio->bi_seg_front_size = seg_size; 82 84 83 - nr_phys_segs++; 84 - bvprv = bv; 85 - seg_size = bv->bv_len; 86 - highprv = high; 85 + nr_phys_segs++; 86 + bvprv = bv; 87 + seg_size = bv->bv_len; 88 + highprv = high; 89 + } 87 90 } 88 91 89 - if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size) 92 + if (seg_size_ptr) 93 + *seg_size_ptr = seg_size; 94 + 95 + return nr_phys_segs; 96 + } 97 + 98 + void blk_recalc_rq_segments(struct request *rq) 99 + { 100 + unsigned int seg_size = 0, phys_segs; 101 + 102 + phys_segs = __blk_recalc_rq_segments(rq->q, rq->bio, &seg_size); 103 + 104 + if (phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size) 90 105 rq->bio->bi_seg_front_size = seg_size; 91 106 if (seg_size > rq->biotail->bi_seg_back_size) 92 107 rq->biotail->bi_seg_back_size = seg_size; 93 108 94 - rq->nr_phys_segments = nr_phys_segs; 109 + rq->nr_phys_segments = phys_segs; 95 110 } 96 111 97 112 void blk_recount_segments(struct request_queue *q, struct bio *bio) 98 113 { 99 - struct request rq; 100 114 struct bio *nxt = bio->bi_next; 101 - rq.q = q; 102 - rq.bio = rq.biotail = bio; 115 + 103 116 bio->bi_next = NULL; 104 - blk_recalc_rq_segments(&rq); 117 + bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, NULL); 105 118 bio->bi_next = nxt; 106 - bio->bi_phys_segments = rq.nr_phys_segments; 107 119 bio->bi_flags |= (1 << BIO_SEG_VALID); 108 120 } 109 121 EXPORT_SYMBOL(blk_recount_segments);
+16
block/genhd.c
··· 256 256 } 257 257 #endif /* CONFIG_PROC_FS */ 258 258 259 + /** 260 + * register_blkdev - register a new block device 261 + * 262 + * @major: the requested major device number [1..255]. If @major=0, try to 263 + * allocate any unused major number. 264 + * @name: the name of the new block device as a zero terminated string 265 + * 266 + * The @name must be unique within the system. 267 + * 268 + * The return value depends on the @major input parameter. 269 + * - if a major device number was requested in range [1..255] then the 270 + * function returns zero on success, or a negative error code 271 + * - if any unused major number was requested with @major=0 parameter 272 + * then the return value is the allocated major number in range 273 + * [1..255] or a negative error code otherwise 274 + */ 259 275 int register_blkdev(unsigned int major, const char *name) 260 276 { 261 277 struct blk_major_name **n, *p;
+7 -3
drivers/block/cciss.c
··· 3611 3611 schedule_timeout_uninterruptible(30*HZ); 3612 3612 3613 3613 /* Now try to get the controller to respond to a no-op */ 3614 - for (i=0; i<12; i++) { 3614 + for (i=0; i<30; i++) { 3615 3615 if (cciss_noop(pdev) == 0) 3616 3616 break; 3617 - else 3618 - printk("cciss: no-op failed%s\n", (i < 11 ? "; re-trying" : "")); 3617 + 3618 + schedule_timeout_uninterruptible(HZ); 3619 + } 3620 + if (i == 30) { 3621 + printk(KERN_ERR "cciss: controller seems dead\n"); 3622 + return -EBUSY; 3619 3623 } 3620 3624 } 3621 3625
+15 -15
drivers/block/xen-blkfront.c
··· 40 40 #include <linux/hdreg.h> 41 41 #include <linux/cdrom.h> 42 42 #include <linux/module.h> 43 + #include <linux/scatterlist.h> 43 44 44 45 #include <xen/xenbus.h> 45 46 #include <xen/grant_table.h> ··· 83 82 enum blkif_state connected; 84 83 int ring_ref; 85 84 struct blkif_front_ring ring; 85 + struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 86 86 unsigned int evtchn, irq; 87 87 struct request_queue *rq; 88 88 struct work_struct work; ··· 206 204 struct blkfront_info *info = req->rq_disk->private_data; 207 205 unsigned long buffer_mfn; 208 206 struct blkif_request *ring_req; 209 - struct req_iterator iter; 210 - struct bio_vec *bvec; 211 207 unsigned long id; 212 208 unsigned int fsect, lsect; 213 - int ref; 209 + int i, ref; 214 210 grant_ref_t gref_head; 211 + struct scatterlist *sg; 215 212 216 213 if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) 217 214 return 1; ··· 239 238 if (blk_barrier_rq(req)) 240 239 ring_req->operation = BLKIF_OP_WRITE_BARRIER; 241 240 242 - ring_req->nr_segments = 0; 243 - rq_for_each_segment(bvec, req, iter) { 244 - BUG_ON(ring_req->nr_segments == BLKIF_MAX_SEGMENTS_PER_REQUEST); 245 - buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); 246 - fsect = bvec->bv_offset >> 9; 247 - lsect = fsect + (bvec->bv_len >> 9) - 1; 241 + ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg); 242 + BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST); 243 + 244 + for_each_sg(info->sg, sg, ring_req->nr_segments, i) { 245 + buffer_mfn = pfn_to_mfn(page_to_pfn(sg_page(sg))); 246 + fsect = sg->offset >> 9; 247 + lsect = fsect + (sg->length >> 9) - 1; 248 248 /* install a grant reference. */ 249 249 ref = gnttab_claim_grant_reference(&gref_head); 250 250 BUG_ON(ref == -ENOSPC); ··· 256 254 buffer_mfn, 257 255 rq_data_dir(req) ); 258 256 259 - info->shadow[id].frame[ring_req->nr_segments] = 260 - mfn_to_pfn(buffer_mfn); 261 - 262 - ring_req->seg[ring_req->nr_segments] = 257 + info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn); 258 + ring_req->seg[i] = 263 259 (struct blkif_request_segment) { 264 260 .gref = ref, 265 261 .first_sect = fsect, 266 262 .last_sect = lsect }; 267 - 268 - ring_req->nr_segments++; 269 263 } 270 264 271 265 info->ring.req_prod_pvt++; ··· 619 621 } 620 622 SHARED_RING_INIT(sring); 621 623 FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); 624 + 625 + sg_init_table(info->sg, BLKIF_MAX_SEGMENTS_PER_REQUEST); 622 626 623 627 err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring)); 624 628 if (err < 0) {
+1 -1
fs/bio.c
··· 302 302 struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs) 303 303 { 304 304 struct bio *bio = NULL; 305 - void *p; 305 + void *uninitialized_var(p); 306 306 307 307 if (bs) { 308 308 p = mempool_alloc(bs->bio_pool, gfp_mask);
+2
include/linux/blkdev.h
··· 708 708 }; 709 709 710 710 /* This should not be used directly - use rq_for_each_segment */ 711 + #define for_each_bio(_bio) \ 712 + for (; _bio; _bio = _bio->bi_next) 711 713 #define __rq_for_each_bio(_bio, rq) \ 712 714 if ((rq->bio)) \ 713 715 for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)