4 * Written by Theodore Ts'o, 3/29/93.
6 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
7 * permitted under the GNU General Public License.
12 #include <linux/bio.h>
13 #include <linux/blkdev.h>
14 #include <linux/blk-mq.h>
15 #include <linux/spinlock.h>
16 #include <linux/mutex.h>
17 #include <linux/kthread.h>
18 #include <uapi/linux/loop.h>
20 /* Possible states of device */
27 struct loop_func_table
;
35 int (*transfer
)(struct loop_device
*, int cmd
,
36 struct page
*raw_page
, unsigned raw_off
,
37 struct page
*loop_page
, unsigned loop_off
,
38 int size
, sector_t real_block
);
39 char lo_file_name
[LO_NAME_SIZE
];
40 char lo_crypt_name
[LO_NAME_SIZE
];
41 char lo_encrypt_key
[LO_KEY_SIZE
];
42 int lo_encrypt_key_size
;
43 struct loop_func_table
*lo_encryption
;
45 kuid_t lo_key_owner
; /* Who set the key */
46 int (*ioctl
)(struct loop_device
*, int cmd
,
49 struct file
* lo_backing_file
;
50 struct block_device
*lo_device
;
51 unsigned lo_blocksize
;
58 struct mutex lo_ctl_mutex
;
59 struct kthread_worker worker
;
60 struct task_struct
*worker_task
;
63 struct request_queue
*lo_queue
;
64 struct blk_mq_tag_set tag_set
;
65 struct gendisk
*lo_disk
;
69 struct kthread_work work
;
71 struct list_head list
;
72 bool use_aio
; /* use AIO interface to handle I/O */
76 /* Support for loadable transfer modules */
77 struct loop_func_table
{
78 int number
; /* filter type */
79 int (*transfer
)(struct loop_device
*lo
, int cmd
,
80 struct page
*raw_page
, unsigned raw_off
,
81 struct page
*loop_page
, unsigned loop_off
,
82 int size
, sector_t real_block
);
83 int (*init
)(struct loop_device
*, const struct loop_info64
*);
84 /* release is called from loop_unregister_transfer or clr_fd */
85 int (*release
)(struct loop_device
*);
86 int (*ioctl
)(struct loop_device
*, int cmd
, unsigned long arg
);
90 int loop_register_transfer(struct loop_func_table
*funcs
);
91 int loop_unregister_transfer(int number
);