block: remove support for bio remapping from ->make_request
[linux-2.6-block.git] / drivers / block / loop.c
index c59a672a3de0d6571fbe173a8328d12a1e03c86b..8360239d553c7ed69a6df49a0c420b32d45f119b 100644 (file)
@@ -514,7 +514,7 @@ static struct bio *loop_get_bio(struct loop_device *lo)
        return bio_list_pop(&lo->lo_bio_list);
 }
 
-static int loop_make_request(struct request_queue *q, struct bio *old_bio)
+static void loop_make_request(struct request_queue *q, struct bio *old_bio)
 {
        struct loop_device *lo = q->queuedata;
        int rw = bio_rw(old_bio);
@@ -532,12 +532,11 @@ static int loop_make_request(struct request_queue *q, struct bio *old_bio)
        loop_add_bio(lo, old_bio);
        wake_up(&lo->lo_event);
        spin_unlock_irq(&lo->lo_lock);
-       return 0;
+       return;
 
 out:
        spin_unlock_irq(&lo->lo_lock);
        bio_io_error(old_bio);
-       return 0;
 }
 
 struct switch_request {
@@ -1540,9 +1539,9 @@ static const struct block_device_operations lo_fops = {
  * And now the modules code and kernel interface.
  */
 static int max_loop;
-module_param(max_loop, int, 0);
+module_param(max_loop, int, S_IRUGO);
 MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
-module_param(max_part, int, 0);
+module_param(max_part, int, S_IRUGO);
 MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
@@ -1688,9 +1687,20 @@ static int __init loop_init(void)
         */
 
        part_shift = 0;
-       if (max_part > 0)
+       if (max_part > 0) {
                part_shift = fls(max_part);
 
+               /*
+                * Adjust max_part according to part_shift as it is exported
+                * to user space so that user can decide correct minor number
+                * if [s]he want to create more devices.
+                *
+                * Note that -1 is required because partition 0 is reserved
+                * for the whole disk.
+                */
+               max_part = (1UL << part_shift) - 1;
+       }
+
        if ((1UL << part_shift) > DISK_MAX_PARTS)
                return -EINVAL;