Blame view

drivers/md/dm.h 6.41 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
  /*
   * Internal header file for device mapper
   *
   * Copyright (C) 2001, 2002 Sistina Software
2b06cfff1   Alasdair G Kergon   [PATCH] dm: conso...
5
   * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
8
9
10
11
12
13
14
15
   *
   * This file is released under the LGPL.
   */
  
  #ifndef DM_INTERNAL_H
  #define DM_INTERNAL_H
  
  #include <linux/fs.h>
  #include <linux/device-mapper.h>
  #include <linux/list.h>
4cc96131a   Mike Snitzer   dm: move request-...
16
  #include <linux/moduleparam.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
  #include <linux/blkdev.h>
66114cad6   Tejun Heo   writeback: separa...
18
  #include <linux/backing-dev.h>
3ac51e741   Darrick J. Wong   [PATCH] dm store ...
19
  #include <linux/hdreg.h>
be35f4861   Mikulas Patocka   dm: wait until em...
20
  #include <linux/completion.h>
2995fa78e   Mikulas Patocka   dm sysfs: fix a m...
21
  #include <linux/kobject.h>
2a0b4682e   Elena Reshetova   dm: convert dm_de...
22
  #include <linux/refcount.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23

fd2ed4d25   Mikulas Patocka   dm: add statistic...
24
  #include "dm-stats.h"
45cbcd798   Kiyoshi Ueda   [PATCH] dm: map a...
25
  /*
a3d77d35b   Kiyoshi Ueda   [PATCH] dm: suspe...
26
27
28
   * Suspend feature flags
   */
  #define DM_SUSPEND_LOCKFS_FLAG		(1 << 0)
81fdb096d   Kiyoshi Ueda   [PATCH] dm: ioctl...
29
  #define DM_SUSPEND_NOFLUSH_FLAG		(1 << 1)
a3d77d35b   Kiyoshi Ueda   [PATCH] dm: suspe...
30
31
  
  /*
1f4e0ff07   Alasdair G Kergon   dm thin: commit b...
32
33
34
35
36
   * Status feature flags
   */
  #define DM_STATUS_NOFLUSH_FLAG		(1 << 0)
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
   * List of devices that a metadevice uses and should open/close.
   */
82b1519b3   Mikulas Patocka   dm: export struct...
39
  struct dm_dev_internal {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
  	struct list_head list;
2a0b4682e   Elena Reshetova   dm: convert dm_de...
41
  	refcount_t count;
86f1152b1   Benjamin Marzinski   dm: allow active ...
42
  	struct dm_dev *dm_dev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
45
  };
  
  struct dm_table;
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
46
  struct dm_md_mempools;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
  
  /*-----------------------------------------------------------------
17b2f66f2   Alasdair G Kergon   [PATCH] dm: add e...
49
   * Internal table functions.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
   *---------------------------------------------------------------*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
52
  void dm_table_event_callback(struct dm_table *t,
  			     void (*fn)(void *), void *context);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
54
  struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index);
  struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector);
3ae706561   Mike Snitzer   dm: retain table ...
55
  bool dm_table_has_no_data_devices(struct dm_table *table);
754c5fc7e   Mike Snitzer   dm: calculate que...
56
57
58
59
  int dm_calculate_queue_limits(struct dm_table *table,
  			      struct queue_limits *limits);
  void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
  			       struct queue_limits *limits);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60
  struct list_head *dm_table_get_devices(struct dm_table *t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
  void dm_table_presuspend_targets(struct dm_table *t);
d67ee213f   Mike Snitzer   dm: add presuspen...
62
  void dm_table_presuspend_undo_targets(struct dm_table *t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
  void dm_table_postsuspend_targets(struct dm_table *t);
8757b7764   Milan Broz   [PATCH] dm table:...
64
  int dm_table_resume_targets(struct dm_table *t);
7e0d574f2   Bart Van Assche   dm: introduce enu...
65
  enum dm_queue_mode dm_table_get_type(struct dm_table *t);
36a0456fb   Alasdair G Kergon   dm table: add imm...
66
  struct target_type *dm_table_get_immutable_target_type(struct dm_table *t);
16f122661   Mike Snitzer   dm: optimize dm_m...
67
  struct dm_target *dm_table_get_immutable_target(struct dm_table *t);
f083b09b7   Mike Snitzer   dm: set DM_TARGET...
68
  struct dm_target *dm_table_get_wildcard_target(struct dm_table *t);
545ed20e6   Toshi Kani   dm: add infrastru...
69
  bool dm_table_bio_based(struct dm_table *t);
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
70
  bool dm_table_request_based(struct dm_table *t);
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
71
72
  void dm_table_free_md_mempools(struct dm_table *t);
  struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);
2e9ee0955   Pankaj Gupta   dm: enable synchr...
73
74
75
76
  bool dm_table_supports_dax(struct dm_table *t, iterate_devices_callout_fn fn,
  			   int *blocksize);
  int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
  			   sector_t start, sector_t len, void *data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77

a5664dad7   Mike Snitzer   dm ioctl: make bi...
78
79
  void dm_lock_md_type(struct mapped_device *md);
  void dm_unlock_md_type(struct mapped_device *md);
7e0d574f2   Bart Van Assche   dm: introduce enu...
80
81
  void dm_set_md_type(struct mapped_device *md, enum dm_queue_mode type);
  enum dm_queue_mode dm_get_md_type(struct mapped_device *md);
36a0456fb   Alasdair G Kergon   dm table: add imm...
82
  struct target_type *dm_get_immutable_target_type(struct mapped_device *md);
a5664dad7   Mike Snitzer   dm ioctl: make bi...
83

591ddcfc4   Mike Snitzer   dm: allow immutab...
84
  int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t);
4a0b4ddf2   Mike Snitzer   dm: do not initia...
85

512875bd9   Jun'ichi Nomura   dm: table detect ...
86
  /*
169e2cc27   Mike Snitzer   dm: allow error t...
87
88
89
90
91
   * To check whether the target type is bio-based or not (request-based).
   */
  #define dm_target_bio_based(t) ((t)->type->map != NULL)
  
  /*
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
92
93
   * To check whether the target type is request-based or not (bio-based).
   */
eb8db831b   Christoph Hellwig   dm: always defer ...
94
  #define dm_target_request_based(t) ((t)->type->clone_and_map_rq != NULL)
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
95

169e2cc27   Mike Snitzer   dm: allow error t...
96
97
98
99
100
  /*
   * To check whether the target type is a hybrid (capable of being
   * either request-based or bio-based).
   */
  #define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
103
104
105
106
  /*-----------------------------------------------------------------
   * A registry of target types.
   *---------------------------------------------------------------*/
  int dm_target_init(void);
  void dm_target_exit(void);
  struct target_type *dm_get_target_type(const char *name);
45194e4f8   Cheng Renquan   dm target: remove...
107
  void dm_put_target_type(struct target_type *tt);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
109
  int dm_target_iterate(void (*iter_func)(struct target_type *tt,
  					void *param), void *param);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
  int dm_split_args(int *argc, char ***argvp, char *input);
  
  /*
432a212c0   Mike Anderson   dm: add dm_deleti...
113
114
115
116
117
   * Is this mapped_device being deleted?
   */
  int dm_deleting_md(struct mapped_device *md);
  
  /*
4f186f8bb   Kiyoshi Ueda   dm: rename dm_sus...
118
119
120
121
122
   * Is this mapped_device suspended?
   */
  int dm_suspended_md(struct mapped_device *md);
  
  /*
ffcc39364   Mike Snitzer   dm: enhance inter...
123
124
125
126
127
128
129
130
131
   * Internal suspend and resume methods.
   */
  int dm_suspended_internally_md(struct mapped_device *md);
  void dm_internal_suspend_fast(struct mapped_device *md);
  void dm_internal_resume_fast(struct mapped_device *md);
  void dm_internal_suspend_noflush(struct mapped_device *md);
  void dm_internal_resume(struct mapped_device *md);
  
  /*
2c140a246   Mikulas Patocka   dm: allow remove ...
132
133
134
135
136
137
138
139
140
141
   * Test if the device is scheduled for deferred remove.
   */
  int dm_test_deferred_remove_flag(struct mapped_device *md);
  
  /*
   * Try to remove devices marked for deferred removal.
   */
  void dm_deferred_remove(void);
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
145
146
147
148
   * The device-mapper can be driven through one of two interfaces;
   * ioctl or filesystem, depending which patch you have applied.
   */
  int dm_interface_init(void);
  void dm_interface_exit(void);
  
  /*
784aae735   Milan Broz   dm: add name and ...
149
150
151
152
153
154
   * sysfs interface
   */
  int dm_sysfs_init(struct mapped_device *md);
  void dm_sysfs_exit(struct mapped_device *md);
  struct kobject *dm_kobject(struct mapped_device *md);
  struct mapped_device *dm_get_from_kobject(struct kobject *kobj);
2995fa78e   Mikulas Patocka   dm sysfs: fix a m...
155
156
157
158
159
  
  /*
   * The kobject helper
   */
  void dm_kobject_release(struct kobject *kobj);
784aae735   Milan Broz   dm: add name and ...
160
161
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
162
163
164
165
166
167
168
   * Targets for linear and striped mappings
   */
  int dm_linear_init(void);
  void dm_linear_exit(void);
  
  int dm_stripe_init(void);
  void dm_stripe_exit(void);
3f77316de   Kiyoshi Ueda   dm: separate devi...
169
170
171
172
173
  /*
   * mapped_device operations
   */
  void dm_destroy(struct mapped_device *md);
  void dm_destroy_immediate(struct mapped_device *md);
5c6bd75d0   Alasdair G Kergon   [PATCH] dm: preve...
174
  int dm_open_count(struct mapped_device *md);
2c140a246   Mikulas Patocka   dm: allow remove ...
175
176
  int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only_deferred);
  int dm_cancel_deferred_remove(struct mapped_device *md);
fd2ed4d25   Mikulas Patocka   dm: add statistic...
177
  int dm_request_based(struct mapped_device *md);
86f1152b1   Benjamin Marzinski   dm: allow active ...
178
179
180
  int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode,
  			struct dm_dev **result);
  void dm_put_table_device(struct mapped_device *md, struct dm_dev *d);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181

3abf85b5b   Peter Rajnoha   dm ioctl: introdu...
182
183
  int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
  		      unsigned cookie);
69267a30b   Alasdair G Kergon   dm: trigger chang...
184

fd2ed4d25   Mikulas Patocka   dm: add statistic...
185
186
  void dm_internal_suspend(struct mapped_device *md);
  void dm_internal_resume(struct mapped_device *md);
952b35576   Mikulas Patocka   dm io: use slab f...
187
188
  int dm_io_init(void);
  void dm_io_exit(void);
945fa4d28   Mikulas Patocka   dm kcopyd: remove...
189
190
  int dm_kcopyd_init(void);
  void dm_kcopyd_exit(void);
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
191
192
193
  /*
   * Mempool operations
   */
7e0d574f2   Bart Van Assche   dm: introduce enu...
194
  struct dm_md_mempools *dm_alloc_md_mempools(struct mapped_device *md, enum dm_queue_mode type,
0776aa0e3   Mike Snitzer   dm: ensure bio-ba...
195
196
  					    unsigned integrity, unsigned per_bio_data_size,
  					    unsigned min_pool_size);
e6ee8c0b7   Kiyoshi Ueda   dm: enable reques...
197
  void dm_free_md_mempools(struct dm_md_mempools *pools);
fd2ed4d25   Mikulas Patocka   dm: add statistic...
198
  /*
4cc96131a   Mike Snitzer   dm: move request-...
199
   * Various helpers
fd2ed4d25   Mikulas Patocka   dm: add statistic...
200
   */
e8603136c   Mike Snitzer   dm: add reserved_...
201
  unsigned dm_get_reserved_bio_based_ios(void);
0ce65797a   Mike Snitzer   dm: impose config...
202

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203
  #endif