]>
Commit | Line | Data |
---|---|---|
b1713d28 | 1 | /* |
67cdbd7e | 2 | * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. |
be684599 | 3 | * Copyright (C) 2004-2007 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 AK |
12 | * along with this program; if not, write to the Free Software Foundation, |
13 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
b1713d28 JT |
14 | */ |
15 | ||
d1d9800e | 16 | #include "lib.h" |
a381c45a | 17 | #include "metadata.h" |
b1713d28 | 18 | #include "activate.h" |
914c9723 | 19 | #include "memlock.h" |
78125be9 | 20 | #include "display.h" |
f7a14956 | 21 | #include "fs.h" |
f894b4b1 | 22 | #include "lvm-exec.h" |
7d1552c9 | 23 | #include "lvm-file.h" |
41b2fd5f | 24 | #include "lvm-string.h" |
413cc918 | 25 | #include "toolcontext.h" |
de6c9183 | 26 | #include "dev_manager.h" |
de17d760 | 27 | #include "str_list.h" |
4922197a | 28 | #include "config.h" |
352a99b9 | 29 | #include "filter.h" |
15d91f5a | 30 | #include "segtype.h" |
12137231 JT |
31 | |
32 | #include <limits.h> | |
5986ec94 | 33 | #include <fcntl.h> |
914c9723 | 34 | #include <unistd.h> |
12137231 | 35 | |
6d52fb46 | 36 | #define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args) |
b1713d28 | 37 | |
7d1552c9 AK |
38 | int lvm1_present(struct cmd_context *cmd) |
39 | { | |
40 | char path[PATH_MAX]; | |
41 | ||
0550c1b6 | 42 | if (dm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir) |
7d1552c9 AK |
43 | < 0) { |
44 | log_error("LVM1 proc global snprintf failed"); | |
45 | return 0; | |
46 | } | |
47 | ||
48 | if (path_exists(path)) | |
49 | return 1; | |
50 | else | |
51 | return 0; | |
52 | } | |
53 | ||
6c81ed26 AK |
54 | int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg, |
55 | struct list *modules) | |
56 | { | |
57 | unsigned int s; | |
58 | struct lv_segment *seg2, *snap_seg; | |
59 | struct list *snh; | |
60 | ||
61 | if (seg->segtype->ops->modules_needed && | |
62 | !seg->segtype->ops->modules_needed(mem, seg, modules)) { | |
63 | log_error("module string allocation failed"); | |
64 | return 0; | |
65 | } | |
66 | ||
67 | if (lv_is_origin(seg->lv)) | |
68 | list_iterate(snh, &seg->lv->snapshot_segs) | |
69 | if (!list_lv_modules(mem, | |
70 | list_struct_base(snh, | |
71 | struct lv_segment, | |
72 | origin_list)->cow, | |
73 | modules)) | |
74 | return_0; | |
75 | ||
76 | if (lv_is_cow(seg->lv)) { | |
77 | snap_seg = find_cow(seg->lv); | |
78 | if (snap_seg->segtype->ops->modules_needed && | |
79 | !snap_seg->segtype->ops->modules_needed(mem, snap_seg, | |
80 | modules)) { | |
81 | log_error("snap_seg module string allocation failed"); | |
82 | return 0; | |
83 | } | |
84 | } | |
85 | ||
86 | for (s = 0; s < seg->area_count; s++) { | |
87 | switch (seg_type(seg, s)) { | |
88 | case AREA_LV: | |
89 | seg2 = find_seg_by_le(seg_lv(seg, s), seg_le(seg, s)); | |
90 | if (seg2 && !list_segment_modules(mem, seg2, modules)) | |
91 | return_0; | |
92 | break; | |
93 | case AREA_PV: | |
94 | case AREA_UNASSIGNED: | |
95 | ; | |
96 | } | |
97 | } | |
98 | ||
99 | return 1; | |
100 | } | |
101 | ||
102 | int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv, | |
103 | struct list *modules) | |
104 | { | |
105 | struct lv_segment *seg; | |
106 | ||
107 | list_iterate_items(seg, &lv->segments) | |
108 | if (!list_segment_modules(mem, seg, modules)) | |
109 | return_0; | |
110 | ||
111 | return 1; | |
112 | } | |
113 | ||
199e490e AK |
114 | #ifndef DEVMAPPER_SUPPORT |
115 | void set_activation(int act) | |
116 | { | |
f2046e0a AK |
117 | static int warned = 0; |
118 | ||
119 | if (warned || !act) | |
120 | return; | |
121 | ||
122 | log_error("Compiled without libdevmapper support. " | |
123 | "Can't enable activation."); | |
124 | ||
125 | warned = 1; | |
199e490e AK |
126 | } |
127 | int activation(void) | |
128 | { | |
129 | return 0; | |
130 | } | |
131 | int library_version(char *version, size_t size) | |
132 | { | |
133 | return 0; | |
134 | } | |
135 | int driver_version(char *version, size_t size) | |
136 | { | |
137 | return 0; | |
138 | } | |
bbf83db1 AK |
139 | int target_version(const char *target_name, uint32_t *maj, |
140 | uint32_t *min, uint32_t *patchlevel) | |
141 | { | |
142 | return 0; | |
143 | } | |
0ce83a83 | 144 | int target_present(const char *target_name, int use_modprobe) |
d1f4953a AK |
145 | { |
146 | return 0; | |
147 | } | |
f894b4b1 | 148 | int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, struct lvinfo *info, |
a6b22cf3 | 149 | int with_open_count, int with_read_ahead) |
199e490e AK |
150 | { |
151 | return 0; | |
152 | } | |
4bd9480d | 153 | int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, |
a6b22cf3 | 154 | struct lvinfo *info, int with_open_count, int with_read_ahead) |
4bd9480d AK |
155 | { |
156 | return 0; | |
157 | } | |
472ac5bd | 158 | int lv_snapshot_percent(const struct logical_volume *lv, float *percent) |
199e490e AK |
159 | { |
160 | return 0; | |
161 | } | |
472ac5bd AK |
162 | int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv, |
163 | int wait, float *percent, uint32_t *event_nr) | |
10b29b8d AK |
164 | { |
165 | return 0; | |
166 | } | |
199e490e AK |
167 | int lvs_in_vg_activated(struct volume_group *vg) |
168 | { | |
169 | return 0; | |
170 | } | |
1bf5aae9 | 171 | int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg) |
b45c9f49 AK |
172 | { |
173 | return 0; | |
174 | } | |
199e490e AK |
175 | int lvs_in_vg_opened(struct volume_group *vg) |
176 | { | |
177 | return 0; | |
178 | } | |
658b5812 AK |
179 | int lv_suspend(struct cmd_context *cmd, const char *lvid_s) |
180 | { | |
181 | return 1; | |
182 | } | |
199e490e AK |
183 | int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) |
184 | { | |
185 | return 1; | |
186 | } | |
658b5812 AK |
187 | int lv_resume(struct cmd_context *cmd, const char *lvid_s) |
188 | { | |
189 | return 1; | |
190 | } | |
199e490e AK |
191 | int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s) |
192 | { | |
193 | return 1; | |
194 | } | |
195 | int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) | |
196 | { | |
197 | return 1; | |
198 | } | |
658b5812 AK |
199 | int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s, |
200 | int *activate_lv) | |
201 | { | |
202 | return 1; | |
203 | } | |
07d31831 | 204 | int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive) |
199e490e AK |
205 | { |
206 | return 1; | |
207 | } | |
07d31831 | 208 | int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive) |
658b5812 AK |
209 | { |
210 | return 1; | |
211 | } | |
f7dd6d84 AK |
212 | |
213 | int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv) | |
214 | { | |
215 | return 1; | |
216 | } | |
217 | ||
0ce83a83 | 218 | int pv_uses_vg(struct physical_volume *pv, |
3e3d5d85 | 219 | struct volume_group *vg) |
352a99b9 AK |
220 | { |
221 | return 0; | |
222 | } | |
223 | ||
2293567c AK |
224 | void activation_release(void) |
225 | { | |
226 | return; | |
227 | } | |
228 | ||
914c9723 AK |
229 | void activation_exit(void) |
230 | { | |
231 | return; | |
232 | } | |
199e490e AK |
233 | |
234 | #else /* DEVMAPPER_SUPPORT */ | |
235 | ||
d1d9800e AK |
236 | static int _activation = 1; |
237 | ||
8ef2b021 | 238 | void set_activation(int act) |
d1d9800e | 239 | { |
8ef2b021 | 240 | if (act == _activation) |
d1d9800e AK |
241 | return; |
242 | ||
8ef2b021 | 243 | _activation = act; |
d1d9800e AK |
244 | if (_activation) |
245 | log_verbose("Activation enabled. Device-mapper kernel " | |
246 | "driver will be used."); | |
247 | else | |
e7ddf416 | 248 | log_warn("WARNING: Activation disabled. No device-mapper " |
bfe2b548 | 249 | "interaction will be attempted."); |
d1d9800e AK |
250 | } |
251 | ||
8ef2b021 | 252 | int activation(void) |
d1d9800e AK |
253 | { |
254 | return _activation; | |
255 | } | |
256 | ||
de17d760 AK |
257 | static int _passes_activation_filter(struct cmd_context *cmd, |
258 | struct logical_volume *lv) | |
259 | { | |
25579907 | 260 | const struct config_node *cn; |
de17d760 AK |
261 | struct config_value *cv; |
262 | char *str; | |
263 | char path[PATH_MAX]; | |
264 | ||
2293567c | 265 | if (!(cn = find_config_tree_node(cmd, "activation/volume_list"))) { |
25579907 | 266 | /* If no host tags defined, activate */ |
de17d760 AK |
267 | if (list_empty(&cmd->tags)) |
268 | return 1; | |
269 | ||
270 | /* If any host tag matches any LV or VG tag, activate */ | |
271 | if (str_list_match_list(&cmd->tags, &lv->tags) || | |
272 | str_list_match_list(&cmd->tags, &lv->vg->tags)) | |
273 | return 1; | |
274 | ||
275 | /* Don't activate */ | |
276 | return 0; | |
277 | } | |
278 | ||
279 | for (cv = cn->v; cv; cv = cv->next) { | |
280 | if (cv->type != CFG_STRING) { | |
281 | log_error("Ignoring invalid string in config file " | |
282 | "activation/volume_list"); | |
283 | continue; | |
284 | } | |
285 | str = cv->v.str; | |
286 | if (!*str) { | |
287 | log_error("Ignoring empty string in config file " | |
288 | "activation/volume_list"); | |
289 | continue; | |
290 | } | |
291 | ||
292 | /* Tag? */ | |
293 | if (*str == '@') { | |
294 | str++; | |
295 | if (!*str) { | |
296 | log_error("Ignoring empty tag in config file " | |
297 | "activation/volume_list"); | |
298 | continue; | |
299 | } | |
300 | /* If any host tag matches any LV or VG tag, activate */ | |
301 | if (!strcmp(str, "*")) { | |
302 | if (str_list_match_list(&cmd->tags, &lv->tags) | |
303 | || str_list_match_list(&cmd->tags, | |
304 | &lv->vg->tags)) | |
305 | return 1; | |
306 | else | |
307 | continue; | |
308 | } | |
309 | /* If supplied tag matches LV or VG tag, activate */ | |
310 | if (str_list_match_item(&lv->tags, str) || | |
311 | str_list_match_item(&lv->vg->tags, str)) | |
312 | return 1; | |
313 | else | |
314 | continue; | |
315 | } | |
13835b5f | 316 | if (!strchr(str, '/')) { |
de17d760 AK |
317 | /* vgname supplied */ |
318 | if (!strcmp(str, lv->vg->name)) | |
319 | return 1; | |
320 | else | |
321 | continue; | |
322 | } | |
323 | /* vgname/lvname */ | |
0550c1b6 | 324 | if (dm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name, |
de17d760 | 325 | lv->name) < 0) { |
0550c1b6 | 326 | log_error("dm_snprintf error from %s/%s", lv->vg->name, |
de17d760 AK |
327 | lv->name); |
328 | continue; | |
329 | } | |
330 | if (!strcmp(path, str)) | |
331 | return 1; | |
332 | } | |
333 | ||
334 | return 0; | |
335 | } | |
336 | ||
fae0c576 AK |
337 | int library_version(char *version, size_t size) |
338 | { | |
d1d9800e AK |
339 | if (!activation()) |
340 | return 0; | |
341 | ||
f894b4b1 | 342 | return dm_get_library_version(version, size); |
fae0c576 AK |
343 | } |
344 | ||
fae0c576 AK |
345 | int driver_version(char *version, size_t size) |
346 | { | |
d1d9800e AK |
347 | if (!activation()) |
348 | return 0; | |
349 | ||
fae0c576 | 350 | log_very_verbose("Getting driver version"); |
fae0c576 | 351 | |
f894b4b1 | 352 | return dm_driver_version(version, size); |
fae0c576 AK |
353 | } |
354 | ||
bbf83db1 AK |
355 | int target_version(const char *target_name, uint32_t *maj, |
356 | uint32_t *min, uint32_t *patchlevel) | |
d1f4953a AK |
357 | { |
358 | int r = 0; | |
359 | struct dm_task *dmt; | |
360 | struct dm_versions *target, *last_target; | |
361 | ||
d1f4953a | 362 | log_very_verbose("Getting target version for %s", target_name); |
5f4b2acf AK |
363 | if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS))) |
364 | return_0; | |
d1f4953a AK |
365 | |
366 | if (!dm_task_run(dmt)) { | |
367 | log_debug("Failed to get %s target version", target_name); | |
368 | /* Assume this was because LIST_VERSIONS isn't supported */ | |
369 | return 1; | |
370 | } | |
371 | ||
372 | target = dm_task_get_versions(dmt); | |
373 | ||
374 | do { | |
375 | last_target = target; | |
376 | ||
377 | if (!strcmp(target_name, target->name)) { | |
378 | r = 1; | |
bbf83db1 AK |
379 | *maj = target->version[0]; |
380 | *min = target->version[1]; | |
381 | *patchlevel = target->version[2]; | |
d1f4953a AK |
382 | goto out; |
383 | } | |
384 | ||
385 | target = (void *) target + target->next; | |
386 | } while (last_target != target); | |
387 | ||
388 | out: | |
389 | dm_task_destroy(dmt); | |
390 | ||
391 | return r; | |
392 | } | |
393 | ||
5619c629 | 394 | int module_present(const char *target_name) |
f894b4b1 | 395 | { |
5619c629 | 396 | int ret = 0; |
03b49fe1 | 397 | #ifdef MODPROBE_CMD |
f894b4b1 | 398 | char module[128]; |
5619c629 MB |
399 | |
400 | if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) { | |
401 | log_error("module_present module name too long: %s", | |
402 | target_name); | |
403 | return 0; | |
404 | } | |
405 | ||
406 | ret = exec_cmd(MODPROBE_CMD, module, "", ""); | |
03b49fe1 | 407 | #endif |
5619c629 MB |
408 | return ret; |
409 | } | |
410 | ||
411 | int target_present(const char *target_name, int use_modprobe) | |
412 | { | |
413 | uint32_t maj, min, patchlevel; | |
f894b4b1 AK |
414 | |
415 | if (!activation()) | |
416 | return 0; | |
417 | ||
418 | #ifdef MODPROBE_CMD | |
5f4b2acf | 419 | if (use_modprobe) { |
bbf83db1 | 420 | if (target_version(target_name, &maj, &min, &patchlevel)) |
5f4b2acf | 421 | return 1; |
f894b4b1 | 422 | |
5619c629 | 423 | if (!module_present(target_name)) |
5f4b2acf | 424 | return_0; |
f894b4b1 AK |
425 | } |
426 | #endif | |
427 | ||
bbf83db1 | 428 | return target_version(target_name, &maj, &min, &patchlevel); |
f894b4b1 AK |
429 | } |
430 | ||
de6c9183 JT |
431 | /* |
432 | * Returns 1 if info structure populated, else 0 on failure. | |
433 | */ | |
f894b4b1 | 434 | static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int with_mknodes, |
a6b22cf3 | 435 | struct lvinfo *info, int with_open_count, int with_read_ahead, unsigned by_uuid_only) |
37ed70b9 | 436 | { |
199e490e | 437 | struct dm_info dminfo; |
b45c9f49 | 438 | char *name = NULL; |
4a624ca0 | 439 | |
d1d9800e AK |
440 | if (!activation()) |
441 | return 0; | |
442 | ||
b45c9f49 AK |
443 | if (!by_uuid_only && |
444 | !(name = build_dm_name(cmd->mem, lv->vg->name, lv->name, NULL))) | |
5f4b2acf | 445 | return_0; |
4a624ca0 | 446 | |
f894b4b1 | 447 | log_debug("Getting device info for %s", name); |
03b49fe1 | 448 | if (!dev_manager_info(lv->vg->cmd->mem, name, lv, with_mknodes, |
a6b22cf3 AK |
449 | with_open_count, with_read_ahead, &dminfo, |
450 | &info->read_ahead)) { | |
b45c9f49 AK |
451 | if (name) |
452 | dm_pool_free(cmd->mem, name); | |
5f4b2acf | 453 | return_0; |
f894b4b1 | 454 | } |
4a624ca0 | 455 | |
199e490e AK |
456 | info->exists = dminfo.exists; |
457 | info->suspended = dminfo.suspended; | |
458 | info->open_count = dminfo.open_count; | |
459 | info->major = dminfo.major; | |
460 | info->minor = dminfo.minor; | |
461 | info->read_only = dminfo.read_only; | |
5f4b2acf AK |
462 | info->live_table = dminfo.live_table; |
463 | info->inactive_table = dminfo.inactive_table; | |
199e490e | 464 | |
b45c9f49 AK |
465 | if (name) |
466 | dm_pool_free(cmd->mem, name); | |
467 | ||
f894b4b1 | 468 | return 1; |
de6c9183 | 469 | } |
a62ee8ad | 470 | |
f894b4b1 | 471 | int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, struct lvinfo *info, |
a6b22cf3 | 472 | int with_open_count, int with_read_ahead) |
8c0388e4 | 473 | { |
a6b22cf3 | 474 | return _lv_info(cmd, lv, 0, info, with_open_count, with_read_ahead, 0); |
8c0388e4 AK |
475 | } |
476 | ||
4bd9480d | 477 | int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, |
a6b22cf3 | 478 | struct lvinfo *info, int with_open_count, int with_read_ahead) |
4bd9480d AK |
479 | { |
480 | struct logical_volume *lv; | |
481 | ||
7a593325 | 482 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
4bd9480d AK |
483 | return 0; |
484 | ||
a6b22cf3 | 485 | return _lv_info(cmd, lv, 0, info, with_open_count, with_read_ahead, 0); |
4bd9480d AK |
486 | } |
487 | ||
1951dba9 AL |
488 | /* |
489 | * Returns 1 if percent set, else 0 on failure. | |
490 | */ | |
472ac5bd | 491 | int lv_snapshot_percent(const struct logical_volume *lv, float *percent) |
1951dba9 AL |
492 | { |
493 | int r; | |
494 | struct dev_manager *dm; | |
495 | ||
d1d9800e AK |
496 | if (!activation()) |
497 | return 0; | |
498 | ||
5f4b2acf AK |
499 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) |
500 | return_0; | |
1951dba9 | 501 | |
c826c0d1 | 502 | if (!(r = dev_manager_snapshot_percent(dm, lv, percent))) |
1951dba9 | 503 | stack; |
c826c0d1 | 504 | |
1951dba9 AL |
505 | dev_manager_destroy(dm); |
506 | ||
507 | return r; | |
508 | } | |
509 | ||
10b29b8d | 510 | /* FIXME Merge with snapshot_percent */ |
472ac5bd AK |
511 | int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv, |
512 | int wait, float *percent, uint32_t *event_nr) | |
10b29b8d AK |
513 | { |
514 | int r; | |
515 | struct dev_manager *dm; | |
b65b777d | 516 | struct lvinfo info; |
10b29b8d | 517 | |
876003dc AK |
518 | /* If mirrored LV is temporarily shrinked to 1 area (= linear), |
519 | * it should be considered in-sync. */ | |
520 | if (list_size(&lv->segments) == 1 && first_seg(lv)->area_count == 1) { | |
521 | *percent = 100.0; | |
522 | return 1; | |
523 | } | |
524 | ||
10b29b8d AK |
525 | if (!activation()) |
526 | return 0; | |
527 | ||
a6b22cf3 | 528 | if (!lv_info(cmd, lv, &info, 0, 0)) |
5f4b2acf | 529 | return_0; |
b65b777d AK |
530 | |
531 | if (!info.exists) | |
532 | return 0; | |
533 | ||
5f4b2acf AK |
534 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) |
535 | return_0; | |
10b29b8d AK |
536 | |
537 | if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr))) | |
538 | stack; | |
539 | ||
540 | dev_manager_destroy(dm); | |
541 | ||
542 | return r; | |
543 | } | |
544 | ||
b45c9f49 AK |
545 | static int _lv_active(struct cmd_context *cmd, struct logical_volume *lv, |
546 | unsigned by_uuid_only) | |
2ba80b43 | 547 | { |
199e490e | 548 | struct lvinfo info; |
2ba80b43 | 549 | |
a6b22cf3 | 550 | if (!_lv_info(cmd, lv, 0, &info, 0, 0, by_uuid_only)) { |
2ba80b43 | 551 | stack; |
de6c9183 | 552 | return -1; |
2ba80b43 JT |
553 | } |
554 | ||
de6c9183 | 555 | return info.exists; |
2ba80b43 JT |
556 | } |
557 | ||
f894b4b1 | 558 | static int _lv_open_count(struct cmd_context *cmd, struct logical_volume *lv) |
5986ec94 | 559 | { |
199e490e | 560 | struct lvinfo info; |
5986ec94 | 561 | |
a6b22cf3 | 562 | if (!lv_info(cmd, lv, &info, 1, 0)) { |
5986ec94 | 563 | stack; |
de6c9183 | 564 | return -1; |
5986ec94 JT |
565 | } |
566 | ||
de6c9183 | 567 | return info.open_count; |
5986ec94 JT |
568 | } |
569 | ||
658b5812 | 570 | static int _lv_activate_lv(struct logical_volume *lv) |
b1713d28 | 571 | { |
6d52fb46 | 572 | int r; |
de6c9183 | 573 | struct dev_manager *dm; |
b1713d28 | 574 | |
5f4b2acf AK |
575 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) |
576 | return_0; | |
ae2bb665 | 577 | |
0fe3a2c5 | 578 | if (!(r = dev_manager_activate(dm, lv))) |
6d52fb46 | 579 | stack; |
ae2bb665 | 580 | |
de6c9183 | 581 | dev_manager_destroy(dm); |
ae2bb665 | 582 | return r; |
b1713d28 | 583 | } |
a381c45a | 584 | |
5f4b2acf | 585 | static int _lv_preload(struct logical_volume *lv) |
0a5e4a14 | 586 | { |
de6c9183 JT |
587 | int r; |
588 | struct dev_manager *dm; | |
37ed70b9 | 589 | |
5f4b2acf AK |
590 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) |
591 | return_0; | |
592 | ||
593 | if (!(r = dev_manager_preload(dm, lv))) | |
6d52fb46 | 594 | stack; |
5f4b2acf AK |
595 | |
596 | dev_manager_destroy(dm); | |
597 | return r; | |
598 | } | |
599 | ||
600 | static int _lv_deactivate(struct logical_volume *lv) | |
601 | { | |
602 | int r; | |
603 | struct dev_manager *dm; | |
604 | ||
605 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) | |
606 | return_0; | |
37ed70b9 | 607 | |
de6c9183 | 608 | if (!(r = dev_manager_deactivate(dm, lv))) |
37ed70b9 | 609 | stack; |
37ed70b9 | 610 | |
de6c9183 JT |
611 | dev_manager_destroy(dm); |
612 | return r; | |
37ed70b9 JT |
613 | } |
614 | ||
9cd3426d | 615 | static int _lv_suspend_lv(struct logical_volume *lv, int lockfs) |
4a624ca0 | 616 | { |
20c5fcf7 AK |
617 | int r; |
618 | struct dev_manager *dm; | |
c2d72fd4 | 619 | |
5f4b2acf AK |
620 | if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) |
621 | return_0; | |
0a5e4a14 | 622 | |
9cd3426d | 623 | if (!(r = dev_manager_suspend(dm, lv, lockfs))) |
37ed70b9 | 624 | stack; |
0a5e4a14 | 625 | |
20c5fcf7 AK |
626 | dev_manager_destroy(dm); |
627 | return r; | |
6d52fb46 | 628 | } |
4a624ca0 | 629 | |
8c013da4 | 630 | /* |
f75c11ed | 631 | * These two functions return the number of visible LVs in the state, |
8c013da4 AK |
632 | * or -1 on error. |
633 | */ | |
b45c9f49 | 634 | static int _lvs_in_vg_activated(struct volume_group *vg, unsigned by_uuid_only) |
f047219b | 635 | { |
60f13f01 | 636 | struct lv_list *lvl; |
94b8220f | 637 | int count = 0; |
37ed70b9 | 638 | |
d1d9800e AK |
639 | if (!activation()) |
640 | return 0; | |
641 | ||
60f13f01 AK |
642 | list_iterate_items(lvl, &vg->lvs) { |
643 | if (lvl->lv->status & VISIBLE_LV) | |
b45c9f49 | 644 | count += (_lv_active(vg->cmd, lvl->lv, by_uuid_only) == 1); |
37ed70b9 JT |
645 | } |
646 | ||
647 | return count; | |
f047219b | 648 | } |
2ba80b43 | 649 | |
b45c9f49 AK |
650 | int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg) |
651 | { | |
652 | return _lvs_in_vg_activated(vg, 1); | |
653 | } | |
654 | ||
655 | int lvs_in_vg_activated(struct volume_group *vg) | |
656 | { | |
657 | return _lvs_in_vg_activated(vg, 0); | |
658 | } | |
659 | ||
08c9ff43 | 660 | int lvs_in_vg_opened(const struct volume_group *vg) |
2ba80b43 | 661 | { |
08c9ff43 | 662 | const struct lv_list *lvl; |
94b8220f | 663 | int count = 0; |
2ba80b43 | 664 | |
d1d9800e AK |
665 | if (!activation()) |
666 | return 0; | |
667 | ||
60f13f01 AK |
668 | list_iterate_items(lvl, &vg->lvs) { |
669 | if (lvl->lv->status & VISIBLE_LV) | |
f894b4b1 | 670 | count += (_lv_open_count(vg->cmd, lvl->lv) > 0); |
2ba80b43 JT |
671 | } |
672 | ||
673 | return count; | |
674 | } | |
413cc918 | 675 | |
5ca6698f DW |
676 | /* |
677 | * Determine whether an LV is active locally or in a cluster. | |
678 | * Assumes vg lock held. | |
679 | * Returns: | |
680 | * 0 - not active locally or on any node in cluster | |
681 | * 1 - active either locally or some node in the cluster | |
682 | */ | |
683 | int lv_is_active(struct logical_volume *lv) | |
684 | { | |
685 | if (_lv_active(lv->vg->cmd, lv, 0)) | |
686 | return 1; | |
687 | ||
688 | if (!vg_is_clustered(lv->vg)) | |
689 | return 0; | |
690 | ||
691 | /* | |
692 | * FIXME: Cluster does not report per-node LV activation status. | |
693 | * Currently the best we can do is try exclusive local activation. | |
694 | * If that succeeds, we know the LV is not active elsewhere in the | |
695 | * cluster. | |
696 | */ | |
697 | if (activate_lv_excl(lv->vg->cmd, lv)) { | |
698 | deactivate_lv(lv->vg->cmd, lv); | |
699 | return 0; | |
700 | } | |
701 | ||
702 | /* | |
703 | * Exclusive local activation failed so assume it is active elsewhere. | |
704 | */ | |
705 | return 1; | |
706 | } | |
707 | ||
3e3d5d85 | 708 | /* |
8a37910d AK |
709 | * Returns 0 if an attempt to (un)monitor the device failed. |
710 | * Returns 1 otherwise. | |
3e3d5d85 | 711 | */ |
8a37910d AK |
712 | int monitor_dev_for_events(struct cmd_context *cmd, |
713 | struct logical_volume *lv, int monitor) | |
15d91f5a | 714 | { |
ed09d7e3 | 715 | #ifdef DMEVENTD |
8a37910d AK |
716 | int i, pending = 0, monitored; |
717 | int r = 1; | |
67961c7c | 718 | struct list *tmp, *snh, *snht; |
15d91f5a | 719 | struct lv_segment *seg; |
24f4552b | 720 | int (*monitor_fn) (struct lv_segment *s, int e); |
4e9083db | 721 | uint32_t s; |
15d91f5a | 722 | |
20db8ffc AK |
723 | /* skip dmeventd code altogether */ |
724 | if (dmeventd_monitor_mode() == DMEVENTD_MONITOR_IGNORE) | |
725 | return 1; | |
726 | ||
8a37910d AK |
727 | /* |
728 | * Nothing to do if dmeventd configured not to be used. | |
729 | */ | |
730 | if (monitor && !dmeventd_monitor_mode()) | |
3e3d5d85 AK |
731 | return 1; |
732 | ||
67961c7c PR |
733 | /* |
734 | * In case of a snapshot device, we monitor lv->snapshot->lv, | |
735 | * not the actual LV itself. | |
736 | */ | |
737 | if (lv_is_cow(lv)) | |
738 | return monitor_dev_for_events(cmd, lv->snapshot->lv, monitor); | |
739 | ||
740 | /* | |
741 | * In case this LV is a snapshot origin, we instead monitor | |
742 | * each of its respective snapshots (the origin itself does | |
743 | * not need to be monitored). | |
744 | * | |
745 | * TODO: This may change when snapshots of mirrors are allowed. | |
746 | */ | |
747 | if (lv_is_origin(lv)) { | |
748 | list_iterate_safe(snh, snht, &lv->snapshot_segs) | |
0c06de63 AK |
749 | if (!monitor_dev_for_events(cmd, list_struct_base(snh, |
750 | struct lv_segment, origin_list)->cow, monitor)) | |
751 | r = 0; | |
67961c7c PR |
752 | return r; |
753 | } | |
754 | ||
15d91f5a AK |
755 | list_iterate(tmp, &lv->segments) { |
756 | seg = list_item(tmp, struct lv_segment); | |
757 | ||
4e9083db AK |
758 | /* Recurse for AREA_LV */ |
759 | for (s = 0; s < seg->area_count; s++) { | |
760 | if (seg_type(seg, s) != AREA_LV) | |
761 | continue; | |
762 | if (!monitor_dev_for_events(cmd, seg_lv(seg, s), | |
763 | monitor)) { | |
764 | log_error("Failed to %smonitor %s", | |
765 | monitor ? "" : "un", | |
766 | seg_lv(seg, s)->name); | |
767 | r = 0; | |
768 | } | |
769 | } | |
770 | ||
8ef6eb30 AK |
771 | if (!seg_monitored(seg) || (seg->status & PVMOVE)) |
772 | continue; | |
8a37910d AK |
773 | |
774 | monitor_fn = NULL; | |
ed09d7e3 | 775 | |
8ef6eb30 | 776 | /* Check monitoring status */ |
8a37910d AK |
777 | if (seg->segtype->ops->target_monitored) |
778 | monitored = seg->segtype->ops->target_monitored(seg, &pending); | |
8ef6eb30 AK |
779 | else |
780 | continue; /* segtype doesn't support registration */ | |
781 | ||
782 | /* | |
783 | * FIXME: We should really try again if pending | |
784 | */ | |
8a37910d | 785 | monitored = (pending) ? 0 : monitored; |
8ef6eb30 | 786 | |
8a37910d AK |
787 | if (monitor) { |
788 | if (monitored) | |
8ef6eb30 | 789 | log_verbose("%s/%s already monitored.", lv->vg->name, lv->name); |
8a37910d AK |
790 | else if (seg->segtype->ops->target_monitor_events) |
791 | monitor_fn = seg->segtype->ops->target_monitor_events; | |
8ef6eb30 | 792 | } else { |
8a37910d | 793 | if (!monitored) |
8ef6eb30 | 794 | log_verbose("%s/%s already not monitored.", lv->vg->name, lv->name); |
8a37910d AK |
795 | else if (seg->segtype->ops->target_unmonitor_events) |
796 | monitor_fn = seg->segtype->ops->target_unmonitor_events; | |
8ef6eb30 | 797 | } |
15d91f5a | 798 | |
8ef6eb30 | 799 | /* Do [un]monitor */ |
8a37910d | 800 | if (!monitor_fn) |
3e3d5d85 | 801 | continue; |
e24e7130 | 802 | |
8a37910d AK |
803 | log_verbose("%sonitoring %s/%s", monitor ? "M" : "Not m", lv->vg->name, lv->name); |
804 | ||
3e3d5d85 | 805 | /* FIXME specify events */ |
57fc4cc0 | 806 | if (!monitor_fn(seg, 0)) { |
8a37910d AK |
807 | log_error("%s/%s: %s segment monitoring function failed.", |
808 | lv->vg->name, lv->name, seg->segtype->name); | |
809 | return 0; | |
e24e7130 | 810 | } |
3e3d5d85 | 811 | |
8ef6eb30 AK |
812 | /* Check [un]monitor results */ |
813 | /* Try a couple times if pending, but not forever... */ | |
814 | for (i = 0; i < 10; i++) { | |
815 | pending = 0; | |
8a37910d | 816 | monitored = seg->segtype->ops->target_monitored(seg, &pending); |
8ef6eb30 | 817 | if (pending || |
8a37910d AK |
818 | (!monitored && monitor) || |
819 | (monitored && !monitor)) | |
820 | log_very_verbose("%s/%s %smonitoring still pending: waiting...", | |
821 | lv->vg->name, lv->name, monitor ? "" : "un"); | |
8ef6eb30 AK |
822 | else |
823 | break; | |
824 | sleep(1); | |
825 | } | |
826 | ||
8a37910d | 827 | r = (monitored && monitor) || (!monitored && !monitor); |
15d91f5a | 828 | } |
e6493477 | 829 | |
3e3d5d85 AK |
830 | return r; |
831 | #else | |
15d91f5a | 832 | return 1; |
3e3d5d85 | 833 | #endif |
15d91f5a | 834 | } |
15d91f5a | 835 | |
658b5812 AK |
836 | static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, |
837 | int error_if_not_suspended) | |
413cc918 | 838 | { |
8b888354 | 839 | struct logical_volume *lv, *lv_pre; |
199e490e | 840 | struct lvinfo info; |
9cd3426d | 841 | int lockfs = 0; |
413cc918 | 842 | |
d1d9800e AK |
843 | if (!activation()) |
844 | return 1; | |
845 | ||
8b888354 | 846 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
e408d62e | 847 | return_0; |
8b888354 | 848 | |
7a593325 | 849 | /* Use precommitted metadata if present */ |
8b888354 | 850 | if (!(lv_pre = lv_from_lvid(cmd, lvid_s, 1))) |
e408d62e | 851 | return_0; |
413cc918 | 852 | |
20c5fcf7 AK |
853 | if (test_mode()) { |
854 | _skip("Suspending '%s'.", lv->name); | |
711f7fc6 | 855 | return 1; |
20c5fcf7 AK |
856 | } |
857 | ||
a6b22cf3 | 858 | if (!lv_info(cmd, lv, &info, 0, 0)) |
5f4b2acf | 859 | return_0; |
41967a02 | 860 | |
914c9723 | 861 | if (!info.exists || info.suspended) |
658b5812 | 862 | return error_if_not_suspended ? 0 : 1; |
914c9723 | 863 | |
5f4b2acf | 864 | /* If VG was precommitted, preload devices for the LV */ |
8b888354 AK |
865 | if ((lv_pre->vg->status & PRECOMMITTED)) { |
866 | if (!_lv_preload(lv_pre)) { | |
5f4b2acf AK |
867 | /* FIXME Revert preloading */ |
868 | return_0; | |
869 | } | |
870 | } | |
871 | ||
8a37910d | 872 | if (!monitor_dev_for_events(cmd, lv, 0)) |
e24e7130 | 873 | /* FIXME Consider aborting here */ |
ed09d7e3 AK |
874 | stack; |
875 | ||
914c9723 | 876 | memlock_inc(); |
9cd3426d AK |
877 | |
878 | if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)) | |
879 | lockfs = 1; | |
880 | ||
881 | if (!_lv_suspend_lv(lv, lockfs)) { | |
914c9723 AK |
882 | memlock_dec(); |
883 | fs_unlock(); | |
884 | return 0; | |
885 | } | |
8c013da4 | 886 | |
413cc918 AK |
887 | return 1; |
888 | } | |
889 | ||
658b5812 AK |
890 | /* Returns success if the device is not active */ |
891 | int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) | |
892 | { | |
893 | return _lv_suspend(cmd, lvid_s, 0); | |
894 | } | |
895 | ||
896 | int lv_suspend(struct cmd_context *cmd, const char *lvid_s) | |
897 | { | |
898 | return _lv_suspend(cmd, lvid_s, 1); | |
899 | } | |
900 | ||
901 | static int _lv_resume(struct cmd_context *cmd, const char *lvid_s, | |
902 | int error_if_not_active) | |
413cc918 AK |
903 | { |
904 | struct logical_volume *lv; | |
199e490e | 905 | struct lvinfo info; |
413cc918 | 906 | |
d1d9800e AK |
907 | if (!activation()) |
908 | return 1; | |
909 | ||
7a593325 | 910 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
413cc918 AK |
911 | return 0; |
912 | ||
20c5fcf7 AK |
913 | if (test_mode()) { |
914 | _skip("Resuming '%s'.", lv->name); | |
711f7fc6 | 915 | return 1; |
20c5fcf7 AK |
916 | } |
917 | ||
a6b22cf3 | 918 | if (!lv_info(cmd, lv, &info, 0, 0)) |
5f4b2acf | 919 | return_0; |
41967a02 | 920 | |
914c9723 | 921 | if (!info.exists || !info.suspended) |
658b5812 | 922 | return error_if_not_active ? 0 : 1; |
914c9723 | 923 | |
658b5812 | 924 | if (!_lv_activate_lv(lv)) |
914c9723 AK |
925 | return 0; |
926 | ||
927 | memlock_dec(); | |
928 | fs_unlock(); | |
413cc918 | 929 | |
8a37910d | 930 | if (!monitor_dev_for_events(cmd, lv, 1)) |
ed09d7e3 | 931 | stack; |
15d91f5a | 932 | |
413cc918 AK |
933 | return 1; |
934 | } | |
935 | ||
658b5812 AK |
936 | /* Returns success if the device is not active */ |
937 | int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s) | |
938 | { | |
939 | return _lv_resume(cmd, lvid_s, 0); | |
940 | } | |
941 | ||
942 | int lv_resume(struct cmd_context *cmd, const char *lvid_s) | |
943 | { | |
944 | return _lv_resume(cmd, lvid_s, 1); | |
945 | } | |
946 | ||
be326a2f | 947 | int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) |
f4cbeaf0 AK |
948 | { |
949 | struct logical_volume *lv; | |
199e490e | 950 | struct lvinfo info; |
914c9723 | 951 | int r; |
f4cbeaf0 | 952 | |
d1d9800e AK |
953 | if (!activation()) |
954 | return 1; | |
955 | ||
7a593325 | 956 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
f4cbeaf0 AK |
957 | return 0; |
958 | ||
20c5fcf7 AK |
959 | if (test_mode()) { |
960 | _skip("Deactivating '%s'.", lv->name); | |
711f7fc6 | 961 | return 1; |
20c5fcf7 AK |
962 | } |
963 | ||
a6b22cf3 | 964 | if (!lv_info(cmd, lv, &info, 1, 0)) |
5f4b2acf | 965 | return_0; |
41967a02 | 966 | |
914c9723 AK |
967 | if (!info.exists) |
968 | return 1; | |
f4cbeaf0 | 969 | |
c1f50521 | 970 | if (info.open_count && (lv->status & VISIBLE_LV)) { |
5f4b2acf | 971 | log_error("LV %s/%s in use: not deactivating", lv->vg->name, |
0cf96f33 AK |
972 | lv->name); |
973 | return 0; | |
974 | } | |
975 | ||
8a37910d | 976 | if (!monitor_dev_for_events(cmd, lv, 0)) |
ed09d7e3 | 977 | stack; |
15d91f5a | 978 | |
914c9723 AK |
979 | memlock_inc(); |
980 | r = _lv_deactivate(lv); | |
981 | memlock_dec(); | |
982 | fs_unlock(); | |
983 | ||
984 | return r; | |
f4cbeaf0 AK |
985 | } |
986 | ||
658b5812 AK |
987 | /* Test if LV passes filter */ |
988 | int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s, | |
989 | int *activate_lv) | |
990 | { | |
991 | struct logical_volume *lv; | |
992 | ||
993 | if (!activation()) | |
994 | goto activate; | |
995 | ||
424dd43e | 996 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
658b5812 AK |
997 | return 0; |
998 | ||
999 | if (!_passes_activation_filter(cmd, lv)) { | |
1000 | log_verbose("Not activating %s/%s due to config file settings", | |
1001 | lv->vg->name, lv->name); | |
1002 | *activate_lv = 0; | |
1003 | return 1; | |
1004 | } | |
1005 | ||
1006 | activate: | |
1007 | *activate_lv = 1; | |
1008 | return 1; | |
1009 | } | |
1010 | ||
07d31831 AK |
1011 | static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, |
1012 | int exclusive, int filter) | |
f4cbeaf0 AK |
1013 | { |
1014 | struct logical_volume *lv; | |
199e490e | 1015 | struct lvinfo info; |
914c9723 | 1016 | int r; |
f4cbeaf0 | 1017 | |
d1d9800e AK |
1018 | if (!activation()) |
1019 | return 1; | |
1020 | ||
424dd43e | 1021 | if (!(lv = lv_from_lvid(cmd, lvid_s, 0))) |
f4cbeaf0 AK |
1022 | return 0; |
1023 | ||
658b5812 | 1024 | if (filter && !_passes_activation_filter(cmd, lv)) { |
de17d760 AK |
1025 | log_verbose("Not activating %s/%s due to config file settings", |
1026 | lv->vg->name, lv->name); | |
1027 | return 0; | |
1028 | } | |
1029 | ||
cda35408 | 1030 | if ((!lv->vg->cmd->partial_activation) && (lv->status & PARTIAL_LV)) { |
8c5bcdab AK |
1031 | log_error("Refusing activation of partial LV %s. Use --partial to override.", |
1032 | lv->name); | |
1033 | return_0; | |
1034 | } | |
1035 | ||
20c5fcf7 AK |
1036 | if (test_mode()) { |
1037 | _skip("Activating '%s'.", lv->name); | |
711f7fc6 | 1038 | return 1; |
20c5fcf7 AK |
1039 | } |
1040 | ||
a6b22cf3 | 1041 | if (!lv_info(cmd, lv, &info, 0, 0)) |
5f4b2acf | 1042 | return_0; |
8c013da4 | 1043 | |
5f4b2acf | 1044 | if (info.exists && !info.suspended && info.live_table) |
914c9723 | 1045 | return 1; |
f4cbeaf0 | 1046 | |
07d31831 AK |
1047 | if (exclusive) |
1048 | lv->status |= ACTIVATE_EXCL; | |
1049 | ||
914c9723 | 1050 | memlock_inc(); |
658b5812 | 1051 | r = _lv_activate_lv(lv); |
914c9723 AK |
1052 | memlock_dec(); |
1053 | fs_unlock(); | |
1054 | ||
5efd97f1 | 1055 | if (r && !monitor_dev_for_events(cmd, lv, 1)) |
ed09d7e3 | 1056 | stack; |
15d91f5a | 1057 | |
914c9723 | 1058 | return r; |
f4cbeaf0 | 1059 | } |
199e490e | 1060 | |
658b5812 | 1061 | /* Activate LV */ |
07d31831 | 1062 | int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive) |
658b5812 | 1063 | { |
07d31831 | 1064 | return _lv_activate(cmd, lvid_s, exclusive, 0); |
658b5812 AK |
1065 | } |
1066 | ||
1067 | /* Activate LV only if it passes filter */ | |
07d31831 | 1068 | int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive) |
658b5812 | 1069 | { |
07d31831 | 1070 | return _lv_activate(cmd, lvid_s, exclusive, 1); |
658b5812 AK |
1071 | } |
1072 | ||
f7dd6d84 AK |
1073 | int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv) |
1074 | { | |
1075 | struct lvinfo info; | |
1076 | int r = 1; | |
1077 | ||
8b076648 | 1078 | if (!lv) { |
2262b320 | 1079 | r = dm_mknodes(NULL); |
8b076648 AK |
1080 | fs_unlock(); |
1081 | return r; | |
1082 | } | |
1083 | ||
a6b22cf3 | 1084 | if (!_lv_info(cmd, lv, 1, &info, 0, 0, 0)) |
5f4b2acf | 1085 | return_0; |
f7dd6d84 AK |
1086 | |
1087 | if (info.exists) | |
f09fe0ad | 1088 | r = dev_manager_lv_mknodes(lv); |
f7dd6d84 | 1089 | else |
f09fe0ad | 1090 | r = dev_manager_lv_rmnodes(lv); |
f7dd6d84 AK |
1091 | |
1092 | fs_unlock(); | |
1093 | ||
1094 | return r; | |
1095 | } | |
1096 | ||
352a99b9 AK |
1097 | /* |
1098 | * Does PV use VG somewhere in its construction? | |
1099 | * Returns 1 on failure. | |
1100 | */ | |
898e6f8e | 1101 | int pv_uses_vg(struct physical_volume *pv, |
3e3d5d85 | 1102 | struct volume_group *vg) |
352a99b9 | 1103 | { |
352a99b9 AK |
1104 | if (!activation()) |
1105 | return 0; | |
1106 | ||
1107 | if (!dm_is_dm_major(MAJOR(pv->dev->dev))) | |
1108 | return 0; | |
1109 | ||
898e6f8e | 1110 | return dev_manager_device_uses_vg(pv->dev, vg); |
352a99b9 AK |
1111 | } |
1112 | ||
2293567c AK |
1113 | void activation_release(void) |
1114 | { | |
1115 | dev_manager_release(); | |
1116 | } | |
1117 | ||
914c9723 AK |
1118 | void activation_exit(void) |
1119 | { | |
1120 | dev_manager_exit(); | |
1121 | } | |
199e490e | 1122 | #endif |