]> sourceware.org Git - lvm2.git/blob - lib/activate/activate.c
Remove unused internal flag ACTIVATE_EXCL from the code
[lvm2.git] / lib / activate / activate.c
1 /*
2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
4 *
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
9 * of the GNU Lesser General Public License v.2.1.
10 *
11 * You should have received a copy of the GNU Lesser General Public License
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
14 */
15
16 #include "lib.h"
17 #include "metadata.h"
18 #include "activate.h"
19 #include "memlock.h"
20 #include "display.h"
21 #include "fs.h"
22 #include "lvm-exec.h"
23 #include "lvm-file.h"
24 #include "lvm-string.h"
25 #include "toolcontext.h"
26 #include "dev_manager.h"
27 #include "str_list.h"
28 #include "config.h"
29 #include "filter.h"
30 #include "segtype.h"
31 #include "sharedlib.h"
32
33 #include <limits.h>
34 #include <fcntl.h>
35 #include <unistd.h>
36
37 #define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args)
38
39 int lvm1_present(struct cmd_context *cmd)
40 {
41 char path[PATH_MAX];
42
43 if (dm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir)
44 < 0) {
45 log_error("LVM1 proc global snprintf failed");
46 return 0;
47 }
48
49 if (path_exists(path))
50 return 1;
51 else
52 return 0;
53 }
54
55 int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
56 struct dm_list *modules)
57 {
58 unsigned int s;
59 struct lv_segment *seg2, *snap_seg;
60 struct dm_list *snh;
61
62 if (seg->segtype->ops->modules_needed &&
63 !seg->segtype->ops->modules_needed(mem, seg, modules)) {
64 log_error("module string allocation failed");
65 return 0;
66 }
67
68 if (lv_is_origin(seg->lv))
69 dm_list_iterate(snh, &seg->lv->snapshot_segs)
70 if (!list_lv_modules(mem,
71 dm_list_struct_base(snh,
72 struct lv_segment,
73 origin_list)->cow,
74 modules))
75 return_0;
76
77 if (lv_is_cow(seg->lv)) {
78 snap_seg = find_cow(seg->lv);
79 if (snap_seg->segtype->ops->modules_needed &&
80 !snap_seg->segtype->ops->modules_needed(mem, snap_seg,
81 modules)) {
82 log_error("snap_seg module string allocation failed");
83 return 0;
84 }
85 }
86
87 for (s = 0; s < seg->area_count; s++) {
88 switch (seg_type(seg, s)) {
89 case AREA_LV:
90 seg2 = find_seg_by_le(seg_lv(seg, s), seg_le(seg, s));
91 if (seg2 && !list_segment_modules(mem, seg2, modules))
92 return_0;
93 break;
94 case AREA_PV:
95 case AREA_UNASSIGNED:
96 ;
97 }
98 }
99
100 return 1;
101 }
102
103 int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,
104 struct dm_list *modules)
105 {
106 struct lv_segment *seg;
107
108 dm_list_iterate_items(seg, &lv->segments)
109 if (!list_segment_modules(mem, seg, modules))
110 return_0;
111
112 return 1;
113 }
114
115 #ifndef DEVMAPPER_SUPPORT
116 void set_activation(int act)
117 {
118 static int warned = 0;
119
120 if (warned || !act)
121 return;
122
123 log_error("Compiled without libdevmapper support. "
124 "Can't enable activation.");
125
126 warned = 1;
127 }
128 int activation(void)
129 {
130 return 0;
131 }
132 int library_version(char *version, size_t size)
133 {
134 return 0;
135 }
136 int driver_version(char *version, size_t size)
137 {
138 return 0;
139 }
140 int target_version(const char *target_name, uint32_t *maj,
141 uint32_t *min, uint32_t *patchlevel)
142 {
143 return 0;
144 }
145 int target_present(struct cmd_context *cmd, const char *target_name,
146 int use_modprobe)
147 {
148 return 0;
149 }
150 int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, unsigned origin_only,
151 struct lvinfo *info, int with_open_count, int with_read_ahead)
152 {
153 return 0;
154 }
155 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
156 unsigned origin_only,
157 struct lvinfo *info, int with_open_count, int with_read_ahead)
158 {
159 return 0;
160 }
161 int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent)
162 {
163 return 0;
164 }
165 int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
166 int wait, percent_t *percent, uint32_t *event_nr)
167 {
168 return 0;
169 }
170 int lvs_in_vg_activated(struct volume_group *vg)
171 {
172 return 0;
173 }
174 int lvs_in_vg_opened(const struct volume_group *vg)
175 {
176 return 0;
177 }
178 /******
179 int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
180 {
181 return 1;
182 }
183 *******/
184 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
185 {
186 return 1;
187 }
188 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
189 {
190 return 1;
191 }
192 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
193 unsigned origin_only, unsigned exclusive)
194 {
195 return 1;
196 }
197 int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
198 {
199 return 1;
200 }
201 int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
202 int *activate_lv)
203 {
204 return 1;
205 }
206 int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive)
207 {
208 return 1;
209 }
210 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive)
211 {
212 return 1;
213 }
214 int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
215 {
216 return 1;
217 }
218 int pv_uses_vg(struct physical_volume *pv,
219 struct volume_group *vg)
220 {
221 return 0;
222 }
223 void activation_release(void)
224 {
225 }
226 void activation_exit(void)
227 {
228 }
229 int lv_is_active(struct logical_volume *lv)
230 {
231 return 0;
232 }
233 int lv_is_active_exclusive_locally(struct logical_volume *lv)
234 {
235 return 0;
236 }
237 int lv_is_active_exclusive_remotely(struct logical_volume *lv)
238 {
239 return 0;
240 }
241 int lv_check_transient(struct logical_volume *lv)
242 {
243 return 1;
244 }
245 int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
246 struct lv_activate_opts *laopts, int monitor)
247 {
248 return 1;
249 }
250 #else /* DEVMAPPER_SUPPORT */
251
252 static int _activation = 1;
253
254 void set_activation(int act)
255 {
256 if (act == _activation)
257 return;
258
259 _activation = act;
260 if (_activation)
261 log_verbose("Activation enabled. Device-mapper kernel "
262 "driver will be used.");
263 else
264 log_warn("WARNING: Activation disabled. No device-mapper "
265 "interaction will be attempted.");
266 }
267
268 int activation(void)
269 {
270 return _activation;
271 }
272
273 static int _passes_activation_filter(struct cmd_context *cmd,
274 struct logical_volume *lv)
275 {
276 const struct config_node *cn;
277 const struct config_value *cv;
278 const char *str;
279 char path[PATH_MAX];
280
281 if (!(cn = find_config_tree_node(cmd, "activation/volume_list"))) {
282 log_verbose("activation/volume_list configuration setting "
283 "not defined, checking only host tags for %s/%s",
284 lv->vg->name, lv->name);
285
286 /* If no host tags defined, activate */
287 if (dm_list_empty(&cmd->tags))
288 return 1;
289
290 /* If any host tag matches any LV or VG tag, activate */
291 if (str_list_match_list(&cmd->tags, &lv->tags, NULL) ||
292 str_list_match_list(&cmd->tags, &lv->vg->tags, NULL))
293 return 1;
294
295 log_verbose("No host tag matches %s/%s",
296 lv->vg->name, lv->name);
297
298 /* Don't activate */
299 return 0;
300 }
301 else
302 log_verbose("activation/volume_list configuration setting "
303 "defined, checking the list to match %s/%s",
304 lv->vg->name, lv->name);
305
306 for (cv = cn->v; cv; cv = cv->next) {
307 if (cv->type != CFG_STRING) {
308 log_error("Ignoring invalid string in config file "
309 "activation/volume_list");
310 continue;
311 }
312 str = cv->v.str;
313 if (!*str) {
314 log_error("Ignoring empty string in config file "
315 "activation/volume_list");
316 continue;
317 }
318
319
320 /* Tag? */
321 if (*str == '@') {
322 str++;
323 if (!*str) {
324 log_error("Ignoring empty tag in config file "
325 "activation/volume_list");
326 continue;
327 }
328 /* If any host tag matches any LV or VG tag, activate */
329 if (!strcmp(str, "*")) {
330 if (str_list_match_list(&cmd->tags, &lv->tags, NULL)
331 || str_list_match_list(&cmd->tags,
332 &lv->vg->tags, NULL))
333 return 1;
334 else
335 continue;
336 }
337 /* If supplied tag matches LV or VG tag, activate */
338 if (str_list_match_item(&lv->tags, str) ||
339 str_list_match_item(&lv->vg->tags, str))
340 return 1;
341 else
342 continue;
343 }
344 if (!strchr(str, '/')) {
345 /* vgname supplied */
346 if (!strcmp(str, lv->vg->name))
347 return 1;
348 else
349 continue;
350 }
351 /* vgname/lvname */
352 if (dm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name,
353 lv->name) < 0) {
354 log_error("dm_snprintf error from %s/%s", lv->vg->name,
355 lv->name);
356 continue;
357 }
358 if (!strcmp(path, str))
359 return 1;
360 }
361
362 log_verbose("No item supplied in activation/volume_list configuration "
363 "setting matches %s/%s", lv->vg->name, lv->name);
364
365 return 0;
366 }
367
368 int library_version(char *version, size_t size)
369 {
370 if (!activation())
371 return 0;
372
373 return dm_get_library_version(version, size);
374 }
375
376 int driver_version(char *version, size_t size)
377 {
378 if (!activation())
379 return 0;
380
381 log_very_verbose("Getting driver version");
382
383 return dm_driver_version(version, size);
384 }
385
386 int target_version(const char *target_name, uint32_t *maj,
387 uint32_t *min, uint32_t *patchlevel)
388 {
389 int r = 0;
390 struct dm_task *dmt;
391 struct dm_versions *target, *last_target;
392
393 log_very_verbose("Getting target version for %s", target_name);
394 if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
395 return_0;
396
397 if (!dm_task_run(dmt)) {
398 log_debug("Failed to get %s target version", target_name);
399 /* Assume this was because LIST_VERSIONS isn't supported */
400 return 1;
401 }
402
403 target = dm_task_get_versions(dmt);
404
405 do {
406 last_target = target;
407
408 if (!strcmp(target_name, target->name)) {
409 r = 1;
410 *maj = target->version[0];
411 *min = target->version[1];
412 *patchlevel = target->version[2];
413 goto out;
414 }
415
416 target = (struct dm_versions *)((char *) target + target->next);
417 } while (last_target != target);
418
419 out:
420 dm_task_destroy(dmt);
421
422 return r;
423 }
424
425 int module_present(struct cmd_context *cmd, const char *target_name)
426 {
427 int ret = 0;
428 #ifdef MODPROBE_CMD
429 char module[128];
430 const char *argv[3];
431
432 if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
433 log_error("module_present module name too long: %s",
434 target_name);
435 return 0;
436 }
437
438 argv[0] = MODPROBE_CMD;
439 argv[1] = module;
440 argv[2] = NULL;
441
442 ret = exec_cmd(cmd, argv, NULL, 0);
443 #endif
444 return ret;
445 }
446
447 int target_present(struct cmd_context *cmd, const char *target_name,
448 int use_modprobe)
449 {
450 uint32_t maj, min, patchlevel;
451
452 if (!activation())
453 return 0;
454
455 #ifdef MODPROBE_CMD
456 if (use_modprobe) {
457 if (target_version(target_name, &maj, &min, &patchlevel))
458 return 1;
459
460 if (!module_present(cmd, target_name))
461 return_0;
462 }
463 #endif
464
465 return target_version(target_name, &maj, &min, &patchlevel);
466 }
467
468 /*
469 * Returns 1 if info structure populated, else 0 on failure.
470 */
471 int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, unsigned origin_only,
472 struct lvinfo *info, int with_open_count, int with_read_ahead)
473 {
474 struct dm_info dminfo;
475
476 if (!activation())
477 return 0;
478 /*
479 * If open_count info is requested and we have to be sure our own udev
480 * transactions are finished
481 * For non-clustered locking type we are only interested for non-delete operation
482 * in progress - as only those could lead to opened files
483 */
484 if (with_open_count) {
485 if (locking_is_clustered())
486 sync_local_dev_names(cmd); /* Wait to have udev in sync */
487 else if (fs_has_non_delete_ops())
488 fs_unlock(); /* For non clustered - wait if there are non-delete ops */
489 }
490
491 if (!dev_manager_info(lv->vg->cmd->mem, lv, origin_only ? "real" : NULL, with_open_count,
492 with_read_ahead, &dminfo, &info->read_ahead))
493 return_0;
494
495 info->exists = dminfo.exists;
496 info->suspended = dminfo.suspended;
497 info->open_count = dminfo.open_count;
498 info->major = dminfo.major;
499 info->minor = dminfo.minor;
500 info->read_only = dminfo.read_only;
501 info->live_table = dminfo.live_table;
502 info->inactive_table = dminfo.inactive_table;
503
504 return 1;
505 }
506
507 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
508 unsigned origin_only,
509 struct lvinfo *info, int with_open_count, int with_read_ahead)
510 {
511 int r;
512 struct logical_volume *lv;
513
514 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
515 return 0;
516
517 if (!lv_is_origin(lv))
518 origin_only = 0;
519
520 r = lv_info(cmd, lv, origin_only, info, with_open_count, with_read_ahead);
521 free_vg(lv->vg);
522
523 return r;
524 }
525
526 /*
527 * Returns 1 if percent set, else 0 on failure.
528 */
529 int lv_check_transient(struct logical_volume *lv)
530 {
531 int r;
532 struct dev_manager *dm;
533
534 if (!activation())
535 return 0;
536
537 log_debug("Checking transient status for LV %s/%s", lv->vg->name, lv->name);
538
539 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
540 return_0;
541
542 if (!(r = dev_manager_transient(dm, lv)))
543 stack;
544
545 dev_manager_destroy(dm);
546
547 return r;
548 }
549
550 /*
551 * Returns 1 if percent set, else 0 on failure.
552 */
553 int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent)
554 {
555 int r;
556 struct dev_manager *dm;
557
558 if (!activation())
559 return 0;
560
561 log_debug("Checking snapshot percent for LV %s/%s", lv->vg->name, lv->name);
562
563 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
564 return_0;
565
566 if (!(r = dev_manager_snapshot_percent(dm, lv, percent)))
567 stack;
568
569 dev_manager_destroy(dm);
570
571 return r;
572 }
573
574 /* FIXME Merge with snapshot_percent */
575 int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
576 int wait, percent_t *percent, uint32_t *event_nr)
577 {
578 int r;
579 struct dev_manager *dm;
580 struct lvinfo info;
581
582 /* If mirrored LV is temporarily shrinked to 1 area (= linear),
583 * it should be considered in-sync. */
584 if (dm_list_size(&lv->segments) == 1 && first_seg(lv)->area_count == 1) {
585 *percent = PERCENT_100;
586 return 1;
587 }
588
589 if (!activation())
590 return 0;
591
592 log_debug("Checking mirror percent for LV %s/%s", lv->vg->name, lv->name);
593
594 if (!lv_info(cmd, lv, 0, &info, 0, 0))
595 return_0;
596
597 if (!info.exists)
598 return 0;
599
600 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
601 return_0;
602
603 if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr)))
604 stack;
605
606 dev_manager_destroy(dm);
607
608 return r;
609 }
610
611 static int _lv_active(struct cmd_context *cmd, struct logical_volume *lv)
612 {
613 struct lvinfo info;
614
615 if (!lv_info(cmd, lv, 0, &info, 0, 0)) {
616 stack;
617 return -1;
618 }
619
620 return info.exists;
621 }
622
623 static int _lv_open_count(struct cmd_context *cmd, struct logical_volume *lv)
624 {
625 struct lvinfo info;
626
627 if (!lv_info(cmd, lv, 0, &info, 1, 0)) {
628 stack;
629 return -1;
630 }
631
632 return info.open_count;
633 }
634
635 static int _lv_activate_lv(struct logical_volume *lv, struct lv_activate_opts *laopts)
636 {
637 int r;
638 struct dev_manager *dm;
639
640 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
641 return_0;
642
643 if (!(r = dev_manager_activate(dm, lv, laopts)))
644 stack;
645
646 dev_manager_destroy(dm);
647 return r;
648 }
649
650 static int _lv_preload(struct logical_volume *lv, struct lv_activate_opts *laopts,
651 int *flush_required)
652 {
653 int r;
654 struct dev_manager *dm;
655
656 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
657 return_0;
658
659 if (!(r = dev_manager_preload(dm, lv, laopts, flush_required)))
660 stack;
661
662 dev_manager_destroy(dm);
663 return r;
664 }
665
666 static int _lv_deactivate(struct logical_volume *lv)
667 {
668 int r;
669 struct dev_manager *dm;
670
671 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
672 return_0;
673
674 if (!(r = dev_manager_deactivate(dm, lv)))
675 stack;
676
677 dev_manager_destroy(dm);
678 return r;
679 }
680
681 static int _lv_suspend_lv(struct logical_volume *lv, struct lv_activate_opts *laopts,
682 int lockfs, int flush_required)
683 {
684 int r;
685 struct dev_manager *dm;
686
687 /*
688 * When we are asked to manipulate (normally suspend/resume) the PVMOVE
689 * device directly, we don't want to touch the devices that use it.
690 */
691 if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
692 return_0;
693
694 if (!(r = dev_manager_suspend(dm, lv, laopts, lockfs, flush_required)))
695 stack;
696
697 dev_manager_destroy(dm);
698 return r;
699 }
700
701 /*
702 * These two functions return the number of visible LVs in the state,
703 * or -1 on error. FIXME Check this.
704 */
705 int lvs_in_vg_activated(struct volume_group *vg)
706 {
707 struct lv_list *lvl;
708 int count = 0;
709
710 if (!activation())
711 return 0;
712
713 dm_list_iterate_items(lvl, &vg->lvs)
714 if (lv_is_visible(lvl->lv))
715 count += (_lv_active(vg->cmd, lvl->lv) == 1);
716
717 log_debug("Counted %d active LVs in VG %s", count, vg->name);
718
719 return count;
720 }
721
722 int lvs_in_vg_opened(const struct volume_group *vg)
723 {
724 const struct lv_list *lvl;
725 int count = 0;
726
727 if (!activation())
728 return 0;
729
730 dm_list_iterate_items(lvl, &vg->lvs)
731 if (lv_is_visible(lvl->lv))
732 count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
733
734 log_debug("Counted %d open LVs in VG %s", count, vg->name);
735
736 return count;
737 }
738
739 /*
740 * _lv_is_active
741 * @lv: logical volume being queried
742 * @locally: set if active locally (when provided)
743 * @exclusive: set if active exclusively (when provided)
744 *
745 * Determine whether an LV is active locally or in a cluster.
746 * In addition to the return code which indicates whether or
747 * not the LV is active somewhere, two other values are set
748 * to yield more information about the status of the activation:
749 * return locally exclusively status
750 * ====== ======= =========== ======
751 * 0 0 0 not active
752 * 1 0 0 active remotely
753 * 1 0 1 exclusive remotely
754 * 1 1 0 active locally and possibly remotely
755 * 1 1 1 exclusive locally (or local && !cluster)
756 * The VG lock must be held to call this function.
757 *
758 * Returns: 0 or 1
759 */
760 static int _lv_is_active(struct logical_volume *lv,
761 int *locally, int *exclusive)
762 {
763 int r, l, e; /* remote, local, and exclusive */
764
765 r = l = e = 0;
766
767 if (_lv_active(lv->vg->cmd, lv))
768 l = 1;
769
770 if (!vg_is_clustered(lv->vg)) {
771 e = 1; /* exclusive by definition */
772 goto out;
773 }
774
775 /* Active locally, and the caller doesn't care about exclusive */
776 if (l && !exclusive)
777 goto out;
778
779 if ((r = remote_lock_held(lv->lvid.s, &e)) >= 0)
780 goto out;
781
782 /*
783 * If lock query is not supported (due to interfacing with old
784 * code), then we cannot evaluate exclusivity properly.
785 *
786 * Old users of this function will never be affected by this,
787 * since they are only concerned about active vs. not active.
788 * New users of this function who specifically ask for 'exclusive'
789 * will be given an error message.
790 */
791 if (l) {
792 if (exclusive)
793 log_error("Unable to determine exclusivity of %s",
794 lv->name);
795 goto out;
796 }
797
798 /* FIXME: Is this fallback alright? */
799 if (activate_lv_excl(lv->vg->cmd, lv)) {
800 if (!deactivate_lv(lv->vg->cmd, lv))
801 stack;
802 /* FIXME: locally & exclusive are undefined. */
803 return 0;
804 }
805 /* FIXME: Check exclusive value here. */
806 out:
807 if (locally)
808 *locally = l;
809 if (exclusive)
810 *exclusive = e;
811
812 log_very_verbose("%s/%s is %sactive%s%s",
813 lv->vg->name, lv->name,
814 (r || l) ? "" : "not ",
815 (exclusive && e) ? " exclusive" : "",
816 e ? (l ? " locally" : " remotely") : "");
817
818 return r || l;
819 }
820
821 int lv_is_active(struct logical_volume *lv)
822 {
823 return _lv_is_active(lv, NULL, NULL);
824 }
825
826 /*
827 int lv_is_active_locally(struct logical_volume *lv)
828 {
829 int l;
830 return _lv_is_active(lv, &l, NULL) && l;
831 }
832 */
833
834 int lv_is_active_exclusive_locally(struct logical_volume *lv)
835 {
836 int l, e;
837
838 return _lv_is_active(lv, &l, &e) && l && e;
839 }
840
841 int lv_is_active_exclusive_remotely(struct logical_volume *lv)
842 {
843 int l, e;
844
845 return _lv_is_active(lv, &l, &e) && !l && e;
846 }
847
848 #ifdef DMEVENTD
849 static struct dm_event_handler *_create_dm_event_handler(struct cmd_context *cmd, const char *dmuuid, const char *dso,
850 const int timeout, enum dm_event_mask mask)
851 {
852 struct dm_event_handler *dmevh;
853
854 if (!(dmevh = dm_event_handler_create()))
855 return_NULL;
856
857 if (dm_event_handler_set_dmeventd_path(dmevh, find_config_tree_str(cmd, "dmeventd/executable", NULL)))
858 goto_bad;
859
860 if (dm_event_handler_set_dso(dmevh, dso))
861 goto_bad;
862
863 if (dm_event_handler_set_uuid(dmevh, dmuuid))
864 goto_bad;
865
866 dm_event_handler_set_timeout(dmevh, timeout);
867 dm_event_handler_set_event_mask(dmevh, mask);
868
869 return dmevh;
870
871 bad:
872 dm_event_handler_destroy(dmevh);
873 return NULL;
874 }
875
876 char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath)
877 {
878 char *path;
879
880 if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) {
881 log_error("Failed to allocate dmeventd library path.");
882 return NULL;
883 }
884
885 get_shared_library_path(cmd, libpath, path, PATH_MAX);
886
887 return path;
888 }
889
890 int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,
891 struct logical_volume *lv, int *pending)
892 {
893 char *uuid;
894 enum dm_event_mask evmask = 0;
895 struct dm_event_handler *dmevh;
896
897 *pending = 0;
898
899 if (!dso)
900 return_0;
901
902 /* We always monitor the "real" device, never the "snapshot-origin" itself. */
903 if (!(uuid = build_dm_uuid(cmd->mem, lv->lvid.s, lv_is_origin(lv) ? "real" : NULL)))
904 return_0;
905
906 if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, 0, DM_EVENT_ALL_ERRORS)))
907 return_0;
908
909 if (dm_event_get_registered_device(dmevh, 0)) {
910 dm_event_handler_destroy(dmevh);
911 return 0;
912 }
913
914 evmask = dm_event_handler_get_event_mask(dmevh);
915 if (evmask & DM_EVENT_REGISTRATION_PENDING) {
916 *pending = 1;
917 evmask &= ~DM_EVENT_REGISTRATION_PENDING;
918 }
919
920 dm_event_handler_destroy(dmevh);
921
922 return evmask;
923 }
924
925 int target_register_events(struct cmd_context *cmd, const char *dso, struct logical_volume *lv,
926 int evmask __attribute__((unused)), int set, int timeout)
927 {
928 char *uuid;
929 struct dm_event_handler *dmevh;
930 int r;
931
932 if (!dso)
933 return_0;
934
935 /* We always monitor the "real" device, never the "snapshot-origin" itself. */
936 if (!(uuid = build_dm_uuid(cmd->mem, lv->lvid.s, lv_is_origin(lv) ? "real" : NULL)))
937 return_0;
938
939 if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, timeout,
940 DM_EVENT_ALL_ERRORS | (timeout ? DM_EVENT_TIMEOUT : 0))))
941 return_0;
942
943 r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh);
944
945 dm_event_handler_destroy(dmevh);
946
947 if (!r)
948 return_0;
949
950 log_info("%s %s for events", set ? "Monitored" : "Unmonitored", uuid);
951
952 return 1;
953 }
954
955 #endif
956
957 /*
958 * Returns 0 if an attempt to (un)monitor the device failed.
959 * Returns 1 otherwise.
960 */
961 int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
962 const struct lv_activate_opts *laopts, int monitor)
963 {
964 #ifdef DMEVENTD
965 int i, pending = 0, monitored;
966 int r = 1;
967 struct dm_list *tmp, *snh, *snht;
968 struct lv_segment *seg;
969 struct lv_segment *log_seg;
970 int (*monitor_fn) (struct lv_segment *s, int e);
971 uint32_t s;
972 static const struct lv_activate_opts zlaopts = { 0 };
973
974 if (!laopts)
975 laopts = &zlaopts;
976
977 /* skip dmeventd code altogether */
978 if (dmeventd_monitor_mode() == DMEVENTD_MONITOR_IGNORE)
979 return 1;
980
981 /*
982 * Nothing to do if dmeventd configured not to be used.
983 */
984 if (monitor && !dmeventd_monitor_mode())
985 return 1;
986
987 /*
988 * In case of a snapshot device, we monitor lv->snapshot->lv,
989 * not the actual LV itself.
990 */
991 if (lv_is_cow(lv) && (laopts->no_merging || !lv_is_merging_cow(lv)))
992 return monitor_dev_for_events(cmd, lv->snapshot->lv, NULL, monitor);
993
994 /*
995 * In case this LV is a snapshot origin, we instead monitor
996 * each of its respective snapshots. The origin itself may
997 * also need to be monitored if it is a mirror, for example.
998 */
999 if (!laopts->origin_only && lv_is_origin(lv))
1000 dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
1001 if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh,
1002 struct lv_segment, origin_list)->cow, NULL, monitor))
1003 r = 0;
1004
1005 /*
1006 * If the volume is mirrored and its log is also mirrored, monitor
1007 * the log volume as well.
1008 */
1009 if ((seg = first_seg(lv)) != NULL && seg->log_lv != NULL &&
1010 (log_seg = first_seg(seg->log_lv)) != NULL &&
1011 seg_is_mirrored(log_seg))
1012 if (!monitor_dev_for_events(cmd, seg->log_lv, NULL, monitor))
1013 r = 0;
1014
1015 dm_list_iterate(tmp, &lv->segments) {
1016 seg = dm_list_item(tmp, struct lv_segment);
1017
1018 /* Recurse for AREA_LV */
1019 for (s = 0; s < seg->area_count; s++) {
1020 if (seg_type(seg, s) != AREA_LV)
1021 continue;
1022 if (!monitor_dev_for_events(cmd, seg_lv(seg, s), NULL,
1023 monitor)) {
1024 log_error("Failed to %smonitor %s",
1025 monitor ? "" : "un",
1026 seg_lv(seg, s)->name);
1027 r = 0;
1028 }
1029 }
1030
1031 if (!seg_monitored(seg) || (seg->status & PVMOVE))
1032 continue;
1033
1034 monitor_fn = NULL;
1035
1036 /* Check monitoring status */
1037 if (seg->segtype->ops->target_monitored)
1038 monitored = seg->segtype->ops->target_monitored(seg, &pending);
1039 else
1040 continue; /* segtype doesn't support registration */
1041
1042 /*
1043 * FIXME: We should really try again if pending
1044 */
1045 monitored = (pending) ? 0 : monitored;
1046
1047 if (monitor) {
1048 if (monitored)
1049 log_verbose("%s/%s already monitored.", lv->vg->name, lv->name);
1050 else if (seg->segtype->ops->target_monitor_events)
1051 monitor_fn = seg->segtype->ops->target_monitor_events;
1052 } else {
1053 if (!monitored)
1054 log_verbose("%s/%s already not monitored.", lv->vg->name, lv->name);
1055 else if (seg->segtype->ops->target_unmonitor_events)
1056 monitor_fn = seg->segtype->ops->target_unmonitor_events;
1057 }
1058
1059 /* Do [un]monitor */
1060 if (!monitor_fn)
1061 continue;
1062
1063 log_verbose("%sonitoring %s/%s%s", monitor ? "M" : "Not m", lv->vg->name, lv->name,
1064 test_mode() ? " [Test mode: skipping this]" : "");
1065
1066 /* FIXME Test mode should really continue a bit further. */
1067 if (test_mode())
1068 continue;
1069
1070 /* FIXME specify events */
1071 if (!monitor_fn(seg, 0)) {
1072 log_error("%s/%s: %s segment monitoring function failed.",
1073 lv->vg->name, lv->name, seg->segtype->name);
1074 return 0;
1075 }
1076
1077 /* Check [un]monitor results */
1078 /* Try a couple times if pending, but not forever... */
1079 for (i = 0; i < 10; i++) {
1080 pending = 0;
1081 monitored = seg->segtype->ops->target_monitored(seg, &pending);
1082 if (pending ||
1083 (!monitored && monitor) ||
1084 (monitored && !monitor))
1085 log_very_verbose("%s/%s %smonitoring still pending: waiting...",
1086 lv->vg->name, lv->name, monitor ? "" : "un");
1087 else
1088 break;
1089 sleep(1);
1090 }
1091
1092 if (r)
1093 r = (monitored && monitor) || (!monitored && !monitor);
1094 }
1095
1096 return r;
1097 #else
1098 return 1;
1099 #endif
1100 }
1101
1102 static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
1103 struct lv_activate_opts *laopts, int error_if_not_suspended)
1104 {
1105 struct logical_volume *lv = NULL, *lv_pre = NULL, *pvmove_lv = NULL;
1106 struct lv_list *lvl_pre;
1107 struct seg_list *sl;
1108 struct lvinfo info;
1109 int r = 0, lockfs = 0, flush_required = 0;
1110
1111 if (!activation())
1112 return 1;
1113
1114 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
1115 goto_out;
1116
1117 /* Use precommitted metadata if present */
1118 if (!(lv_pre = lv_from_lvid(cmd, lvid_s, 1)))
1119 goto_out;
1120
1121 /* Ignore origin_only unless LV is origin in both old and new metadata */
1122 if (!lv_is_origin(lv) || !lv_is_origin(lv_pre))
1123 laopts->origin_only = 0;
1124
1125 if (test_mode()) {
1126 _skip("Suspending %s%s.", lv->name, laopts->origin_only ? " origin without snapshots" : "");
1127 r = 1;
1128 goto out;
1129 }
1130
1131 if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0))
1132 goto_out;
1133
1134 if (!info.exists || info.suspended) {
1135 if (!error_if_not_suspended) {
1136 r = 1;
1137 if (info.suspended)
1138 critical_section_inc(cmd, "already suspended");
1139 }
1140 goto out;
1141 }
1142
1143 if (!lv_read_replicator_vgs(lv))
1144 goto_out;
1145
1146 lv_calculate_readahead(lv, NULL);
1147
1148 /*
1149 * If VG was precommitted, preload devices for the LV.
1150 * If the PVMOVE LV is being removed, it's only present in the old
1151 * metadata and not the new, so we must explicitly add the new
1152 * tables for all the changed LVs here, as the relationships
1153 * are not found by walking the new metadata.
1154 */
1155 if ((lv_pre->vg->status & PRECOMMITTED)) {
1156 if (!(lv_pre->status & LOCKED) &&
1157 (lv->status & LOCKED) &&
1158 (pvmove_lv = find_pvmove_lv_in_lv(lv))) {
1159 /* Preload all the LVs above the PVMOVE LV */
1160 dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) {
1161 if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, sl->seg->lv->name))) {
1162 /* FIXME Internal error? */
1163 log_error("LV %s missing from preload metadata", sl->seg->lv->name);
1164 goto out;
1165 }
1166 if (!_lv_preload(lvl_pre->lv, laopts, &flush_required))
1167 goto_out;
1168 }
1169 /* Now preload the PVMOVE LV itself */
1170 if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, pvmove_lv->name))) {
1171 /* FIXME Internal error? */
1172 log_error("LV %s missing from preload metadata", pvmove_lv->name);
1173 goto out;
1174 }
1175 if (!_lv_preload(lvl_pre->lv, laopts, &flush_required))
1176 goto_out;
1177 } else if (!_lv_preload(lv_pre, laopts, &flush_required))
1178 /* FIXME Revert preloading */
1179 goto_out;
1180 }
1181
1182 if (!monitor_dev_for_events(cmd, lv, laopts, 0))
1183 /* FIXME Consider aborting here */
1184 stack;
1185
1186 critical_section_inc(cmd, "suspending");
1187 if (pvmove_lv)
1188 critical_section_inc(cmd, "suspending pvmove LV");
1189
1190 if (!laopts->origin_only &&
1191 (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
1192 lockfs = 1;
1193
1194 /*
1195 * Suspending an LV directly above a PVMOVE LV also
1196 * suspends other LVs using that same PVMOVE LV.
1197 * FIXME Remove this and delay the 'clear node' until
1198 * after the code knows whether there's a different
1199 * inactive table to load or not instead so lv_suspend
1200 * can be called separately for each LV safely.
1201 */
1202 if ((lv_pre->vg->status & PRECOMMITTED) &&
1203 (lv_pre->status & LOCKED) && find_pvmove_lv_in_lv(lv_pre)) {
1204 if (!_lv_suspend_lv(lv_pre, laopts, lockfs, flush_required)) {
1205 critical_section_dec(cmd, "failed precommitted suspend");
1206 if (pvmove_lv)
1207 critical_section_dec(cmd, "failed precommitted suspend (pvmove)");
1208 goto_out;
1209 }
1210 } else {
1211 /* Normal suspend */
1212 if (!_lv_suspend_lv(lv, laopts, lockfs, flush_required)) {
1213 critical_section_dec(cmd, "failed suspend");
1214 if (pvmove_lv)
1215 critical_section_dec(cmd, "failed suspend (pvmove)");
1216 goto_out;
1217 }
1218 }
1219
1220 r = 1;
1221 out:
1222 if (lv_pre)
1223 free_vg(lv_pre->vg);
1224 if (lv) {
1225 lv_release_replicator_vgs(lv);
1226 free_vg(lv->vg);
1227 }
1228
1229 return r;
1230 }
1231
1232 /* Returns success if the device is not active */
1233 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
1234 {
1235 struct lv_activate_opts laopts = { .origin_only = origin_only };
1236
1237 return _lv_suspend(cmd, lvid_s, &laopts, 0);
1238 }
1239
1240 /* No longer used */
1241 /***********
1242 int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
1243 {
1244 return _lv_suspend(cmd, lvid_s, 1);
1245 }
1246 ***********/
1247
1248 /*
1249 * _lv_resume
1250 * @cmd
1251 * @lvid_s
1252 * @origin_only
1253 * @exclusive: This parameter only has an affect in cluster-context.
1254 * It forces local target type to be used (instead of
1255 * cluster-aware type).
1256 * @error_if_not_active
1257 */
1258 static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
1259 struct lv_activate_opts *laopts, int error_if_not_active)
1260 {
1261 struct logical_volume *lv;
1262 struct lvinfo info;
1263 int r = 0;
1264
1265 if (!activation())
1266 return 1;
1267
1268 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
1269 goto_out;
1270
1271 if (!lv_is_origin(lv))
1272 laopts->origin_only = 0;
1273
1274 if (test_mode()) {
1275 _skip("Resuming %s%s.", lv->name, laopts->origin_only ? " without snapshots" : "");
1276 r = 1;
1277 goto out;
1278 }
1279
1280 log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name,
1281 error_if_not_active ? "" : " if active",
1282 laopts->origin_only ? " without snapshots" : "");
1283
1284 if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0))
1285 goto_out;
1286
1287 if (!info.exists || !info.suspended) {
1288 if (error_if_not_active)
1289 goto_out;
1290 r = 1;
1291 if (!info.suspended)
1292 critical_section_dec(cmd, "already resumed");
1293 goto out;
1294 }
1295
1296 if (!_lv_activate_lv(lv, laopts))
1297 goto_out;
1298
1299 critical_section_dec(cmd, "resumed");
1300
1301 if (!monitor_dev_for_events(cmd, lv, laopts, 1))
1302 stack;
1303
1304 r = 1;
1305 out:
1306 if (lv)
1307 free_vg(lv->vg);
1308
1309 return r;
1310 }
1311
1312 /* Returns success if the device is not active */
1313 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
1314 unsigned origin_only, unsigned exclusive)
1315 {
1316 struct lv_activate_opts laopts = {
1317 .origin_only = origin_only,
1318 /*
1319 * When targets are activated exclusively in a cluster, the
1320 * non-clustered target should be used. This only happens
1321 * if exclusive is set.
1322 */
1323 .exclusive = exclusive
1324 };
1325
1326 return _lv_resume(cmd, lvid_s, &laopts, 0);
1327 }
1328
1329 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
1330 {
1331 struct lv_activate_opts laopts = { .origin_only = origin_only, };
1332
1333 return _lv_resume(cmd, lvid_s, &laopts, 1);
1334 }
1335
1336 static int _lv_has_open_snapshots(struct logical_volume *lv)
1337 {
1338 struct lv_segment *snap_seg;
1339 struct lvinfo info;
1340 int r = 0;
1341
1342 dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) {
1343 if (!lv_info(lv->vg->cmd, snap_seg->cow, 0, &info, 1, 0)) {
1344 r = 1;
1345 continue;
1346 }
1347
1348 if (info.exists && info.open_count) {
1349 log_error("LV %s/%s has open snapshot %s: "
1350 "not deactivating", lv->vg->name, lv->name,
1351 snap_seg->cow->name);
1352 r = 1;
1353 }
1354 }
1355
1356 return r;
1357 }
1358
1359 int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
1360 {
1361 struct logical_volume *lv;
1362 struct lvinfo info;
1363 int r = 0;
1364
1365 if (!activation())
1366 return 1;
1367
1368 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
1369 goto out;
1370
1371 if (test_mode()) {
1372 _skip("Deactivating '%s'.", lv->name);
1373 r = 1;
1374 goto out;
1375 }
1376
1377 log_debug("Deactivating %s/%s.", lv->vg->name, lv->name);
1378
1379 if (!lv_info(cmd, lv, 0, &info, 1, 0))
1380 goto_out;
1381
1382 if (!info.exists) {
1383 r = 1;
1384 goto out;
1385 }
1386
1387 if (lv_is_visible(lv)) {
1388 if (info.open_count) {
1389 log_error("LV %s/%s in use: not deactivating",
1390 lv->vg->name, lv->name);
1391 goto out;
1392 }
1393 if (lv_is_origin(lv) && _lv_has_open_snapshots(lv))
1394 goto_out;
1395 }
1396
1397 if (!lv_read_replicator_vgs(lv))
1398 goto_out;
1399
1400 lv_calculate_readahead(lv, NULL);
1401
1402 if (!monitor_dev_for_events(cmd, lv, NULL, 0))
1403 stack;
1404
1405 critical_section_inc(cmd, "deactivating");
1406 r = _lv_deactivate(lv);
1407 critical_section_dec(cmd, "deactivated");
1408
1409 if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists)
1410 r = 0;
1411 out:
1412 if (lv) {
1413 lv_release_replicator_vgs(lv);
1414 free_vg(lv->vg);
1415 }
1416
1417 return r;
1418 }
1419
1420 /* Test if LV passes filter */
1421 int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
1422 int *activate_lv)
1423 {
1424 struct logical_volume *lv;
1425 int r = 0;
1426
1427 if (!activation()) {
1428 *activate_lv = 1;
1429 return 1;
1430 }
1431
1432 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
1433 goto out;
1434
1435 if (!_passes_activation_filter(cmd, lv)) {
1436 log_verbose("Not activating %s/%s since it does not pass "
1437 "activation filter.", lv->vg->name, lv->name);
1438 *activate_lv = 0;
1439 } else
1440 *activate_lv = 1;
1441 r = 1;
1442 out:
1443 if (lv)
1444 free_vg(lv->vg);
1445
1446 return r;
1447 }
1448
1449 static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
1450 struct lv_activate_opts *laopts, int filter)
1451 {
1452 struct logical_volume *lv;
1453 struct lvinfo info;
1454 int r = 0;
1455
1456 if (!activation())
1457 return 1;
1458
1459 if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
1460 goto out;
1461
1462 if (filter && !_passes_activation_filter(cmd, lv)) {
1463 log_error("Not activating %s/%s since it does not pass "
1464 "activation filter.", lv->vg->name, lv->name);
1465 goto out;
1466 }
1467
1468 if ((!lv->vg->cmd->partial_activation) && (lv->status & PARTIAL_LV)) {
1469 log_error("Refusing activation of partial LV %s. Use --partial to override.",
1470 lv->name);
1471 goto_out;
1472 }
1473
1474 if (lv_has_unknown_segments(lv)) {
1475 log_error("Refusing activation of LV %s containing "
1476 "an unrecognised segment.", lv->name);
1477 goto_out;
1478 }
1479
1480 if (test_mode()) {
1481 _skip("Activating '%s'.", lv->name);
1482 r = 1;
1483 goto out;
1484 }
1485
1486 log_debug("Activating %s/%s%s.", lv->vg->name, lv->name,
1487 laopts->exclusive ? " exclusively" : "");
1488
1489 if (!lv_info(cmd, lv, 0, &info, 0, 0))
1490 goto_out;
1491
1492 if (info.exists && !info.suspended && info.live_table) {
1493 r = 1;
1494 goto out;
1495 }
1496
1497 if (!lv_read_replicator_vgs(lv))
1498 goto_out;
1499
1500 lv_calculate_readahead(lv, NULL);
1501
1502 critical_section_inc(cmd, "activating");
1503 if (!(r = _lv_activate_lv(lv, laopts)))
1504 stack;
1505 critical_section_dec(cmd, "activated");
1506
1507 if (r && !monitor_dev_for_events(cmd, lv, laopts, 1))
1508 stack;
1509
1510 out:
1511 if (lv) {
1512 lv_release_replicator_vgs(lv);
1513 free_vg(lv->vg);
1514 }
1515
1516 return r;
1517 }
1518
1519 /* Activate LV */
1520 int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive)
1521 {
1522 struct lv_activate_opts laopts = { .exclusive = exclusive };
1523
1524 if (!_lv_activate(cmd, lvid_s, &laopts, 0))
1525 return_0;
1526
1527 return 1;
1528 }
1529
1530 /* Activate LV only if it passes filter */
1531 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive)
1532 {
1533 struct lv_activate_opts laopts = { .exclusive = exclusive };
1534
1535 if (!_lv_activate(cmd, lvid_s, &laopts, 1))
1536 return_0;
1537
1538 return 1;
1539 }
1540
1541 int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
1542 {
1543 int r = 1;
1544
1545 if (!lv) {
1546 r = dm_mknodes(NULL);
1547 fs_unlock();
1548 return r;
1549 }
1550
1551 if (!activation())
1552 return 1;
1553
1554 r = dev_manager_mknodes(lv);
1555
1556 fs_unlock();
1557
1558 return r;
1559 }
1560
1561 /*
1562 * Does PV use VG somewhere in its construction?
1563 * Returns 1 on failure.
1564 */
1565 int pv_uses_vg(struct physical_volume *pv,
1566 struct volume_group *vg)
1567 {
1568 if (!activation())
1569 return 0;
1570
1571 if (!dm_is_dm_major(MAJOR(pv->dev->dev)))
1572 return 0;
1573
1574 return dev_manager_device_uses_vg(pv->dev, vg);
1575 }
1576
1577 void activation_release(void)
1578 {
1579 dev_manager_release();
1580 }
1581
1582 void activation_exit(void)
1583 {
1584 dev_manager_exit();
1585 }
1586 #endif
This page took 0.106057 seconds and 6 git commands to generate.