1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2011, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
40 * linux/drivers/block/loop.c
42 * Written by Theodore Ts'o, 3/29/93
44 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
45 * permitted under the GNU General Public License.
47 * Modularized and updated for 1.1.16 kernel - Mitch Dsouza 28th May 1994
48 * Adapted for 1.3.59 kernel - Andries Brouwer, 1 Feb 1996
50 * Fixed do_loop_request() re-entrancy - Vincent.Renardias@waw.com Mar 20, 1997
52 * Added devfs support - Richard Gooch <rgooch@atnf.csiro.au> 16-Jan-1998
54 * Handle sparse backing files correctly - Kenn Humborg, Jun 28, 1998
56 * Loadable modules and other fixes by AK, 1998
58 * Maximum number of loop devices now dynamic via max_loop module parameter.
59 * Russell Kroll <rkroll@exploits.org> 19990701
61 * Maximum number of loop devices when compiled-in now selectable by passing
62 * max_loop=<1-255> to the kernel on boot.
63 * Erik I. Bols?, <eriki@himolde.no>, Oct 31, 1999
65 * Completely rewrite request handling to be make_request_fn style and
66 * non blocking, pushing work to a helper thread. Lots of fixes from
68 * Jens Axboe <axboe@suse.de>, Nov 2000
70 * Support up to 256 loop devices
71 * Heinz Mauelshagen <mge@sistina.com>, Feb 2002
73 * Support for falling back on the write file operation when the address space
74 * operations prepare_write and/or commit_write are not available on the
76 * Anton Altaparmakov, 16 Feb 2005
79 * - Advisory locking is ignored here.
80 * - Should use an own CAP_* category instead of CAP_SYS_ADMIN
84 #ifndef AUTOCONF_INCLUDED
85 #include <linux/config.h>
87 #include <linux/module.h>
89 #include <linux/sched.h>
91 #include <linux/file.h>
92 #include <linux/stat.h>
93 #include <linux/errno.h>
94 #include <linux/major.h>
95 #include <linux/wait.h>
96 #include <linux/blkdev.h>
97 #include <linux/blkpg.h>
98 #include <linux/init.h>
99 #include <linux/smp_lock.h>
100 #include <linux/swap.h>
101 #include <linux/slab.h>
102 #include <linux/suspend.h>
103 #include <linux/writeback.h>
104 #include <linux/buffer_head.h> /* for invalidate_bdev() */
105 #include <linux/completion.h>
106 #include <linux/highmem.h>
107 #include <linux/gfp.h>
108 #include <linux/swap.h>
109 #include <linux/pagevec.h>
111 #include <asm/uaccess.h>
113 #include <lustre_lib.h>
114 #include <lustre_lite.h>
115 #include "llite_internal.h"
117 #define LLOOP_MAX_SEGMENTS PTLRPC_MAX_BRW_PAGES
119 /* Possible states of device */
126 struct lloop_device {
132 int (*ioctl)(struct lloop_device *, int cmd,
135 struct file *lo_backing_file;
136 struct block_device *lo_device;
137 unsigned lo_blocksize;
141 cfs_spinlock_t lo_lock;
143 struct bio *lo_biotail;
145 cfs_semaphore_t lo_sem;
146 cfs_semaphore_t lo_ctl_mutex;
147 cfs_atomic_t lo_pending;
148 cfs_waitq_t lo_bh_wait;
150 struct request_queue *lo_queue;
152 const struct lu_env *lo_env;
154 struct ll_dio_pages lo_pvec;
156 /* data to handle bio for lustre. */
157 struct lo_request_data {
158 struct page *lrd_pages[LLOOP_MAX_SEGMENTS];
159 loff_t lrd_offsets[LLOOP_MAX_SEGMENTS];
167 LO_FLAGS_READ_ONLY = 1,
170 static int lloop_major;
171 #define MAX_LOOP_DEFAULT 16
172 static int max_loop = MAX_LOOP_DEFAULT;
173 static struct lloop_device *loop_dev;
174 static struct gendisk **disks;
175 static cfs_semaphore_t lloop_mutex;
176 static void *ll_iocontrol_magic = NULL;
178 static loff_t get_loop_size(struct lloop_device *lo, struct file *file)
180 loff_t size, offset, loopsize;
182 /* Compute loopsize in bytes */
183 size = i_size_read(file->f_mapping->host);
184 offset = lo->lo_offset;
185 loopsize = size - offset;
186 if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
187 loopsize = lo->lo_sizelimit;
190 * Unfortunately, if we want to do I/O on the device,
191 * the number of 512-byte sectors has to fit into a sector_t.
193 return loopsize >> 9;
196 static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head)
198 const struct lu_env *env = lo->lo_env;
199 struct cl_io *io = &lo->lo_io;
200 struct inode *inode = lo->lo_backing_file->f_dentry->d_inode;
201 struct cl_object *obj = ll_i2info(inode)->lli_clob;
206 obd_count page_count = 0;
207 struct bio_vec *bvec;
211 struct ll_dio_pages *pvec = &lo->lo_pvec;
212 struct page **pages = pvec->ldp_pages;
213 loff_t *offsets = pvec->ldp_offsets;
215 truncate_inode_pages(inode->i_mapping, 0);
217 /* initialize the IO */
218 memset(io, 0, sizeof(*io));
220 ret = cl_io_init(env, io, CIT_MISC, obj);
222 return io->ci_result;
223 io->ci_lockreq = CILR_NEVER;
225 LASSERT(head != NULL);
227 for (bio = head; bio != NULL; bio = bio->bi_next) {
228 LASSERT(rw == bio->bi_rw);
230 offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset;
231 bio_for_each_segment(bvec, bio, i) {
232 BUG_ON(bvec->bv_offset != 0);
233 BUG_ON(bvec->bv_len != CFS_PAGE_SIZE);
235 pages[page_count] = bvec->bv_page;
236 offsets[page_count] = offset;
238 offset += bvec->bv_len;
240 LASSERT(page_count <= LLOOP_MAX_SEGMENTS);
243 ll_stats_ops_tally(ll_i2sbi(inode),
244 (rw == WRITE) ? LPROC_LL_BRW_WRITE : LPROC_LL_BRW_READ,
247 pvec->ldp_size = page_count << PAGE_CACHE_SHIFT;
248 pvec->ldp_nr = page_count;
250 /* FIXME: in ll_direct_rw_pages, it has to allocate many cl_page{}s to
251 * write those pages into OST. Even worse case is that more pages
252 * would be asked to write out to swap space, and then finally get here
254 * Unfortunately this is NOT easy to fix.
255 * Thoughts on solution:
256 * 0. Define a reserved pool for cl_pages, which could be a list of
257 * pre-allocated cl_pages from cl_page_kmem;
258 * 1. Define a new operation in cl_object_operations{}, says clo_depth,
259 * which measures how many layers for this lustre object. Generally
260 * speaking, the depth would be 2, one for llite, and one for lovsub.
261 * However, for SNS, there will be more since we need additional page
263 * 2. Reserve the # of (page_count * depth) cl_pages from the reserved
264 * pool. Afterwards, the clio would allocate the pages from reserved
265 * pool, this guarantees we neeedn't allocate the cl_pages from
266 * generic cl_page slab cache.
267 * Of course, if there is NOT enough pages in the pool, we might
268 * be asked to write less pages once, this purely depends on
269 * implementation. Anyway, we should be careful to avoid deadlocking.
271 LOCK_INODE_MUTEX(inode);
272 bytes = ll_direct_rw_pages(env, io, rw, inode, pvec);
273 UNLOCK_INODE_MUTEX(inode);
275 return (bytes == pvec->ldp_size) ? 0 : (int)bytes;
279 * Add bio to back of pending list
281 static void loop_add_bio(struct lloop_device *lo, struct bio *bio)
285 cfs_spin_lock_irqsave(&lo->lo_lock, flags);
286 if (lo->lo_biotail) {
287 lo->lo_biotail->bi_next = bio;
288 lo->lo_biotail = bio;
290 lo->lo_bio = lo->lo_biotail = bio;
291 cfs_spin_unlock_irqrestore(&lo->lo_lock, flags);
293 cfs_atomic_inc(&lo->lo_pending);
294 if (cfs_waitq_active(&lo->lo_bh_wait))
295 cfs_waitq_signal(&lo->lo_bh_wait);
299 * Grab first pending buffer
301 static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req)
305 unsigned int count = 0;
306 unsigned int page_count = 0;
309 cfs_spin_lock_irq(&lo->lo_lock);
311 if (unlikely(first == NULL)) {
312 cfs_spin_unlock_irq(&lo->lo_lock);
316 /* TODO: need to split the bio, too bad. */
317 LASSERT(first->bi_vcnt <= LLOOP_MAX_SEGMENTS);
321 while (*bio && (*bio)->bi_rw == rw) {
322 CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n",
323 (unsigned long long)(*bio)->bi_sector, (*bio)->bi_size,
324 page_count, (*bio)->bi_vcnt);
325 if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS)
329 page_count += (*bio)->bi_vcnt;
331 bio = &(*bio)->bi_next;
334 /* Some of bios can't be mergable. */
338 /* Hit the end of queue */
339 lo->lo_biotail = NULL;
343 cfs_spin_unlock_irq(&lo->lo_lock);
347 static int loop_make_request(struct request_queue *q, struct bio *old_bio)
349 struct lloop_device *lo = q->queuedata;
350 int rw = bio_rw(old_bio);
356 CDEBUG(D_INFO, "submit bio sector %llu size %u\n",
357 (unsigned long long)old_bio->bi_sector, old_bio->bi_size);
359 cfs_spin_lock_irq(&lo->lo_lock);
360 inactive = (lo->lo_state != LLOOP_BOUND);
361 cfs_spin_unlock_irq(&lo->lo_lock);
366 if (lo->lo_flags & LO_FLAGS_READ_ONLY)
368 } else if (rw == READA) {
370 } else if (rw != READ) {
371 CERROR("lloop: unknown command (%x)\n", rw);
374 loop_add_bio(lo, old_bio);
377 cfs_bio_io_error(old_bio, old_bio->bi_size);
381 #ifdef HAVE_REQUEST_QUEUE_UNPLUG_FN
383 * kick off io on the underlying address space
385 static void loop_unplug(struct request_queue *q)
387 struct lloop_device *lo = q->queuedata;
389 clear_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags);
390 blk_run_address_space(lo->lo_backing_file->f_mapping);
394 static inline void loop_handle_bio(struct lloop_device *lo, struct bio *bio)
397 ret = do_bio_lustrebacked(lo, bio);
399 struct bio *tmp = bio->bi_next;
401 cfs_bio_endio(bio, bio->bi_size, ret);
406 static inline int loop_active(struct lloop_device *lo)
408 return cfs_atomic_read(&lo->lo_pending) ||
409 (lo->lo_state == LLOOP_RUNDOWN);
413 * worker thread that handles reads/writes to file backed loop devices,
414 * to avoid blocking in our make_request_fn.
416 static int loop_thread(void *data)
418 struct lloop_device *lo = data;
421 unsigned long times = 0;
422 unsigned long total_count = 0;
428 daemonize("lloop%d", lo->lo_number);
430 set_user_nice(current, -20);
432 lo->lo_state = LLOOP_BOUND;
434 env = cl_env_get(&refcheck);
436 GOTO(out, ret = PTR_ERR(env));
439 memset(&lo->lo_pvec, 0, sizeof(lo->lo_pvec));
440 lo->lo_pvec.ldp_pages = lo->lo_requests[0].lrd_pages;
441 lo->lo_pvec.ldp_offsets = lo->lo_requests[0].lrd_offsets;
444 * up sem, we are running
449 cfs_wait_event(lo->lo_bh_wait, loop_active(lo));
450 if (!cfs_atomic_read(&lo->lo_pending)) {
452 cfs_spin_lock_irq(&lo->lo_lock);
453 exiting = (lo->lo_state == LLOOP_RUNDOWN);
454 cfs_spin_unlock_irq(&lo->lo_lock);
460 count = loop_get_bio(lo, &bio);
462 CWARN("lloop(minor: %d): missing bio\n", lo->lo_number);
466 total_count += count;
467 if (total_count < count) { /* overflow */
473 if ((times & 127) == 0) {
474 CDEBUG(D_INFO, "total: %lu, count: %lu, avg: %lu\n",
475 total_count, times, total_count / times);
478 LASSERT(bio != NULL);
479 LASSERT(count <= cfs_atomic_read(&lo->lo_pending));
480 loop_handle_bio(lo, bio);
481 cfs_atomic_sub(count, &lo->lo_pending);
483 cl_env_put(env, &refcheck);
490 static int loop_set_fd(struct lloop_device *lo, struct file *unused,
491 struct block_device *bdev, struct file *file)
494 struct address_space *mapping;
499 if (!cfs_try_module_get(THIS_MODULE))
503 if (lo->lo_state != LLOOP_UNBOUND)
506 mapping = file->f_mapping;
507 inode = mapping->host;
510 if (!S_ISREG(inode->i_mode) || inode->i_sb->s_magic != LL_SUPER_MAGIC)
513 if (!(file->f_mode & FMODE_WRITE))
514 lo_flags |= LO_FLAGS_READ_ONLY;
516 size = get_loop_size(lo, file);
518 if ((loff_t)(sector_t)size != size) {
523 /* remove all pages in cache so as dirty pages not to be existent. */
524 truncate_inode_pages(mapping, 0);
526 set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0);
528 lo->lo_blocksize = CFS_PAGE_SIZE;
529 lo->lo_device = bdev;
530 lo->lo_flags = lo_flags;
531 lo->lo_backing_file = file;
533 lo->lo_sizelimit = 0;
534 lo->old_gfp_mask = mapping_gfp_mask(mapping);
535 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
537 lo->lo_bio = lo->lo_biotail = NULL;
540 * set queue make_request_fn, and add limits based on lower level
543 blk_queue_make_request(lo->lo_queue, loop_make_request);
544 lo->lo_queue->queuedata = lo;
545 #ifdef HAVE_REQUEST_QUEUE_UNPLUG_FN
546 lo->lo_queue->unplug_fn = loop_unplug;
549 /* queue parameters */
550 CLASSERT(CFS_PAGE_SIZE < (1 << (sizeof(unsigned short) * 8)));
551 blk_queue_logical_block_size(lo->lo_queue,
552 (unsigned short)CFS_PAGE_SIZE);
553 blk_queue_max_hw_sectors(lo->lo_queue,
554 LLOOP_MAX_SEGMENTS << (CFS_PAGE_SHIFT - 9));
555 blk_queue_max_segments(lo->lo_queue, LLOOP_MAX_SEGMENTS);
557 set_capacity(disks[lo->lo_number], size);
558 bd_set_size(bdev, size << 9);
560 set_blocksize(bdev, lo->lo_blocksize);
562 cfs_create_thread(loop_thread, lo, CLONE_KERNEL);
563 cfs_down(&lo->lo_sem);
567 /* This is safe: open() is still holding a reference. */
568 cfs_module_put(THIS_MODULE);
572 static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
575 struct file *filp = lo->lo_backing_file;
576 int gfp = lo->old_gfp_mask;
578 if (lo->lo_state != LLOOP_BOUND)
581 if (lo->lo_refcnt > count) /* we needed one fd for the ioctl */
587 cfs_spin_lock_irq(&lo->lo_lock);
588 lo->lo_state = LLOOP_RUNDOWN;
589 cfs_spin_unlock_irq(&lo->lo_lock);
590 cfs_waitq_signal(&lo->lo_bh_wait);
592 cfs_down(&lo->lo_sem);
593 lo->lo_backing_file = NULL;
595 lo->lo_device = NULL;
597 lo->lo_sizelimit = 0;
599 ll_invalidate_bdev(bdev, 0);
600 set_capacity(disks[lo->lo_number], 0);
601 bd_set_size(bdev, 0);
602 mapping_set_gfp_mask(filp->f_mapping, gfp);
603 lo->lo_state = LLOOP_UNBOUND;
605 /* This is safe: open() is still holding a reference. */
606 cfs_module_put(THIS_MODULE);
610 #ifdef HAVE_BLKDEV_PUT_2ARGS
611 static int lo_open(struct block_device *bdev, fmode_t mode)
613 struct lloop_device *lo = bdev->bd_disk->private_data;
615 static int lo_open(struct inode *inode, struct file *file)
617 struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
620 cfs_down(&lo->lo_ctl_mutex);
622 cfs_up(&lo->lo_ctl_mutex);
627 #ifdef HAVE_BLKDEV_PUT_2ARGS
628 static int lo_release(struct gendisk *disk, fmode_t mode)
630 struct lloop_device *lo = disk->private_data;
632 static int lo_release(struct inode *inode, struct file *file)
634 struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
637 cfs_down(&lo->lo_ctl_mutex);
639 cfs_up(&lo->lo_ctl_mutex);
644 /* lloop device node's ioctl function. */
645 #ifdef HAVE_BLKDEV_PUT_2ARGS
646 static int lo_ioctl(struct block_device *bdev, fmode_t mode,
647 unsigned int cmd, unsigned long arg)
649 struct lloop_device *lo = bdev->bd_disk->private_data;
650 struct inode *inode = lo->lo_backing_file->f_dentry->d_inode;
652 static int lo_ioctl(struct inode *inode, struct file *unused,
653 unsigned int cmd, unsigned long arg)
655 struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
656 struct block_device *bdev = inode->i_bdev;
660 cfs_down(&lloop_mutex);
662 case LL_IOC_LLOOP_DETACH: {
663 err = loop_clr_fd(lo, bdev, 2);
665 ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
669 case LL_IOC_LLOOP_INFO: {
672 if (lo->lo_state == LLOOP_BOUND)
673 fid = ll_i2info(inode)->lli_fid;
677 if (copy_to_user((struct lu_fid *)arg, &fid, sizeof(fid)))
686 cfs_up(&lloop_mutex);
691 static struct block_device_operations lo_fops = {
692 .owner = THIS_MODULE,
694 .release = lo_release,
698 /* dynamic iocontrol callback.
699 * This callback is registered in lloop_init and will be called by
702 * This is a llite regular file ioctl function. It takes the responsibility
703 * of attaching or detaching a file by a lloop's device numner.
705 static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
706 unsigned int cmd, unsigned long arg,
707 void *magic, int *rcp)
709 struct lloop_device *lo = NULL;
710 struct block_device *bdev = NULL;
714 if (magic != ll_iocontrol_magic)
718 GOTO(out1, err = -ENODEV);
720 CWARN("Enter llop_ioctl\n");
722 cfs_down(&lloop_mutex);
724 case LL_IOC_LLOOP_ATTACH: {
725 struct lloop_device *lo_free = NULL;
728 for (i = 0; i < max_loop; i++, lo = NULL) {
730 if (lo->lo_state == LLOOP_UNBOUND) {
735 if (lo->lo_backing_file->f_dentry->d_inode ==
736 file->f_dentry->d_inode)
740 GOTO(out, err = -EBUSY);
743 dev = MKDEV(lloop_major, lo->lo_number);
745 /* quit if the used pointer is writable */
746 if (put_user((long)old_encode_dev(dev), (long*)arg))
747 GOTO(out, err = -EFAULT);
749 bdev = blkdev_get_by_dev(dev, file->f_mode, NULL);
751 GOTO(out, err = PTR_ERR(bdev));
754 err = loop_set_fd(lo, NULL, bdev, file);
757 ll_blkdev_put(bdev, 0);
763 case LL_IOC_LLOOP_DETACH_BYDEV: {
766 dev = old_decode_dev(arg);
767 if (MAJOR(dev) != lloop_major)
768 GOTO(out, err = -EINVAL);
771 if (minor > max_loop - 1)
772 GOTO(out, err = -EINVAL);
774 lo = &loop_dev[minor];
775 if (lo->lo_state != LLOOP_BOUND)
776 GOTO(out, err = -EINVAL);
778 bdev = lo->lo_device;
779 err = loop_clr_fd(lo, bdev, 1);
781 ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
792 cfs_up(&lloop_mutex);
799 static int __init lloop_init(void)
802 unsigned int cmdlist[] = {
804 LL_IOC_LLOOP_DETACH_BYDEV,
807 if (max_loop < 1 || max_loop > 256) {
808 max_loop = MAX_LOOP_DEFAULT;
809 CWARN("lloop: invalid max_loop (must be between"
810 " 1 and 256), using default (%u)\n", max_loop);
813 lloop_major = register_blkdev(0, "lloop");
817 CDEBUG(D_CONFIG, "registered lloop major %d with %u minors\n",
818 lloop_major, max_loop);
820 ll_iocontrol_magic = ll_iocontrol_register(lloop_ioctl, 2, cmdlist);
821 if (ll_iocontrol_magic == NULL)
824 OBD_ALLOC_WAIT(loop_dev, max_loop * sizeof(*loop_dev));
828 OBD_ALLOC_WAIT(disks, max_loop * sizeof(*disks));
832 for (i = 0; i < max_loop; i++) {
833 disks[i] = alloc_disk(1);
838 cfs_init_mutex(&lloop_mutex);
840 for (i = 0; i < max_loop; i++) {
841 struct lloop_device *lo = &loop_dev[i];
842 struct gendisk *disk = disks[i];
844 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
848 cfs_init_mutex(&lo->lo_ctl_mutex);
849 cfs_init_mutex_locked(&lo->lo_sem);
850 cfs_waitq_init(&lo->lo_bh_wait);
852 cfs_spin_lock_init(&lo->lo_lock);
853 disk->major = lloop_major;
854 disk->first_minor = i;
855 disk->fops = &lo_fops;
856 sprintf(disk->disk_name, "lloop%d", i);
857 disk->private_data = lo;
858 disk->queue = lo->lo_queue;
861 /* We cannot fail after we call this, so another loop!*/
862 for (i = 0; i < max_loop; i++)
868 blk_cleanup_queue(loop_dev[i].lo_queue);
873 OBD_FREE(disks, max_loop * sizeof(*disks));
875 OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
877 unregister_blkdev(lloop_major, "lloop");
878 ll_iocontrol_unregister(ll_iocontrol_magic);
879 CERROR("lloop: ran out of memory\n");
883 static void lloop_exit(void)
887 ll_iocontrol_unregister(ll_iocontrol_magic);
888 for (i = 0; i < max_loop; i++) {
889 del_gendisk(disks[i]);
890 blk_cleanup_queue(loop_dev[i].lo_queue);
893 if (ll_unregister_blkdev(lloop_major, "lloop"))
894 CWARN("lloop: cannot unregister blkdev\n");
896 CDEBUG(D_CONFIG, "unregistered lloop major %d\n", lloop_major);
898 OBD_FREE(disks, max_loop * sizeof(*disks));
899 OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
902 module_init(lloop_init);
903 module_exit(lloop_exit);
905 CFS_MODULE_PARM(max_loop, "i", int, 0444, "maximum of lloop_device");
906 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
907 MODULE_DESCRIPTION("Lustre virtual block device");
908 MODULE_LICENSE("GPL");