Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / md / dm-core.h
blob3222e21cbbf82cab0039cf1a992f14bf48383b8a
1 /*
2 * Internal header file _only_ for device mapper core
4 * Copyright (C) 2016 Red Hat, Inc. All rights reserved.
6 * This file is released under the LGPL.
7 */
9 #ifndef DM_CORE_INTERNAL_H
10 #define DM_CORE_INTERNAL_H
12 #include <linux/kthread.h>
13 #include <linux/ktime.h>
14 #include <linux/blk-mq.h>
16 #include <trace/events/block.h>
18 #include "dm.h"
20 #define DM_RESERVED_MAX_IOS 1024
22 struct dm_kobject_holder {
23 struct kobject kobj;
24 struct completion completion;
28 * DM core internal structure that used directly by dm.c and dm-rq.c
29 * DM targets must _not_ deference a mapped_device to directly access its members!
31 struct mapped_device {
32 struct mutex suspend_lock;
35 * The current mapping (struct dm_table *).
36 * Use dm_get_live_table{_fast} or take suspend_lock for
37 * dereference.
39 void __rcu *map;
41 struct list_head table_devices;
42 struct mutex table_devices_lock;
44 unsigned long flags;
46 struct request_queue *queue;
47 int numa_node_id;
49 enum dm_queue_mode type;
50 /* Protect queue and type against concurrent access. */
51 struct mutex type_lock;
53 atomic_t holders;
54 atomic_t open_count;
56 struct dm_target *immutable_target;
57 struct target_type *immutable_target_type;
59 struct gendisk *disk;
60 struct dax_device *dax_dev;
61 char name[16];
63 void *interface_ptr;
66 * A list of ios that arrived while we were suspended.
68 atomic_t pending[2];
69 wait_queue_head_t wait;
70 struct work_struct work;
71 spinlock_t deferred_lock;
72 struct bio_list deferred;
75 * Event handling.
77 wait_queue_head_t eventq;
78 atomic_t event_nr;
79 atomic_t uevent_seq;
80 struct list_head uevent_list;
81 spinlock_t uevent_lock; /* Protect access to uevent_list */
83 /* the number of internal suspends */
84 unsigned internal_suspend_count;
87 * Processing queue (flush)
89 struct workqueue_struct *wq;
92 * io objects are allocated from here.
94 struct bio_set *io_bs;
95 struct bio_set *bs;
98 * freeze/thaw support require holding onto a super block
100 struct super_block *frozen_sb;
102 /* forced geometry settings */
103 struct hd_geometry geometry;
105 struct block_device *bdev;
107 /* kobject and completion */
108 struct dm_kobject_holder kobj_holder;
110 /* zero-length flush that will be cloned and submitted to targets */
111 struct bio flush_bio;
113 struct dm_stats stats;
115 struct kthread_worker kworker;
116 struct task_struct *kworker_task;
118 /* for request-based merge heuristic in dm_request_fn() */
119 unsigned seq_rq_merge_deadline_usecs;
120 int last_rq_rw;
121 sector_t last_rq_pos;
122 ktime_t last_rq_start_time;
124 /* for blk-mq request-based DM support */
125 struct blk_mq_tag_set *tag_set;
126 bool use_blk_mq:1;
127 bool init_tio_pdu:1;
129 struct srcu_struct io_barrier;
132 int md_in_flight(struct mapped_device *md);
133 void disable_write_same(struct mapped_device *md);
134 void disable_write_zeroes(struct mapped_device *md);
136 static inline struct completion *dm_get_completion_from_kobject(struct kobject *kobj)
138 return &container_of(kobj, struct dm_kobject_holder, kobj)->completion;
141 unsigned __dm_get_module_param(unsigned *module_param, unsigned def, unsigned max);
143 static inline bool dm_message_test_buffer_overflow(char *result, unsigned maxlen)
145 return !maxlen || strlen(result) + 1 >= maxlen;
148 extern atomic_t dm_global_event_nr;
149 extern wait_queue_head_t dm_global_eventq;
150 void dm_issue_global_event(void);
152 #endif