2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
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.
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
16 #ifndef LVM_ACTIVATE_H
17 #define LVM_ACTIVATE_H
19 #include "metadata-exported.h"
24 unsigned int open_count
;
33 struct lv_activate_opts
{
44 /* target attribute flags */
45 #define MIRROR_LOG_CLUSTERED 0x00000001U
47 /* thin target attribute flags */
49 /* bitfields - new features from 1.1 version */
50 THIN_FEATURE_DISCARDS
= (1 << 0),
51 THIN_FEATURE_EXTERNAL_ORIGIN
= (1 << 1),
52 THIN_FEATURE_HELD_ROOT
= (1 << 2),
53 THIN_FEATURE_BLOCK_SIZE
= (1 << 3),
56 void set_activation(int activation
);
59 int driver_version(char *version
, size_t size
);
60 int library_version(char *version
, size_t size
);
61 int lvm1_present(struct cmd_context
*cmd
);
63 int module_present(struct cmd_context
*cmd
, const char *target_name
);
64 int target_present(struct cmd_context
*cmd
, const char *target_name
,
66 int target_version(const char *target_name
, uint32_t *maj
,
67 uint32_t *min
, uint32_t *patchlevel
);
68 int lvm_dm_prefix_check(int major
, int minor
, const char *prefix
);
69 int list_segment_modules(struct dm_pool
*mem
, const struct lv_segment
*seg
,
70 struct dm_list
*modules
);
71 int list_lv_modules(struct dm_pool
*mem
, const struct logical_volume
*lv
,
72 struct dm_list
*modules
);
74 void activation_release(void);
75 void activation_exit(void);
77 /* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
78 int lv_suspend_if_active(struct cmd_context
*cmd
, const char *lvid_s
, unsigned origin_only
, unsigned exclusive
);
79 int lv_resume(struct cmd_context
*cmd
, const char *lvid_s
, unsigned origin_only
);
80 int lv_resume_if_active(struct cmd_context
*cmd
, const char *lvid_s
,
81 unsigned origin_only
, unsigned exclusive
, unsigned revert
);
82 int lv_activate(struct cmd_context
*cmd
, const char *lvid_s
, int exclusive
);
83 int lv_activate_with_filter(struct cmd_context
*cmd
, const char *lvid_s
,
85 int lv_deactivate(struct cmd_context
*cmd
, const char *lvid_s
);
87 int lv_mknodes(struct cmd_context
*cmd
, const struct logical_volume
*lv
);
90 * Returns 1 if info structure has been populated, else 0.
92 int lv_info(struct cmd_context
*cmd
, const struct logical_volume
*lv
, int use_layer
,
93 struct lvinfo
*info
, int with_open_count
, int with_read_ahead
);
94 int lv_info_by_lvid(struct cmd_context
*cmd
, const char *lvid_s
, int use_layer
,
95 struct lvinfo
*info
, int with_open_count
, int with_read_ahead
);
97 int lv_check_not_in_use(struct cmd_context
*cmd
, struct logical_volume
*lv
,
101 * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
103 int lv_activation_filter(struct cmd_context
*cmd
, const char *lvid_s
,
106 * Checks against the auto_activation_volume_list and
107 * returns 1 if the LV should be activated, 0 otherwise.
109 int lv_passes_auto_activation_filter(struct cmd_context
*cmd
, struct logical_volume
*lv
);
111 int lv_check_transient(struct logical_volume
*lv
);
113 * Returns 1 if percent has been set, else 0.
115 int lv_snapshot_percent(const struct logical_volume
*lv
, percent_t
*percent
);
116 int lv_mirror_percent(struct cmd_context
*cmd
, const struct logical_volume
*lv
,
117 int wait
, percent_t
*percent
, uint32_t *event_nr
);
118 int lv_raid_percent(const struct logical_volume
*lv
, percent_t
*percent
);
119 int lv_thin_pool_percent(const struct logical_volume
*lv
, int metadata
,
121 int lv_thin_percent(const struct logical_volume
*lv
, int mapped
,
123 int lv_thin_pool_transaction_id(const struct logical_volume
*lv
,
124 uint64_t *transaction_id
);
127 * Return number of LVs in the VG that are active.
129 int lvs_in_vg_activated(const struct volume_group
*vg
);
130 int lvs_in_vg_opened(const struct volume_group
*vg
);
132 int lv_is_active(const struct logical_volume
*lv
);
133 int lv_is_active_but_not_locally(const struct logical_volume
*lv
);
134 int lv_is_active_exclusive(const struct logical_volume
*lv
);
135 int lv_is_active_exclusive_locally(const struct logical_volume
*lv
);
136 int lv_is_active_exclusive_remotely(const struct logical_volume
*lv
);
138 int lv_has_target_type(struct dm_pool
*mem
, struct logical_volume
*lv
,
139 const char *layer
, const char *target_type
);
141 int monitor_dev_for_events(struct cmd_context
*cmd
, struct logical_volume
*lv
,
142 const struct lv_activate_opts
*laopts
, int do_reg
);
145 # include "libdevmapper-event.h"
146 char *get_monitor_dso_path(struct cmd_context
*cmd
, const char *libpath
);
147 int target_registered_with_dmeventd(struct cmd_context
*cmd
, const char *libpath
,
148 struct logical_volume
*lv
, int *pending
);
149 int target_register_events(struct cmd_context
*cmd
, const char *dso
, struct logical_volume
*lv
,
150 int evmask
__attribute__((unused
)), int set
, int timeout
);
153 int add_linear_area_to_dtree(struct dm_tree_node
*node
, uint64_t size
,
154 uint32_t extent_size
, int use_linear_target
,
155 const char *vgname
, const char *lvname
);
158 * Returns 1 if PV has a dependency tree that uses anything in VG.
160 int pv_uses_vg(struct physical_volume
*pv
,
161 struct volume_group
*vg
);
164 * Returns 1 if mapped device is not suspended.
166 int device_is_usable(struct device
*dev
);
169 * Declaration moved here from fs.h to keep header fs.h hidden
171 void fs_unlock(void);