X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fblock%2Floop.c;h=91ebb007416c185587b22ac08e46993f09fcb7dc;hb=e1ec1b8ccdf0df6000faa8c2d985ca5f94157e5a;hp=e5a051577a5e617008f263b8cb5c9f914e1fe6a7;hpb=8268f5a7415d914fc855a86aa2284ac819dc6b2e;p=linux-2.6 diff --git a/drivers/block/loop.c b/drivers/block/loop.c index e5a051577a..91ebb00741 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -29,7 +29,7 @@ * * Maximum number of loop devices when compiled-in now selectable by passing * max_loop=<1-255> to the kernel on boot. - * Erik I. Bolsø, , Oct 31, 1999 + * Erik I. Bolsø, , Oct 31, 1999 * * Completely rewrite request handling to be make_request_fn style and * non blocking, pushing work to a helper thread. Lots of fixes from @@ -610,7 +610,7 @@ static int loop_thread(void *data) static int loop_switch(struct loop_device *lo, struct file *file) { struct switch_request w; - struct bio *bio = bio_alloc(GFP_KERNEL, 1); + struct bio *bio = bio_alloc(GFP_KERNEL, 0); if (!bio) return -ENOMEM; init_completion(&w.wait); @@ -973,6 +973,10 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) lo->transfer = xfer->transfer; lo->ioctl = xfer->ioctl; + if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) != + (info->lo_flags & LO_FLAGS_AUTOCLEAR)) + lo->lo_flags ^= LO_FLAGS_AUTOCLEAR; + lo->lo_encrypt_key_size = info->lo_encrypt_key_size; lo->lo_init[0] = info->lo_init[0]; lo->lo_init[1] = info->lo_init[1]; @@ -1285,7 +1289,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a struct loop_device *lo = inode->i_bdev->bd_disk->private_data; int err; - lock_kernel(); switch(cmd) { case LOOP_SET_STATUS: mutex_lock(&lo->lo_ctl_mutex); @@ -1311,7 +1314,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a err = -ENOIOCTLCMD; break; } - unlock_kernel(); return err; } #endif @@ -1333,6 +1335,10 @@ static int lo_release(struct inode *inode, struct file *file) mutex_lock(&lo->lo_ctl_mutex); --lo->lo_refcnt; + + if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt) + loop_clr_fd(lo, inode->i_bdev); + mutex_unlock(&lo->lo_ctl_mutex); return 0;