aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-27 13:24:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-27 13:24:40 -0400
commitbdf7cf1c83872a0586ce4c4da6889103cc36dbd3 (patch)
tree9311bbcf8b9ffbe7207eba5cca557275f8151ae7
parent40efeb4d0bb1993c3c10baff9b7d86839f99171e (diff)
parentac04fee0b5c55bbac0858727a4154110b55d3f5a (diff)
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
* 'for-linus' of git://git.kernel.dk/linux-2.6-block: loop: export module parameters block: export blk_{get,put}_queue() block: remove unused variable in bio_attempt_front_merge() block: always allocate genhd->ev if check_events is implemented brd: export module parameters brd: fix comment on initial device creation brd: handle on-demand devices correctly brd: limit 'max_part' module param to DISK_MAX_PARTS brd: get rid of unused members from struct brd_device block: fix oops on !disk->queue and sysfs discard alignment display
-rw-r--r--block/blk-core.c5
-rw-r--r--block/genhd.c2
-rw-r--r--drivers/block/brd.c42
-rw-r--r--drivers/block/loop.c17
-rw-r--r--fs/partitions/check.c8
5 files changed, 48 insertions, 26 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index c8303e9d919d..d2f8f4049abd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -345,6 +345,7 @@ void blk_put_queue(struct request_queue *q)
345{ 345{
346 kobject_put(&q->kobj); 346 kobject_put(&q->kobj);
347} 347}
348EXPORT_SYMBOL(blk_put_queue);
348 349
349/* 350/*
350 * Note: If a driver supplied the queue lock, it should not zap that lock 351 * Note: If a driver supplied the queue lock, it should not zap that lock
@@ -566,6 +567,7 @@ int blk_get_queue(struct request_queue *q)
566 567
567 return 1; 568 return 1;
568} 569}
570EXPORT_SYMBOL(blk_get_queue);
569 571
570static inline void blk_free_request(struct request_queue *q, struct request *rq) 572static inline void blk_free_request(struct request_queue *q, struct request *rq)
571{ 573{
@@ -1130,7 +1132,6 @@ static bool bio_attempt_front_merge(struct request_queue *q,
1130 struct request *req, struct bio *bio) 1132 struct request *req, struct bio *bio)
1131{ 1133{
1132 const int ff = bio->bi_rw & REQ_FAILFAST_MASK; 1134 const int ff = bio->bi_rw & REQ_FAILFAST_MASK;
1133 sector_t sector;
1134 1135
1135 if (!ll_front_merge_fn(q, req, bio)) 1136 if (!ll_front_merge_fn(q, req, bio))
1136 return false; 1137 return false;
@@ -1140,8 +1141,6 @@ static bool bio_attempt_front_merge(struct request_queue *q,
1140 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) 1141 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
1141 blk_rq_set_mixed_merge(req); 1142 blk_rq_set_mixed_merge(req);
1142 1143
1143 sector = bio->bi_sector;
1144
1145 bio->bi_next = req->bio; 1144 bio->bi_next = req->bio;
1146 req->bio = bio; 1145 req->bio = bio;
1147 1146
diff --git a/block/genhd.c b/block/genhd.c
index 2dd988723d73..95822ae25cfe 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1728,7 +1728,7 @@ static void disk_add_events(struct gendisk *disk)
1728{ 1728{
1729 struct disk_events *ev; 1729 struct disk_events *ev;
1730 1730
1731 if (!disk->fops->check_events || !(disk->events | disk->async_events)) 1731 if (!disk->fops->check_events)
1732 return; 1732 return;
1733 1733
1734 ev = kzalloc(sizeof(*ev), GFP_KERNEL); 1734 ev = kzalloc(sizeof(*ev), GFP_KERNEL);
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index b7f51e4594f8..dba1c32e1ddf 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -35,10 +35,6 @@
35 */ 35 */
36struct brd_device { 36struct brd_device {
37 int brd_number; 37 int brd_number;
38 int brd_refcnt;
39 loff_t brd_offset;
40 loff_t brd_sizelimit;
41 unsigned brd_blocksize;
42 38
43 struct request_queue *brd_queue; 39 struct request_queue *brd_queue;
44 struct gendisk *brd_disk; 40 struct gendisk *brd_disk;
@@ -440,11 +436,11 @@ static int rd_nr;
440int rd_size = CONFIG_BLK_DEV_RAM_SIZE; 436int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
441static int max_part; 437static int max_part;
442static int part_shift; 438static int part_shift;
443module_param(rd_nr, int, 0); 439module_param(rd_nr, int, S_IRUGO);
444MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); 440MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
445module_param(rd_size, int, 0); 441module_param(rd_size, int, S_IRUGO);
446MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); 442MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
447module_param(max_part, int, 0); 443module_param(max_part, int, S_IRUGO);
448MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); 444MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
449MODULE_LICENSE("GPL"); 445MODULE_LICENSE("GPL");
450MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); 446MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
@@ -552,7 +548,7 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
552 struct kobject *kobj; 548 struct kobject *kobj;
553 549
554 mutex_lock(&brd_devices_mutex); 550 mutex_lock(&brd_devices_mutex);
555 brd = brd_init_one(dev & MINORMASK); 551 brd = brd_init_one(MINOR(dev) >> part_shift);
556 kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM); 552 kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM);
557 mutex_unlock(&brd_devices_mutex); 553 mutex_unlock(&brd_devices_mutex);
558 554
@@ -575,25 +571,39 @@ static int __init brd_init(void)
575 * 571 *
576 * (1) if rd_nr is specified, create that many upfront, and this 572 * (1) if rd_nr is specified, create that many upfront, and this
577 * also becomes a hard limit. 573 * also becomes a hard limit.
578 * (2) if rd_nr is not specified, create 1 rd device on module 574 * (2) if rd_nr is not specified, create CONFIG_BLK_DEV_RAM_COUNT
579 * load, user can further extend brd device by create dev node 575 * (default 16) rd device on module load, user can further
580 * themselves and have kernel automatically instantiate actual 576 * extend brd device by create dev node themselves and have
581 * device on-demand. 577 * kernel automatically instantiate actual device on-demand.
582 */ 578 */
583 579
584 part_shift = 0; 580 part_shift = 0;
585 if (max_part > 0) 581 if (max_part > 0) {
586 part_shift = fls(max_part); 582 part_shift = fls(max_part);
587 583
584 /*
585 * Adjust max_part according to part_shift as it is exported
586 * to user space so that user can decide correct minor number
587 * if [s]he want to create more devices.
588 *
589 * Note that -1 is required because partition 0 is reserved
590 * for the whole disk.
591 */
592 max_part = (1UL << part_shift) - 1;
593 }
594
595 if ((1UL << part_shift) > DISK_MAX_PARTS)
596 return -EINVAL;
597
588 if (rd_nr > 1UL << (MINORBITS - part_shift)) 598 if (rd_nr > 1UL << (MINORBITS - part_shift))
589 return -EINVAL; 599 return -EINVAL;
590 600
591 if (rd_nr) { 601 if (rd_nr) {
592 nr = rd_nr; 602 nr = rd_nr;
593 range = rd_nr; 603 range = rd_nr << part_shift;
594 } else { 604 } else {
595 nr = CONFIG_BLK_DEV_RAM_COUNT; 605 nr = CONFIG_BLK_DEV_RAM_COUNT;
596 range = 1UL << (MINORBITS - part_shift); 606 range = 1UL << MINORBITS;
597 } 607 }
598 608
599 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) 609 if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
@@ -632,7 +642,7 @@ static void __exit brd_exit(void)
632 unsigned long range; 642 unsigned long range;
633 struct brd_device *brd, *next; 643 struct brd_device *brd, *next;
634 644
635 range = rd_nr ? rd_nr : 1UL << (MINORBITS - part_shift); 645 range = rd_nr ? rd_nr << part_shift : 1UL << MINORBITS;
636 646
637 list_for_each_entry_safe(brd, next, &brd_devices, brd_list) 647 list_for_each_entry_safe(brd, next, &brd_devices, brd_list)
638 brd_del_one(brd); 648 brd_del_one(brd);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index c59a672a3de0..76c8da78212b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1540,9 +1540,9 @@ static const struct block_device_operations lo_fops = {
1540 * And now the modules code and kernel interface. 1540 * And now the modules code and kernel interface.
1541 */ 1541 */
1542static int max_loop; 1542static int max_loop;
1543module_param(max_loop, int, 0); 1543module_param(max_loop, int, S_IRUGO);
1544MODULE_PARM_DESC(max_loop, "Maximum number of loop devices"); 1544MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
1545module_param(max_part, int, 0); 1545module_param(max_part, int, S_IRUGO);
1546MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device"); 1546MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
1547MODULE_LICENSE("GPL"); 1547MODULE_LICENSE("GPL");
1548MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); 1548MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
@@ -1688,9 +1688,20 @@ static int __init loop_init(void)
1688 */ 1688 */
1689 1689
1690 part_shift = 0; 1690 part_shift = 0;
1691 if (max_part > 0) 1691 if (max_part > 0) {
1692 part_shift = fls(max_part); 1692 part_shift = fls(max_part);
1693 1693
1694 /*
1695 * Adjust max_part according to part_shift as it is exported
1696 * to user space so that user can decide correct minor number
1697 * if [s]he want to create more devices.
1698 *
1699 * Note that -1 is required because partition 0 is reserved
1700 * for the whole disk.
1701 */
1702 max_part = (1UL << part_shift) - 1;
1703 }
1704
1694 if ((1UL << part_shift) > DISK_MAX_PARTS) 1705 if ((1UL << part_shift) > DISK_MAX_PARTS)
1695 return -EINVAL; 1706 return -EINVAL;
1696 1707
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 8ed4d3433199..f82e762eeca2 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -256,10 +256,12 @@ ssize_t part_discard_alignment_show(struct device *dev,
256{ 256{
257 struct hd_struct *p = dev_to_part(dev); 257 struct hd_struct *p = dev_to_part(dev);
258 struct gendisk *disk = dev_to_disk(dev); 258 struct gendisk *disk = dev_to_disk(dev);
259 unsigned int alignment = 0;
259 260
260 return sprintf(buf, "%u\n", 261 if (disk->queue)
261 queue_limit_discard_alignment(&disk->queue->limits, 262 alignment = queue_limit_discard_alignment(&disk->queue->limits,
262 p->start_sect)); 263 p->start_sect);
264 return sprintf(buf, "%u\n", alignment);
263} 265}
264 266
265ssize_t part_stat_show(struct device *dev, 267ssize_t part_stat_show(struct device *dev,