]> sourceware.org Git - lvm2.git/blame - lib/activate/activate.h
dev-type: detect mixed dos partition with gpt's PMBR
[lvm2.git] / lib / activate / activate.h
CommitLineData
b1713d28 1/*
6606c3ae 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
ca9cbd92 3 * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
b1713d28 4 *
6606c3ae
AK
5 * This file is part of LVM2.
6 *
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
be684599 9 * of the GNU Lesser General Public License v.2.1.
6606c3ae 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae 12 * along with this program; if not, write to the Free Software Foundation,
fcbef05a 13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
b1713d28
JT
14 */
15
a381c45a
AK
16#ifndef LVM_ACTIVATE_H
17#define LVM_ACTIVATE_H
b1713d28 18
7f97c7ea 19#include "lib/metadata/metadata-exported.h"
199e490e 20
199e490e
AK
21struct lvinfo {
22 int exists;
23 int suspended;
24 unsigned int open_count;
25 int major;
26 int minor;
27 int read_only;
5f4b2acf
AK
28 int live_table;
29 int inactive_table;
a6b22cf3 30 uint32_t read_ahead;
199e490e 31};
3080a754 32
d7e5f038
PR
33typedef enum {
34 SEG_STATUS_NONE,
35 SEG_STATUS_CACHE,
36 SEG_STATUS_RAID,
37 SEG_STATUS_SNAPSHOT,
38 SEG_STATUS_THIN,
e34b0044 39 SEG_STATUS_THIN_POOL,
0dafd159 40 SEG_STATUS_VDO_POOL,
3ae55695 41 SEG_STATUS_WRITECACHE,
d9e8895a 42 SEG_STATUS_INTEGRITY,
e34b0044 43 SEG_STATUS_UNKNOWN
d7e5f038
PR
44} lv_seg_status_type_t;
45
46struct lv_seg_status {
47 struct dm_pool *mem; /* input */
d202f43f 48 const struct lv_segment *seg; /* input */
d7e5f038 49 lv_seg_status_type_t type; /* output */
b3a348c0
ZK
50 union {
51 struct dm_status_cache *cache;
52 struct dm_status_raid *raid;
53 struct dm_status_snapshot *snapshot;
54 struct dm_status_thin *thin;
55 struct dm_status_thin_pool *thin_pool;
3ae55695 56 struct dm_status_writecache *writecache;
d9e8895a 57 struct dm_status_integrity *integrity;
0dafd159 58 struct lv_status_vdo vdo_pool;
b3a348c0 59 };
d7e5f038
PR
60};
61
62struct lv_with_info_and_seg_status {
e34b0044 63 int info_ok;
6fd20be6 64 const struct logical_volume *lv; /* output */
d202f43f 65 struct lvinfo info; /* output */
d7e5f038 66 int seg_part_of_lv; /* output */
6fd20be6
ZK
67 struct lv_seg_status seg_status; /* output, see lv_seg_status */
68 /* TODO: add extra status for snapshot origin */
d7e5f038
PR
69};
70
81beded3
ZK
71struct lv_activate_opts {
72 int exclusive;
73 int origin_only;
74 int no_merging;
8ed0b6f3 75 int send_messages;
2caa558e 76 int skip_in_use;
10d0d9c7 77 unsigned revert;
a18dcfb5 78 unsigned read_only;
039bdad7
PR
79 unsigned noscan; /* Mark this LV to avoid its scanning. This also
80 directs udev to use proper udev flag to avoid
81 any scanning in udev. This udev flag is automatically
82 dropped in udev db on any spurious event that follows. */
83 unsigned temporary; /* Mark this LV as temporary. It means, the LV
84 * is created, used and deactivated within single
85 * LVM command execution. Such LVs are mostly helper
86 * LVs to do some action or cleanup before the proper
87 * LV is created. This also directs udev to use proper
88 * set of flags to avoid any scanning in udev. These udev
89 * flags are persistent in udev db for any spurious event
90 * that follows. */
6954de22 91 unsigned resuming; /* Set when resuming after a suspend. */
eb3597ac 92 const struct logical_volume *component_lv;
81beded3
ZK
93};
94
b5f8f452 95void set_activation(int activation, int silent);
8ef2b021 96int activation(void);
d1d9800e 97
fae0c576
AK
98int driver_version(char *version, size_t size);
99int library_version(char *version, size_t size);
100
ed82bfd2 101int module_present(struct cmd_context *cmd, const char *target_name);
4d116d7a
ZK
102int target_present_version(struct cmd_context *cmd, const char *target_name,
103 int use_modprobe, uint32_t *maj,
104 uint32_t *min, uint32_t *patchlevel);
ed82bfd2
AK
105int target_present(struct cmd_context *cmd, const char *target_name,
106 int use_modprobe);
bbf83db1 107int target_version(const char *target_name, uint32_t *maj,
d1e8046f 108 uint32_t *min, uint32_t *patchlevel);
0d67bc96 109
990f4f7c 110int get_dm_active_devices(const struct volume_group *vg, struct dm_list **devs,
0d67bc96 111 unsigned *devs_features);
990f4f7c
DT
112int devno_dm_uuid(struct cmd_context *cmd, int major, int minor,
113 char *uuid_buf, size_t uuid_buf_size);
114int dev_dm_uuid(struct cmd_context *cmd, struct device *dev,
115 char *uuid_buf, size_t uuid_buf_size);
0d67bc96 116
ff05ed7a 117int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
a3390bb5 118int lvm_dm_prefix_check(int major, int minor, const char *prefix);
6c81ed26 119int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
2c44337b 120 struct dm_list *modules);
6c81ed26 121int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,
2c44337b 122 struct dm_list *modules);
d1f4953a 123
2293567c 124void activation_release(void);
914c9723
AK
125void activation_exit(void);
126
2d6fcbf6 127/* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
84cdf85b 128int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive,
4312b096 129 const struct logical_volume *lv, const struct logical_volume *lv_pre);
84cdf85b 130int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, const struct logical_volume *lv);
c054e7cc 131int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
84cdf85b 132 unsigned origin_only, unsigned exclusive, unsigned revert, const struct logical_volume *lv);
039bdad7 133int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive,
84cdf85b 134 int noscan, int temporary, const struct logical_volume *lv);
039bdad7 135int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive,
84cdf85b
ZK
136 int noscan, int temporary, const struct logical_volume *lv);
137int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logical_volume *lv);
a9953411 138
f7dd6d84
AK
139int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
140
95d68f1d
HM
141int lv_deactivate_any_missing_subdevs(const struct logical_volume *lv);
142
da30b4a7
DT
143int activate_lv(struct cmd_context *cmd, const struct logical_volume *lv);
144int deactivate_lv(struct cmd_context *cmd, const struct logical_volume *lv);
145int suspend_lv(struct cmd_context *cmd, const struct logical_volume *lv);
146int suspend_lv_origin(struct cmd_context *cmd, const struct logical_volume *lv);
147int resume_lv(struct cmd_context *cmd, const struct logical_volume *lv);
148int resume_lv_origin(struct cmd_context *cmd, const struct logical_volume *lv);
149int revert_lv(struct cmd_context *cmd, const struct logical_volume *lv);
150
a62ee8ad 151/*
83308fdf
PR
152 * Returns 1 if info structure has been populated, else 0 on failure.
153 * When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise.
a62ee8ad 154 */
e8905d98
ZK
155int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_layer,
156 struct lvinfo *info, int with_open_count, int with_read_ahead);
80b2de9e
ZK
157int lv_info_with_name_check(struct cmd_context *cmd, const struct logical_volume *lv,
158 int use_layer, struct lvinfo *info);
658b5812 159
83308fdf
PR
160/*
161 * Returns 1 if lv_info_and_seg_status structure has been populated,
162 * else 0 on failure or if device not active locally.
163 *
d202f43f 164 * lv_info_with_seg_status is the same as calling lv_info and then lv_status,
83308fdf
PR
165 * but this fn tries to do that with one ioctl if possible.
166 */
6fd20be6
ZK
167int lv_info_with_seg_status(struct cmd_context *cmd,
168 const struct lv_segment *lv_seg,
d202f43f 169 struct lv_with_info_and_seg_status *status,
a2c1024f
PR
170 int with_open_count, int with_read_ahead);
171
01181a29 172int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used);
125712be 173
658b5812 174/*
0d61a171 175 * Returns 1 if activate has been set: 1 = activate; 0 = don't.
658b5812
AK
176 */
177int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
0d61a171 178 int *activate, const struct logical_volume *lv);
95ced7a7
PR
179/*
180 * Checks against the auto_activation_volume_list and
181 * returns 1 if the LV should be activated, 0 otherwise.
182 */
183int lv_passes_auto_activation_filter(struct cmd_context *cmd, struct logical_volume *lv);
658b5812 184
d345bf2c 185int lv_check_transient(struct logical_volume *lv);
1951dba9
AL
186/*
187 * Returns 1 if percent has been set, else 0.
188 */
cfed0d09 189int lv_snapshot_percent(const struct logical_volume *lv, dm_percent_t *percent);
aec21154 190int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
cfed0d09
PR
191 int wait, dm_percent_t *percent, uint32_t *event_nr);
192int lv_raid_percent(const struct logical_volume *lv, dm_percent_t *percent);
e2354ea3
HM
193int lv_raid_dev_count(const struct logical_volume *lv, uint32_t *dev_cnt);
194int lv_raid_data_offset(const struct logical_volume *lv, uint64_t *data_offset);
c8242e5c 195int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health);
ff64e350
JB
196int lv_raid_mismatch_count(const struct logical_volume *lv, uint64_t *cnt);
197int lv_raid_sync_action(const struct logical_volume *lv, char **sync_action);
198int lv_raid_message(const struct logical_volume *lv, const char *msg);
a9b4acd5 199int lv_raid_status(const struct logical_volume *lv, struct lv_status_raid **status);
3ae55695 200int lv_writecache_message(const struct logical_volume *lv, const char *msg);
876c4a1b 201int lv_cache_status(const struct logical_volume *cache_lv,
ab491204 202 struct lv_status_cache **status);
572983d7 203int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id);
4de6f580
ZK
204int lv_thin_status(const struct logical_volume *lv, int flush,
205 struct lv_status_thin **status);
206int lv_thin_pool_status(const struct logical_volume *lv, int flush,
207 struct lv_status_thin_pool **status);
4f708e87
ZK
208int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
209 struct lv_status_vdo **status);
3d367f33 210int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent);
1bed2caf
ZK
211int lv_vdo_pool_size_config(const struct logical_volume *lv,
212 struct vdo_pool_size_config *cfg);
2ba80b43 213
37ed70b9 214/*
6d52fb46 215 * Return number of LVs in the VG that are active.
37ed70b9 216 */
499a1616 217int lvs_in_vg_activated(const struct volume_group *vg);
08c9ff43 218int lvs_in_vg_opened(const struct volume_group *vg);
a381c45a 219
499a1616 220int lv_is_active(const struct logical_volume *lv);
3e3d5d85 221
51c83f14
ZK
222int lv_passes_readonly_filter(const struct logical_volume *lv);
223
ca9cbd92
ZK
224/* Check is any component LV is active */
225const struct logical_volume *lv_component_is_active(const struct logical_volume *lv);
226const struct logical_volume *lv_holder_is_active(const struct logical_volume *lv);
227int deactivate_lv_with_sub_lv(const struct logical_volume *lv);
228
84cdf85b 229int lv_has_target_type(struct dm_pool *mem, const struct logical_volume *lv,
1f661c5d
MS
230 const char *layer, const char *target_type);
231
84cdf85b 232int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume *lv,
876c4a1b 233 const struct lv_activate_opts *laopts, int monitor);
3e3d5d85 234
d1e8046f 235#ifdef DMEVENTD
1140d708 236# include "daemons/dmeventd/libdevmapper-event.h"
27399755 237char *get_monitor_dso_path(struct cmd_context *cmd, int id);
876c4a1b 238int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,
d90a6478 239 const struct logical_volume *lv, int *pending, int *monitored);
84cdf85b 240int target_register_events(struct cmd_context *cmd, const char *dso, const struct logical_volume *lv,
d1e8046f
AK
241 int evmask __attribute__((unused)), int set, int timeout);
242#endif
243
8dd6036d
AK
244int add_linear_area_to_dtree(struct dm_tree_node *node, uint64_t size,
245 uint32_t extent_size, int use_linear_target,
246 const char *vgname, const char *lvname);
247
352a99b9
AK
248/*
249 * Returns 1 if PV has a dependency tree that uses anything in VG.
250 */
898e6f8e 251int pv_uses_vg(struct physical_volume *pv,
352a99b9
AK
252 struct volume_group *vg);
253
00d8ab84
PR
254struct dev_usable_check_params {
255 unsigned int check_empty:1;
256 unsigned int check_blocked:1;
257 unsigned int check_suspended:1;
258 unsigned int check_error_target:1;
259 unsigned int check_reserved:1;
bfcecbbc 260 unsigned int check_lv:1;
00d8ab84
PR
261};
262
f247a4e7 263/*
c95f17ea
JB
264 * Returns 1 if mapped device is not suspended, blocked or
265 * is using a reserved name.
f247a4e7 266 */
24943fe9 267int dm_device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usable_check_params check, int *is_lv);
c95f17ea 268
937a21f0
ZK
269/*
270 * Declaration moved here from fs.h to keep header fs.h hidden
271 */
272void fs_unlock(void);
273
1216efdf 274#define TARGET_NAME_CACHE "cache"
3ae55695 275#define TARGET_NAME_WRITECACHE "writecache"
d9e8895a 276#define TARGET_NAME_INTEGRITY "integrity"
1216efdf
AK
277#define TARGET_NAME_ERROR "error"
278#define TARGET_NAME_ERROR_OLD "erro" /* Truncated in older kernels */
279#define TARGET_NAME_LINEAR "linear"
280#define TARGET_NAME_MIRROR "mirror"
281#define TARGET_NAME_RAID "raid"
282#define TARGET_NAME_SNAPSHOT "snapshot"
283#define TARGET_NAME_SNAPSHOT_MERGE "snapshot-merge"
284#define TARGET_NAME_SNAPSHOT_ORIGIN "snapshot-origin"
285#define TARGET_NAME_STRIPED "striped"
286#define TARGET_NAME_THIN "thin"
287#define TARGET_NAME_THIN_POOL "thin-pool"
a8f84f78 288#define TARGET_NAME_VDO "vdo"
1216efdf
AK
289#define TARGET_NAME_ZERO "zero"
290
291#define MODULE_NAME_CLUSTERED_MIRROR "clog"
292#define MODULE_NAME_CACHE TARGET_NAME_CACHE
3ae55695 293#define MODULE_NAME_WRITECACHE TARGET_NAME_WRITECACHE
d9e8895a 294#define MODULE_NAME_INTEGRITY TARGET_NAME_INTEGRITY
1216efdf
AK
295#define MODULE_NAME_ERROR TARGET_NAME_ERROR
296#define MODULE_NAME_LOG_CLUSTERED "log-clustered"
297#define MODULE_NAME_LOG_USERSPACE "log-userspace"
298#define MODULE_NAME_MIRROR TARGET_NAME_MIRROR
299#define MODULE_NAME_SNAPSHOT TARGET_NAME_SNAPSHOT
300#define MODULE_NAME_RAID TARGET_NAME_RAID
2e05f601 301#define MODULE_NAME_VDO "kvdo" /* does NOT use dm- prefix */
1216efdf
AK
302#define MODULE_NAME_ZERO TARGET_NAME_ZERO
303
b1713d28 304#endif
This page took 0.240098 seconds and 6 git commands to generate.