Blame view

drivers/block/loop.h 2.31 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
83a876114   Al Viro   move linux/loop.h...
2
   * loop.h
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
5
6
7
8
   *
   * Written by Theodore Ts'o, 3/29/93.
   *
   * Copyright 1993 by Theodore Ts'o.  Redistribution of this file is
   * permitted under the GNU General Public License.
   */
607ca46e9   David Howells   UAPI: (Scripted) ...
9
10
  #ifndef _LINUX_LOOP_H
  #define _LINUX_LOOP_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
  #include <linux/bio.h>
  #include <linux/blkdev.h>
78e367a36   Jens Axboe   loop: add blk-mq....
14
  #include <linux/blk-mq.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
  #include <linux/spinlock.h>
f85221dd7   Ingo Molnar   [PATCH] sem2mutex...
16
  #include <linux/mutex.h>
e03a3d7a9   Ming Lei   block: loop: use ...
17
  #include <linux/kthread.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
18
  #include <uapi/linux/loop.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
23
24
25
26
27
28
29
30
  
  /* Possible states of device */
  enum {
  	Lo_unbound,
  	Lo_bound,
  	Lo_rundown,
  };
  
  struct loop_func_table;
  
  struct loop_device {
  	int		lo_number;
f89336679   Ming Lei   block: loop: don'...
31
  	atomic_t	lo_refcnt;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
33
34
35
36
37
38
39
40
41
42
43
44
  	loff_t		lo_offset;
  	loff_t		lo_sizelimit;
  	int		lo_flags;
  	int		(*transfer)(struct loop_device *, int cmd,
  				    struct page *raw_page, unsigned raw_off,
  				    struct page *loop_page, unsigned loop_off,
  				    int size, sector_t real_block);
  	char		lo_file_name[LO_NAME_SIZE];
  	char		lo_crypt_name[LO_NAME_SIZE];
  	char		lo_encrypt_key[LO_KEY_SIZE];
  	int		lo_encrypt_key_size;
  	struct loop_func_table *lo_encryption;
  	__u32           lo_init[2];
e4849737f   Eric W. Biederman   userns: Convert l...
45
  	kuid_t		lo_key_owner;	/* Who set the key */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
50
  	int		(*ioctl)(struct loop_device *, int cmd, 
  				 unsigned long arg); 
  
  	struct file *	lo_backing_file;
  	struct block_device *lo_device;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  	void		*key_data; 
b4e3ca1ab   Al Viro   [PATCH] gfp_t: re...
52
  	gfp_t		old_gfp_mask;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
54
  
  	spinlock_t		lo_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
  	int			lo_state;
e03a3d7a9   Ming Lei   block: loop: use ...
56
57
  	struct kthread_worker	worker;
  	struct task_struct	*worker_task;
2e5ab5f37   Ming Lei   block: loop: prep...
58
  	bool			use_dio;
d3349b6b3   Tetsuo Handa   loop: remember wh...
59
  	bool			sysfs_inited;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60

01e457cfc   Arnd Bergmann   loop.h build fix
61
  	struct request_queue	*lo_queue;
b5dd2f604   Ming Lei   block: loop: impr...
62
  	struct blk_mq_tag_set	tag_set;
732850827   Ken Chen   remove artificial...
63
  	struct gendisk		*lo_disk;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
  };
b5dd2f604   Ming Lei   block: loop: impr...
65
  struct loop_cmd {
e03a3d7a9   Ming Lei   block: loop: use ...
66
  	struct kthread_work work;
e5313c141   Omar Sandoval   loop: remove unio...
67
68
  	bool use_aio; /* use AIO interface to handle I/O */
  	atomic_t ref; /* only for aio */
fe2cb2905   Christoph Hellwig   loop: zero-fill b...
69
  	long ret;
bc07c10a3   Ming Lei   block: loop: supp...
70
  	struct kiocb iocb;
40326d8a3   Shaohua Li   block/loop: allow...
71
  	struct bio_vec *bvec;
d4478e92d   Shaohua Li   block/loop: make ...
72
  	struct cgroup_subsys_state *css;
b5dd2f604   Ming Lei   block: loop: impr...
73
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  /* Support for loadable transfer modules */
  struct loop_func_table {
  	int number;	/* filter type */ 
  	int (*transfer)(struct loop_device *lo, int cmd,
  			struct page *raw_page, unsigned raw_off,
  			struct page *loop_page, unsigned loop_off,
  			int size, sector_t real_block);
  	int (*init)(struct loop_device *, const struct loop_info64 *); 
  	/* release is called from loop_unregister_transfer or clr_fd */
  	int (*release)(struct loop_device *); 
  	int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
  	struct module *owner;
  }; 
  
  int loop_register_transfer(struct loop_func_table *funcs);
  int loop_unregister_transfer(int number); 
  
  #endif