| 1 | |
| 2 | * loop.h
|
| 3 | *
|
| 4 | * Written by Theodore Ts'o, 3/29/93.
|
| 5 | *
|
| 6 | * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
|
| 7 | * permitted under the GNU General Public License.
|
| 8 |
|
| 9 | #ifndef _LINUX_LOOP_H
|
| 10 | #define _LINUX_LOOP_H
|
| 11 |
|
| 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>
|
| 19 |
|
| 20 |
|
| 21 | enum {
|
| 22 | Lo_unbound,
|
| 23 | Lo_bound,
|
| 24 | Lo_rundown,
|
| 25 | Lo_deleting,
|
| 26 | };
|
| 27 |
|
| 28 | struct loop_func_table;
|
| 29 |
|
| 30 | struct loop_device {
|
| 31 | int lo_number;
|
| 32 | atomic_t lo_refcnt;
|
| 33 | loff_t lo_offset;
|
| 34 | loff_t lo_sizelimit;
|
| 35 | int lo_flags;
|
| 36 | int (*transfer)(struct loop_device *, int cmd,
|
| 37 | struct page *raw_page, unsigned raw_off,
|
| 38 | struct page *loop_page, unsigned loop_off,
|
| 39 | int size, sector_t real_block);
|
| 40 | char lo_file_name[LO_NAME_SIZE];
|
| 41 | char lo_crypt_name[LO_NAME_SIZE];
|
| 42 | char lo_encrypt_key[LO_KEY_SIZE];
|
| 43 | int lo_encrypt_key_size;
|
| 44 | struct loop_func_table *lo_encryption;
|
| 45 | __u32 lo_init[2];
|
| 46 | kuid_t lo_key_owner;
|
| 47 | int (*ioctl)(struct loop_device *, int cmd,
|
| 48 | unsigned long arg);
|
| 49 |
|
| 50 | struct file * lo_backing_file;
|
| 51 | struct block_device *lo_device;
|
| 52 | void *key_data;
|
| 53 |
|
| 54 | gfp_t old_gfp_mask;
|
| 55 |
|
| 56 | spinlock_t lo_lock;
|
| 57 | int lo_state;
|
| 58 | struct kthread_worker worker;
|
| 59 | struct task_struct *worker_task;
|
| 60 | bool use_dio;
|
| 61 | bool sysfs_inited;
|
| 62 |
|
| 63 | struct request_queue *lo_queue;
|
| 64 | struct blk_mq_tag_set tag_set;
|
| 65 | struct gendisk *lo_disk;
|
| 66 | struct mutex lo_mutex;
|
| 67 | };
|
| 68 |
|
| 69 | struct loop_cmd {
|
| 70 | struct kthread_work work;
|
| 71 | bool use_aio;
|
| 72 | atomic_t ref;
|
| 73 | long ret;
|
| 74 | struct kiocb iocb;
|
| 75 | struct bio_vec *bvec;
|
| 76 | struct cgroup_subsys_state *css;
|
| 77 | };
|
| 78 |
|
| 79 |
|
| 80 | struct loop_func_table {
|
| 81 | int number;
|
| 82 | int (*transfer)(struct loop_device *lo, int cmd,
|
| 83 | struct page *raw_page, unsigned raw_off,
|
| 84 | struct page *loop_page, unsigned loop_off,
|
| 85 | int size, sector_t real_block);
|
| 86 | int (*init)(struct loop_device *, const struct loop_info64 *);
|
| 87 |
|
| 88 | int (*release)(struct loop_device *);
|
| 89 | int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
|
| 90 | struct module *owner;
|
| 91 | };
|
| 92 |
|
| 93 | int loop_register_transfer(struct loop_func_table *funcs);
|
| 94 | int loop_unregister_transfer(int number);
|
| 95 |
|
| 96 | #endif
|