Loading...
Note: File does not exist in v3.1.
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 <uapi/linux/loop.h>
18
19/* Possible states of device */
20enum {
21 Lo_unbound,
22 Lo_bound,
23 Lo_rundown,
24 Lo_deleting,
25};
26
27struct loop_func_table;
28
29struct loop_device {
30 int lo_number;
31 atomic_t lo_refcnt;
32 loff_t lo_offset;
33 loff_t lo_sizelimit;
34 int lo_flags;
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;
44 __u32 lo_init[2];
45 kuid_t lo_key_owner; /* Who set the key */
46 int (*ioctl)(struct loop_device *, int cmd,
47 unsigned long arg);
48
49 struct file * lo_backing_file;
50 struct block_device *lo_device;
51 void *key_data;
52
53 gfp_t old_gfp_mask;
54
55 spinlock_t lo_lock;
56 int lo_state;
57 spinlock_t lo_work_lock;
58 struct workqueue_struct *workqueue;
59 struct work_struct rootcg_work;
60 struct list_head rootcg_cmd_list;
61 struct list_head idle_worker_list;
62 struct rb_root worker_tree;
63 struct timer_list timer;
64 bool use_dio;
65 bool sysfs_inited;
66
67 struct request_queue *lo_queue;
68 struct blk_mq_tag_set tag_set;
69 struct gendisk *lo_disk;
70 struct mutex lo_mutex;
71 bool idr_visible;
72};
73
74struct loop_cmd {
75 struct list_head list_entry;
76 bool use_aio; /* use AIO interface to handle I/O */
77 atomic_t ref; /* only for aio */
78 long ret;
79 struct kiocb iocb;
80 struct bio_vec *bvec;
81 struct cgroup_subsys_state *blkcg_css;
82 struct cgroup_subsys_state *memcg_css;
83};
84
85/* Support for loadable transfer modules */
86struct loop_func_table {
87 int number; /* filter type */
88 int (*transfer)(struct loop_device *lo, int cmd,
89 struct page *raw_page, unsigned raw_off,
90 struct page *loop_page, unsigned loop_off,
91 int size, sector_t real_block);
92 int (*init)(struct loop_device *, const struct loop_info64 *);
93 /* release is called from loop_unregister_transfer or clr_fd */
94 int (*release)(struct loop_device *);
95 int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
96 struct module *owner;
97};
98
99int loop_register_transfer(struct loop_func_table *funcs);
100int loop_unregister_transfer(int number);
101
102#endif