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:
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

+48 -26
+2 -3
block/blk-core.c
··· 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 ··· 567 566 568 567 return 1; 569 568 } 569 + EXPORT_SYMBOL(blk_get_queue); 570 570 571 571 static inline void blk_free_request(struct request_queue *q, struct request *rq) 572 572 { ··· 1132 1130 struct request *req, struct bio *bio) 1133 1131 { 1134 1132 const int ff = bio->bi_rw & REQ_FAILFAST_MASK; 1135 - sector_t sector; 1136 1133 1137 1134 if (!ll_front_merge_fn(q, req, bio)) 1138 1135 return false; ··· 1140 1139 1141 1140 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) 1142 1141 blk_rq_set_mixed_merge(req); 1143 - 1144 - sector = bio->bi_sector; 1145 1142 1146 1143 bio->bi_next = req->bio; 1147 1144 req->bio = bio;
+1 -1
block/genhd.c
··· 1728 1728 { 1729 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 1732 return; 1733 1733 1734 1734 ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+26 -16
drivers/block/brd.c
··· 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; ··· 436 440 int rd_size = CONFIG_BLK_DEV_RAM_SIZE; 437 441 static int max_part; 438 442 static int part_shift; 439 - module_param(rd_nr, int, 0); 443 + module_param(rd_nr, int, S_IRUGO); 440 444 MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); 441 - module_param(rd_size, int, 0); 445 + module_param(rd_size, int, S_IRUGO); 442 446 MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); 443 - module_param(max_part, int, 0); 447 + module_param(max_part, int, S_IRUGO); 444 448 MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); 445 449 MODULE_LICENSE("GPL"); 446 450 MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); ··· 548 552 struct kobject *kobj; 549 553 550 554 mutex_lock(&brd_devices_mutex); 551 - brd = brd_init_one(dev & MINORMASK); 555 + brd = brd_init_one(MINOR(dev) >> part_shift); 552 556 kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM); 553 557 mutex_unlock(&brd_devices_mutex); 554 558 ··· 571 575 * 572 576 * (1) if rd_nr is specified, create that many upfront, and this 573 577 * also becomes a hard limit. 574 - * (2) if rd_nr is not specified, create 1 rd device on module 575 - * load, user can further extend brd device by create dev node 576 - * themselves and have kernel automatically instantiate actual 577 - * device on-demand. 578 + * (2) if rd_nr is not specified, create CONFIG_BLK_DEV_RAM_COUNT 579 + * (default 16) rd device on module load, user can further 580 + * extend brd device by create dev node themselves and have 581 + * kernel automatically instantiate actual device on-demand. 578 582 */ 579 583 580 584 part_shift = 0; 581 - if (max_part > 0) 585 + if (max_part > 0) { 582 586 part_shift = fls(max_part); 587 + 588 + /* 589 + * Adjust max_part according to part_shift as it is exported 590 + * to user space so that user can decide correct minor number 591 + * if [s]he want to create more devices. 592 + * 593 + * Note that -1 is required because partition 0 is reserved 594 + * for the whole disk. 595 + */ 596 + max_part = (1UL << part_shift) - 1; 597 + } 598 + 599 + if ((1UL << part_shift) > DISK_MAX_PARTS) 600 + return -EINVAL; 583 601 584 602 if (rd_nr > 1UL << (MINORBITS - part_shift)) 585 603 return -EINVAL; 586 604 587 605 if (rd_nr) { 588 606 nr = rd_nr; 589 - range = rd_nr; 607 + range = rd_nr << part_shift; 590 608 } else { 591 609 nr = CONFIG_BLK_DEV_RAM_COUNT; 592 - range = 1UL << (MINORBITS - part_shift); 610 + range = 1UL << MINORBITS; 593 611 } 594 612 595 613 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) ··· 642 632 unsigned long range; 643 633 struct brd_device *brd, *next; 644 634 645 - range = rd_nr ? rd_nr : 1UL << (MINORBITS - part_shift); 635 + range = rd_nr ? rd_nr << part_shift : 1UL << MINORBITS; 646 636 647 637 list_for_each_entry_safe(brd, next, &brd_devices, brd_list) 648 638 brd_del_one(brd);
+14 -3
drivers/block/loop.c
··· 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); ··· 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;
+5 -3
fs/partitions/check.c
··· 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,