Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Al Viro | 83a8761 | 2013-05-12 10:14:07 -0400 | [diff] [blame] | 2 | * loop.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ | ||||
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 9 | #ifndef _LINUX_LOOP_H |
10 | #define _LINUX_LOOP_H | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/bio.h> |
13 | #include <linux/blkdev.h> | ||||
Jens Axboe | 78e367a | 2015-01-02 15:20:25 -0700 | [diff] [blame] | 14 | #include <linux/blk-mq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/spinlock.h> |
Ingo Molnar | f85221d | 2006-03-23 03:00:38 -0800 | [diff] [blame] | 16 | #include <linux/mutex.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 17 | #include <uapi/linux/loop.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
19 | /* Possible states of device */ | ||||
20 | enum { | ||||
21 | Lo_unbound, | ||||
22 | Lo_bound, | ||||
23 | Lo_rundown, | ||||
Christoph Hellwig | 990e781 | 2021-06-05 17:09:50 +0300 | [diff] [blame] | 24 | Lo_deleting, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | }; |
26 | |||||
27 | struct loop_func_table; | ||||
28 | |||||
29 | struct loop_device { | ||||
30 | int lo_number; | ||||
Ming Lei | f893366 | 2015-05-06 12:26:23 +0800 | [diff] [blame] | 31 | atomic_t lo_refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | loff_t lo_offset; |
33 | loff_t lo_sizelimit; | ||||
34 | int lo_flags; | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | char lo_file_name[LO_NAME_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
37 | struct file * lo_backing_file; | ||||
38 | struct block_device *lo_device; | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Al Viro | b4e3ca1 | 2005-10-21 03:22:34 -0400 | [diff] [blame] | 40 | gfp_t old_gfp_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
42 | spinlock_t lo_lock; | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | int lo_state; |
Dan Schatzberg | 87579e9 | 2021-06-28 19:38:15 -0700 | [diff] [blame] | 44 | spinlock_t lo_work_lock; |
45 | struct workqueue_struct *workqueue; | ||||
46 | struct work_struct rootcg_work; | ||||
47 | struct list_head rootcg_cmd_list; | ||||
48 | struct list_head idle_worker_list; | ||||
49 | struct rb_root worker_tree; | ||||
50 | struct timer_list timer; | ||||
Ming Lei | 2e5ab5f | 2015-08-17 10:31:49 +0800 | [diff] [blame] | 51 | bool use_dio; |
Tetsuo Handa | d3349b6 | 2018-05-04 10:58:09 -0600 | [diff] [blame] | 52 | bool sysfs_inited; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Arnd Bergmann | 01e457c | 2007-07-23 18:44:00 -0700 | [diff] [blame] | 54 | struct request_queue *lo_queue; |
Ming Lei | b5dd2f6 | 2014-12-31 13:22:57 +0000 | [diff] [blame] | 55 | struct blk_mq_tag_set tag_set; |
Ken Chen | 7328508 | 2007-05-08 00:28:20 -0700 | [diff] [blame] | 56 | struct gendisk *lo_disk; |
Pavel Tatashin | 6cc8e74 | 2021-01-26 09:46:30 -0500 | [diff] [blame] | 57 | struct mutex lo_mutex; |
Tetsuo Handa | 1c500ad | 2021-09-02 09:07:35 +0900 | [diff] [blame] | 58 | bool idr_visible; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | }; |
60 | |||||
Ming Lei | b5dd2f6 | 2014-12-31 13:22:57 +0000 | [diff] [blame] | 61 | struct loop_cmd { |
Dan Schatzberg | 87579e9 | 2021-06-28 19:38:15 -0700 | [diff] [blame] | 62 | struct list_head list_entry; |
Omar Sandoval | e5313c1 | 2017-09-20 14:24:34 -0700 | [diff] [blame] | 63 | bool use_aio; /* use AIO interface to handle I/O */ |
64 | atomic_t ref; /* only for aio */ | ||||
Christoph Hellwig | fe2cb29 | 2017-04-20 16:03:02 +0200 | [diff] [blame] | 65 | long ret; |
Ming Lei | bc07c10 | 2015-08-17 10:31:51 +0800 | [diff] [blame] | 66 | struct kiocb iocb; |
Shaohua Li | 40326d8 | 2017-08-31 22:09:46 -0700 | [diff] [blame] | 67 | struct bio_vec *bvec; |
Dan Schatzberg | c74d40e | 2021-06-28 19:38:21 -0700 | [diff] [blame] | 68 | struct cgroup_subsys_state *blkcg_css; |
69 | struct cgroup_subsys_state *memcg_css; | ||||
Ming Lei | b5dd2f6 | 2014-12-31 13:22:57 +0000 | [diff] [blame] | 70 | }; |
71 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #endif |