This source file includes following definitions.
- null_zone_init
- null_zone_exit
- null_zone_report
- null_handle_zoned
1
2 #ifndef __BLK_NULL_BLK_H
3 #define __BLK_NULL_BLK_H
4
5 #undef pr_fmt
6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8 #include <linux/blkdev.h>
9 #include <linux/slab.h>
10 #include <linux/blk-mq.h>
11 #include <linux/hrtimer.h>
12 #include <linux/configfs.h>
13 #include <linux/badblocks.h>
14 #include <linux/fault-inject.h>
15
16 struct nullb_cmd {
17 struct list_head list;
18 struct llist_node ll_list;
19 struct __call_single_data csd;
20 struct request *rq;
21 struct bio *bio;
22 unsigned int tag;
23 blk_status_t error;
24 struct nullb_queue *nq;
25 struct hrtimer timer;
26 };
27
28 struct nullb_queue {
29 unsigned long *tag_map;
30 wait_queue_head_t wait;
31 unsigned int queue_depth;
32 struct nullb_device *dev;
33 unsigned int requeue_selection;
34
35 struct nullb_cmd *cmds;
36 };
37
38 struct nullb_device {
39 struct nullb *nullb;
40 struct config_item item;
41 struct radix_tree_root data;
42 struct radix_tree_root cache;
43 unsigned long flags;
44 unsigned int curr_cache;
45 struct badblocks badblocks;
46
47 unsigned int nr_zones;
48 struct blk_zone *zones;
49 sector_t zone_size_sects;
50
51 unsigned long size;
52 unsigned long completion_nsec;
53 unsigned long cache_size;
54 unsigned long zone_size;
55 unsigned int zone_nr_conv;
56 unsigned int submit_queues;
57 unsigned int home_node;
58 unsigned int queue_mode;
59 unsigned int blocksize;
60 unsigned int irqmode;
61 unsigned int hw_queue_depth;
62 unsigned int index;
63 unsigned int mbps;
64 bool blocking;
65 bool use_per_node_hctx;
66 bool power;
67 bool memory_backed;
68 bool discard;
69 bool zoned;
70 };
71
72 struct nullb {
73 struct nullb_device *dev;
74 struct list_head list;
75 unsigned int index;
76 struct request_queue *q;
77 struct gendisk *disk;
78 struct blk_mq_tag_set *tag_set;
79 struct blk_mq_tag_set __tag_set;
80 unsigned int queue_depth;
81 atomic_long_t cur_bytes;
82 struct hrtimer bw_timer;
83 unsigned long cache_flush_pos;
84 spinlock_t lock;
85
86 struct nullb_queue *queues;
87 unsigned int nr_queues;
88 char disk_name[DISK_NAME_LEN];
89 };
90
91 #ifdef CONFIG_BLK_DEV_ZONED
92 int null_zone_init(struct nullb_device *dev);
93 void null_zone_exit(struct nullb_device *dev);
94 int null_zone_report(struct gendisk *disk, sector_t sector,
95 struct blk_zone *zones, unsigned int *nr_zones);
96 blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
97 enum req_opf op, sector_t sector,
98 sector_t nr_sectors);
99 #else
100 static inline int null_zone_init(struct nullb_device *dev)
101 {
102 pr_err("CONFIG_BLK_DEV_ZONED not enabled\n");
103 return -EINVAL;
104 }
105 static inline void null_zone_exit(struct nullb_device *dev) {}
106 static inline int null_zone_report(struct gendisk *disk, sector_t sector,
107 struct blk_zone *zones,
108 unsigned int *nr_zones)
109 {
110 return -EOPNOTSUPP;
111 }
112 static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
113 enum req_opf op, sector_t sector,
114 sector_t nr_sectors)
115 {
116 return BLK_STS_NOTSUPP;
117 }
118 #endif
119 #endif