~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/block/loop.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
540
540
        return 0;
541
541
}
542
542
 
543
 
/*
544
 
 * kick off io on the underlying address space
545
 
 */
546
 
static void loop_unplug(struct request_queue *q)
547
 
{
548
 
        struct loop_device *lo = q->queuedata;
549
 
 
550
 
        queue_flag_clear_unlocked(QUEUE_FLAG_PLUGGED, q);
551
 
        blk_run_address_space(lo->lo_backing_file->f_mapping);
552
 
}
553
 
 
554
543
struct switch_request {
555
544
        struct file *file;
556
545
        struct completion wait;
917
906
         */
918
907
        blk_queue_make_request(lo->lo_queue, loop_make_request);
919
908
        lo->lo_queue->queuedata = lo;
920
 
        lo->lo_queue->unplug_fn = loop_unplug;
921
909
 
922
910
        if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
923
911
                blk_queue_flush(lo->lo_queue, REQ_FLUSH);
1019
1007
 
1020
1008
        kthread_stop(lo->lo_thread);
1021
1009
 
1022
 
        lo->lo_queue->unplug_fn = NULL;
1023
1010
        lo->lo_backing_file = NULL;
1024
1011
 
1025
1012
        loop_release_xfer(lo);
1553
1540
 * And now the modules code and kernel interface.
1554
1541
 */
1555
1542
static int max_loop;
1556
 
module_param(max_loop, int, 0);
 
1543
module_param(max_loop, int, S_IRUGO);
1557
1544
MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
1558
 
module_param(max_part, int, 0);
 
1545
module_param(max_part, int, S_IRUGO);
1559
1546
MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
1560
1547
MODULE_LICENSE("GPL");
1561
1548
MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
1636
1623
 
1637
1624
static void loop_free(struct loop_device *lo)
1638
1625
{
1639
 
        if (!lo->lo_queue->queue_lock)
1640
 
                lo->lo_queue->queue_lock = &lo->lo_queue->__queue_lock;
1641
 
 
1642
1626
        blk_cleanup_queue(lo->lo_queue);
1643
1627
        put_disk(lo->lo_disk);
1644
1628
        list_del(&lo->lo_list);
1674
1658
        struct kobject *kobj;
1675
1659
 
1676
1660
        mutex_lock(&loop_devices_mutex);
1677
 
        lo = loop_init_one(dev & MINORMASK);
 
1661
        lo = loop_init_one(MINOR(dev) >> part_shift);
1678
1662
        kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM);
1679
1663
        mutex_unlock(&loop_devices_mutex);
1680
1664
 
1704
1688
         */
1705
1689
 
1706
1690
        part_shift = 0;
1707
 
        if (max_part > 0)
 
1691
        if (max_part > 0) {
1708
1692
                part_shift = fls(max_part);
1709
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
 
 
1705
        if ((1UL << part_shift) > DISK_MAX_PARTS)
 
1706
                return -EINVAL;
 
1707
 
1710
1708
        if (max_loop > 1UL << (MINORBITS - part_shift))
1711
1709
                return -EINVAL;
1712
1710
 
1713
1711
        if (max_loop) {
1714
1712
                nr = max_loop;
1715
 
                range = max_loop;
 
1713
                range = max_loop << part_shift;
1716
1714
        } else {
1717
1715
                nr = 8;
1718
 
                range = 1UL << (MINORBITS - part_shift);
 
1716
                range = 1UL << MINORBITS;
1719
1717
        }
1720
1718
 
1721
1719
        if (register_blkdev(LOOP_MAJOR, "loop"))
1754
1752
        unsigned long range;
1755
1753
        struct loop_device *lo, *next;
1756
1754
 
1757
 
        range = max_loop ? max_loop :  1UL << (MINORBITS - part_shift);
 
1755
        range = max_loop ? max_loop << part_shift : 1UL << MINORBITS;
1758
1756
 
1759
1757
        list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
1760
1758
                loop_del_one(lo);