aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r--drivers/block/loop.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 5c9edf944879..3defc52f060c 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1793,21 +1793,6 @@ static int __init loop_init(void)
1793 struct loop_device *lo; 1793 struct loop_device *lo;
1794 int err; 1794 int err;
1795 1795
1796 /*
1797 * loop module now has a feature to instantiate underlying device
1798 * structure on-demand, provided that there is an access dev node.
1799 * However, this will not work well with user space tool that doesn't
1800 * know about such "feature". In order to not break any existing
1801 * tool, we do the following:
1802 *
1803 * (1) if max_loop is specified, create that many upfront, and this
1804 * also becomes a hard limit.
1805 * (2) if max_loop is not specified, create 8 loop device on module
1806 * load, user can further extend loop device by create dev node
1807 * themselves and have kernel automatically instantiate actual
1808 * device on-demand.
1809 */
1810
1811 err = misc_register(&loop_misc); 1796 err = misc_register(&loop_misc);
1812 if (err < 0) 1797 if (err < 0)
1813 return err; 1798 return err;
@@ -1833,11 +1818,19 @@ static int __init loop_init(void)
1833 if (max_loop > 1UL << (MINORBITS - part_shift)) 1818 if (max_loop > 1UL << (MINORBITS - part_shift))
1834 return -EINVAL; 1819 return -EINVAL;
1835 1820
1821 /*
1822 * If max_loop is specified, create that many devices upfront.
1823 * This also becomes a hard limit. If max_loop is not specified,
1824 * create CONFIG_BLK_DEV_LOOP_MIN_COUNT loop devices at module
1825 * init time. Loop devices can be requested on-demand with the
1826 * /dev/loop-control interface, or be instantiated by accessing
1827 * a 'dead' device node.
1828 */
1836 if (max_loop) { 1829 if (max_loop) {
1837 nr = max_loop; 1830 nr = max_loop;
1838 range = max_loop << part_shift; 1831 range = max_loop << part_shift;
1839 } else { 1832 } else {
1840 nr = 8; 1833 nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
1841 range = 1UL << MINORBITS; 1834 range = 1UL << MINORBITS;
1842 } 1835 }
1843 1836
@@ -1847,7 +1840,7 @@ static int __init loop_init(void)
1847 blk_register_region(MKDEV(LOOP_MAJOR, 0), range, 1840 blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
1848 THIS_MODULE, loop_probe, NULL, NULL); 1841 THIS_MODULE, loop_probe, NULL, NULL);
1849 1842
1850 /* pre-create number devices of devices given by config or max_loop */ 1843 /* pre-create number of devices given by config or max_loop */
1851 mutex_lock(&loop_index_mutex); 1844 mutex_lock(&loop_index_mutex);
1852 for (i = 0; i < nr; i++) 1845 for (i = 0; i < nr; i++)
1853 loop_add(&lo, i); 1846 loop_add(&lo, i);