]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/block/loop.h
Merge branch 'for-4.2/core' into for-4.2/drivers
[mirror_ubuntu-bionic-kernel.git] / drivers / block / loop.h
CommitLineData
1da177e4 1/*
83a87611 2 * loop.h
1da177e4
LT
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 */
607ca46e
DH
9#ifndef _LINUX_LOOP_H
10#define _LINUX_LOOP_H
1da177e4 11
1da177e4
LT
12#include <linux/bio.h>
13#include <linux/blkdev.h>
78e367a3 14#include <linux/blk-mq.h>
1da177e4 15#include <linux/spinlock.h>
f85221dd 16#include <linux/mutex.h>
b5dd2f60 17#include <linux/workqueue.h>
607ca46e 18#include <uapi/linux/loop.h>
1da177e4
LT
19
20/* Possible states of device */
21enum {
22 Lo_unbound,
23 Lo_bound,
24 Lo_rundown,
25};
26
27struct loop_func_table;
28
29struct loop_device {
30 int lo_number;
31 int 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];
e4849737 45 kuid_t lo_key_owner; /* Who set the key */
1da177e4
LT
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 unsigned lo_blocksize;
52 void *key_data;
53
b4e3ca1a 54 gfp_t old_gfp_mask;
1da177e4
LT
55
56 spinlock_t lo_lock;
f4aa4c7b 57 struct workqueue_struct *wq;
b5dd2f60
ML
58 struct list_head write_cmd_head;
59 struct work_struct write_work;
60 bool write_started;
1da177e4 61 int lo_state;
f85221dd 62 struct mutex lo_ctl_mutex;
1da177e4 63
01e457cf 64 struct request_queue *lo_queue;
b5dd2f60 65 struct blk_mq_tag_set tag_set;
73285082 66 struct gendisk *lo_disk;
1da177e4
LT
67};
68
b5dd2f60
ML
69struct loop_cmd {
70 struct work_struct read_work;
71 struct request *rq;
72 struct list_head list;
73};
74
1da177e4
LT
75/* Support for loadable transfer modules */
76struct loop_func_table {
77 int number; /* filter type */
78 int (*transfer)(struct loop_device *lo, int cmd,
79 struct page *raw_page, unsigned raw_off,
80 struct page *loop_page, unsigned loop_off,
81 int size, sector_t real_block);
82 int (*init)(struct loop_device *, const struct loop_info64 *);
83 /* release is called from loop_unregister_transfer or clr_fd */
84 int (*release)(struct loop_device *);
85 int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
86 struct module *owner;
87};
88
89int loop_register_transfer(struct loop_func_table *funcs);
90int loop_unregister_transfer(int number);
91
92#endif