aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-map.c2
-rw-r--r--block/blk-merge.c6
-rw-r--r--block/blk-settings.c27
-rw-r--r--block/blk-sysfs.c2
-rw-r--r--block/cfq-iosched.c4
-rw-r--r--block/genhd.c6
-rw-r--r--block/scsi_ioctl.c34
7 files changed, 41 insertions, 40 deletions
diff --git a/block/blk-map.c b/block/blk-map.c
index ade0a08c9099..267a57b77099 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -205,6 +205,8 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
205 unaligned = 1; 205 unaligned = 1;
206 break; 206 break;
207 } 207 }
208 if (!iov[i].iov_len)
209 return -EINVAL;
208 } 210 }
209 211
210 if (unaligned || (q->dma_pad_mask & len) || map_data) 212 if (unaligned || (q->dma_pad_mask & len) || map_data)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index eafc94f68d79..c24bf43d51f0 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -21,7 +21,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
21 return 0; 21 return 0;
22 22
23 fbio = bio; 23 fbio = bio;
24 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 24 cluster = blk_queue_cluster(q);
25 seg_size = 0; 25 seg_size = 0;
26 nr_phys_segs = 0; 26 nr_phys_segs = 0;
27 for_each_bio(bio) { 27 for_each_bio(bio) {
@@ -87,7 +87,7 @@ EXPORT_SYMBOL(blk_recount_segments);
87static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, 87static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
88 struct bio *nxt) 88 struct bio *nxt)
89{ 89{
90 if (!test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags)) 90 if (!blk_queue_cluster(q))
91 return 0; 91 return 0;
92 92
93 if (bio->bi_seg_back_size + nxt->bi_seg_front_size > 93 if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
@@ -123,7 +123,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
123 int nsegs, cluster; 123 int nsegs, cluster;
124 124
125 nsegs = 0; 125 nsegs = 0;
126 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 126 cluster = blk_queue_cluster(q);
127 127
128 /* 128 /*
129 * for each bio in rq 129 * for each bio in rq
diff --git a/block/blk-settings.c b/block/blk-settings.c
index a234f4bf1d6f..ea9430d3d7d2 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -125,7 +125,7 @@ void blk_set_default_limits(struct queue_limits *lim)
125 lim->alignment_offset = 0; 125 lim->alignment_offset = 0;
126 lim->io_opt = 0; 126 lim->io_opt = 0;
127 lim->misaligned = 0; 127 lim->misaligned = 0;
128 lim->no_cluster = 0; 128 lim->cluster = 1;
129} 129}
130EXPORT_SYMBOL(blk_set_default_limits); 130EXPORT_SYMBOL(blk_set_default_limits);
131 131
@@ -343,7 +343,7 @@ EXPORT_SYMBOL(blk_queue_logical_block_size);
343 * hardware can operate on without reverting to read-modify-write 343 * hardware can operate on without reverting to read-modify-write
344 * operations. 344 * operations.
345 */ 345 */
346void blk_queue_physical_block_size(struct request_queue *q, unsigned short size) 346void blk_queue_physical_block_size(struct request_queue *q, unsigned int size)
347{ 347{
348 q->limits.physical_block_size = size; 348 q->limits.physical_block_size = size;
349 349
@@ -468,15 +468,6 @@ EXPORT_SYMBOL(blk_queue_io_opt);
468void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) 468void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
469{ 469{
470 blk_stack_limits(&t->limits, &b->limits, 0); 470 blk_stack_limits(&t->limits, &b->limits, 0);
471
472 if (!t->queue_lock)
473 WARN_ON_ONCE(1);
474 else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
475 unsigned long flags;
476 spin_lock_irqsave(t->queue_lock, flags);
477 queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
478 spin_unlock_irqrestore(t->queue_lock, flags);
479 }
480} 471}
481EXPORT_SYMBOL(blk_queue_stack_limits); 472EXPORT_SYMBOL(blk_queue_stack_limits);
482 473
@@ -547,7 +538,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
547 t->io_min = max(t->io_min, b->io_min); 538 t->io_min = max(t->io_min, b->io_min);
548 t->io_opt = lcm(t->io_opt, b->io_opt); 539 t->io_opt = lcm(t->io_opt, b->io_opt);
549 540
550 t->no_cluster |= b->no_cluster; 541 t->cluster &= b->cluster;
551 t->discard_zeroes_data &= b->discard_zeroes_data; 542 t->discard_zeroes_data &= b->discard_zeroes_data;
552 543
553 /* Physical block size a multiple of the logical block size? */ 544 /* Physical block size a multiple of the logical block size? */
@@ -643,7 +634,6 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
643 sector_t offset) 634 sector_t offset)
644{ 635{
645 struct request_queue *t = disk->queue; 636 struct request_queue *t = disk->queue;
646 struct request_queue *b = bdev_get_queue(bdev);
647 637
648 if (bdev_stack_limits(&t->limits, bdev, offset >> 9) < 0) { 638 if (bdev_stack_limits(&t->limits, bdev, offset >> 9) < 0) {
649 char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE]; 639 char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];
@@ -654,17 +644,6 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
654 printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n", 644 printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
655 top, bottom); 645 top, bottom);
656 } 646 }
657
658 if (!t->queue_lock)
659 WARN_ON_ONCE(1);
660 else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
661 unsigned long flags;
662
663 spin_lock_irqsave(t->queue_lock, flags);
664 if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags))
665 queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
666 spin_unlock_irqrestore(t->queue_lock, flags);
667 }
668} 647}
669EXPORT_SYMBOL(disk_stack_limits); 648EXPORT_SYMBOL(disk_stack_limits);
670 649
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 0749b89c6885..a26c930db346 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -114,7 +114,7 @@ static ssize_t queue_max_segments_show(struct request_queue *q, char *page)
114 114
115static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page) 115static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page)
116{ 116{
117 if (test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags)) 117 if (blk_queue_cluster(q))
118 return queue_var_show(queue_max_segment_size(q), (page)); 118 return queue_var_show(queue_max_segment_size(q), (page));
119 119
120 return queue_var_show(PAGE_CACHE_SIZE, (page)); 120 return queue_var_show(PAGE_CACHE_SIZE, (page));
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 9eba291eb6fd..909479cfa0af 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3402,6 +3402,10 @@ static bool cfq_should_wait_busy(struct cfq_data *cfqd, struct cfq_queue *cfqq)
3402{ 3402{
3403 struct cfq_io_context *cic = cfqd->active_cic; 3403 struct cfq_io_context *cic = cfqd->active_cic;
3404 3404
3405 /* If the queue already has requests, don't wait */
3406 if (!RB_EMPTY_ROOT(&cfqq->sort_list))
3407 return false;
3408
3405 /* If there are other queues in the group, don't wait */ 3409 /* If there are other queues in the group, don't wait */
3406 if (cfqq->cfqg->nr_cfqq > 1) 3410 if (cfqq->cfqg->nr_cfqq > 1)
3407 return false; 3411 return false;
diff --git a/block/genhd.c b/block/genhd.c
index 59a2db6fecef..315afd2f2088 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -541,13 +541,15 @@ void add_disk(struct gendisk *disk)
541 disk->major = MAJOR(devt); 541 disk->major = MAJOR(devt);
542 disk->first_minor = MINOR(devt); 542 disk->first_minor = MINOR(devt);
543 543
544 /* Register BDI before referencing it from bdev */
545 bdi = &disk->queue->backing_dev_info;
546 bdi_register_dev(bdi, disk_devt(disk));
547
544 blk_register_region(disk_devt(disk), disk->minors, NULL, 548 blk_register_region(disk_devt(disk), disk->minors, NULL,
545 exact_match, exact_lock, disk); 549 exact_match, exact_lock, disk);
546 register_disk(disk); 550 register_disk(disk);
547 blk_register_queue(disk); 551 blk_register_queue(disk);
548 552
549 bdi = &disk->queue->backing_dev_info;
550 bdi_register_dev(bdi, disk_devt(disk));
551 retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, 553 retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,
552 "bdi"); 554 "bdi");
553 WARN_ON(retval); 555 WARN_ON(retval);
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index a8b5a10eb5b0..4f4230b79bb6 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -321,33 +321,47 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
321 if (hdr->iovec_count) { 321 if (hdr->iovec_count) {
322 const int size = sizeof(struct sg_iovec) * hdr->iovec_count; 322 const int size = sizeof(struct sg_iovec) * hdr->iovec_count;
323 size_t iov_data_len; 323 size_t iov_data_len;
324 struct sg_iovec *iov; 324 struct sg_iovec *sg_iov;
325 struct iovec *iov;
326 int i;
325 327
326 iov = kmalloc(size, GFP_KERNEL); 328 sg_iov = kmalloc(size, GFP_KERNEL);
327 if (!iov) { 329 if (!sg_iov) {
328 ret = -ENOMEM; 330 ret = -ENOMEM;
329 goto out; 331 goto out;
330 } 332 }
331 333
332 if (copy_from_user(iov, hdr->dxferp, size)) { 334 if (copy_from_user(sg_iov, hdr->dxferp, size)) {
333 kfree(iov); 335 kfree(sg_iov);
334 ret = -EFAULT; 336 ret = -EFAULT;
335 goto out; 337 goto out;
336 } 338 }
337 339
340 /*
341 * Sum up the vecs, making sure they don't overflow
342 */
343 iov = (struct iovec *) sg_iov;
344 iov_data_len = 0;
345 for (i = 0; i < hdr->iovec_count; i++) {
346 if (iov_data_len + iov[i].iov_len < iov_data_len) {
347 kfree(sg_iov);
348 ret = -EINVAL;
349 goto out;
350 }
351 iov_data_len += iov[i].iov_len;
352 }
353
338 /* SG_IO howto says that the shorter of the two wins */ 354 /* SG_IO howto says that the shorter of the two wins */
339 iov_data_len = iov_length((struct iovec *)iov,
340 hdr->iovec_count);
341 if (hdr->dxfer_len < iov_data_len) { 355 if (hdr->dxfer_len < iov_data_len) {
342 hdr->iovec_count = iov_shorten((struct iovec *)iov, 356 hdr->iovec_count = iov_shorten(iov,
343 hdr->iovec_count, 357 hdr->iovec_count,
344 hdr->dxfer_len); 358 hdr->dxfer_len);
345 iov_data_len = hdr->dxfer_len; 359 iov_data_len = hdr->dxfer_len;
346 } 360 }
347 361
348 ret = blk_rq_map_user_iov(q, rq, NULL, iov, hdr->iovec_count, 362 ret = blk_rq_map_user_iov(q, rq, NULL, sg_iov, hdr->iovec_count,
349 iov_data_len, GFP_KERNEL); 363 iov_data_len, GFP_KERNEL);
350 kfree(iov); 364 kfree(sg_iov);
351 } else if (hdr->dxfer_len) 365 } else if (hdr->dxfer_len)
352 ret = blk_rq_map_user(q, rq, NULL, hdr->dxferp, hdr->dxfer_len, 366 ret = blk_rq_map_user(q, rq, NULL, hdr->dxferp, hdr->dxfer_len,
353 GFP_KERNEL); 367 GFP_KERNEL);