Commit bdf7cf1c83872a0586ce4c4da6889103cc36dbd3
Exists in
master
and in
4 other branches
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
Showing 5 changed files Side-by-side Diff
block/blk-core.c
... | ... | @@ -345,6 +345,7 @@ |
345 | 345 | { |
346 | 346 | kobject_put(&q->kobj); |
347 | 347 | } |
348 | +EXPORT_SYMBOL(blk_put_queue); | |
348 | 349 | |
349 | 350 | /* |
350 | 351 | * Note: If a driver supplied the queue lock, it should not zap that lock |
... | ... | @@ -566,6 +567,7 @@ |
566 | 567 | |
567 | 568 | return 1; |
568 | 569 | } |
570 | +EXPORT_SYMBOL(blk_get_queue); | |
569 | 571 | |
570 | 572 | static inline void blk_free_request(struct request_queue *q, struct request *rq) |
571 | 573 | { |
... | ... | @@ -1130,7 +1132,6 @@ |
1130 | 1132 | struct request *req, struct bio *bio) |
1131 | 1133 | { |
1132 | 1134 | const int ff = bio->bi_rw & REQ_FAILFAST_MASK; |
1133 | - sector_t sector; | |
1134 | 1135 | |
1135 | 1136 | if (!ll_front_merge_fn(q, req, bio)) |
1136 | 1137 | return false; |
... | ... | @@ -1139,8 +1140,6 @@ |
1139 | 1140 | |
1140 | 1141 | if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) |
1141 | 1142 | blk_rq_set_mixed_merge(req); |
1142 | - | |
1143 | - sector = bio->bi_sector; | |
1144 | 1143 | |
1145 | 1144 | bio->bi_next = req->bio; |
1146 | 1145 | req->bio = bio; |
block/genhd.c
drivers/block/brd.c
... | ... | @@ -35,10 +35,6 @@ |
35 | 35 | */ |
36 | 36 | struct brd_device { |
37 | 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 | 39 | struct request_queue *brd_queue; |
44 | 40 | struct gendisk *brd_disk; |
45 | 41 | |
46 | 42 | |
... | ... | @@ -440,11 +436,11 @@ |
440 | 436 | int rd_size = CONFIG_BLK_DEV_RAM_SIZE; |
441 | 437 | static int max_part; |
442 | 438 | static int part_shift; |
443 | -module_param(rd_nr, int, 0); | |
439 | +module_param(rd_nr, int, S_IRUGO); | |
444 | 440 | MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); |
445 | -module_param(rd_size, int, 0); | |
441 | +module_param(rd_size, int, S_IRUGO); | |
446 | 442 | MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); |
447 | -module_param(max_part, int, 0); | |
443 | +module_param(max_part, int, S_IRUGO); | |
448 | 444 | MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); |
449 | 445 | MODULE_LICENSE("GPL"); |
450 | 446 | MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); |
... | ... | @@ -552,7 +548,7 @@ |
552 | 548 | struct kobject *kobj; |
553 | 549 | |
554 | 550 | mutex_lock(&brd_devices_mutex); |
555 | - brd = brd_init_one(dev & MINORMASK); | |
551 | + brd = brd_init_one(MINOR(dev) >> part_shift); | |
556 | 552 | kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM); |
557 | 553 | mutex_unlock(&brd_devices_mutex); |
558 | 554 | |
559 | 555 | |
560 | 556 | |
561 | 557 | |
562 | 558 | |
... | ... | @@ -575,25 +571,39 @@ |
575 | 571 | * |
576 | 572 | * (1) if rd_nr is specified, create that many upfront, and this |
577 | 573 | * also becomes a hard limit. |
578 | - * (2) if rd_nr is not specified, create 1 rd device on module | |
579 | - * load, user can further extend brd device by create dev node | |
580 | - * themselves and have kernel automatically instantiate actual | |
581 | - * device on-demand. | |
574 | + * (2) if rd_nr is not specified, create CONFIG_BLK_DEV_RAM_COUNT | |
575 | + * (default 16) rd device on module load, user can further | |
576 | + * extend brd device by create dev node themselves and have | |
577 | + * kernel automatically instantiate actual device on-demand. | |
582 | 578 | */ |
583 | 579 | |
584 | 580 | part_shift = 0; |
585 | - if (max_part > 0) | |
581 | + if (max_part > 0) { | |
586 | 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 | 598 | if (rd_nr > 1UL << (MINORBITS - part_shift)) |
589 | 599 | return -EINVAL; |
590 | 600 | |
591 | 601 | if (rd_nr) { |
592 | 602 | nr = rd_nr; |
593 | - range = rd_nr; | |
603 | + range = rd_nr << part_shift; | |
594 | 604 | } else { |
595 | 605 | nr = CONFIG_BLK_DEV_RAM_COUNT; |
596 | - range = 1UL << (MINORBITS - part_shift); | |
606 | + range = 1UL << MINORBITS; | |
597 | 607 | } |
598 | 608 | |
599 | 609 | if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) |
... | ... | @@ -632,7 +642,7 @@ |
632 | 642 | unsigned long range; |
633 | 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 | 647 | list_for_each_entry_safe(brd, next, &brd_devices, brd_list) |
638 | 648 | brd_del_one(brd); |
drivers/block/loop.c
... | ... | @@ -1540,9 +1540,9 @@ |
1540 | 1540 | * And now the modules code and kernel interface. |
1541 | 1541 | */ |
1542 | 1542 | static int max_loop; |
1543 | -module_param(max_loop, int, 0); | |
1543 | +module_param(max_loop, int, S_IRUGO); | |
1544 | 1544 | MODULE_PARM_DESC(max_loop, "Maximum number of loop devices"); |
1545 | -module_param(max_part, int, 0); | |
1545 | +module_param(max_part, int, S_IRUGO); | |
1546 | 1546 | MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device"); |
1547 | 1547 | MODULE_LICENSE("GPL"); |
1548 | 1548 | MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); |
1549 | 1549 | |
... | ... | @@ -1688,8 +1688,19 @@ |
1688 | 1688 | */ |
1689 | 1689 | |
1690 | 1690 | part_shift = 0; |
1691 | - if (max_part > 0) | |
1691 | + if (max_part > 0) { | |
1692 | 1692 | part_shift = fls(max_part); |
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 | + } | |
1693 | 1704 | |
1694 | 1705 | if ((1UL << part_shift) > DISK_MAX_PARTS) |
1695 | 1706 | return -EINVAL; |
fs/partitions/check.c
... | ... | @@ -256,10 +256,12 @@ |
256 | 256 | { |
257 | 257 | struct hd_struct *p = dev_to_part(dev); |
258 | 258 | struct gendisk *disk = dev_to_disk(dev); |
259 | + unsigned int alignment = 0; | |
259 | 260 | |
260 | - return sprintf(buf, "%u\n", | |
261 | - queue_limit_discard_alignment(&disk->queue->limits, | |
262 | - p->start_sect)); | |
261 | + if (disk->queue) | |
262 | + alignment = queue_limit_discard_alignment(&disk->queue->limits, | |
263 | + p->start_sect); | |
264 | + return sprintf(buf, "%u\n", alignment); | |
263 | 265 | } |
264 | 266 | |
265 | 267 | ssize_t part_stat_show(struct device *dev, |