]> sourceware.org Git - lvm2.git/blame - tools/toollib.h
metadata: use lv_hash in segment-specific metadata parsing
[lvm2.git] / tools / toollib.h
CommitLineData
269930c0 1/*
6606c3ae 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
ea0cdd28 3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
269930c0 4 *
6606c3ae 5 * This file is part of LVM2.
269930c0 6 *
6606c3ae
AK
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.
269930c0 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
269930c0
AK
14 */
15
b8ef655f
AK
16#ifndef _LVM_TOOLLIB_H
17#define _LVM_TOOLLIB_H
269930c0 18
7f97c7ea
JT
19#include "lib/metadata/metadata-exported.h"
20#include "lib/report/report.h"
60274aba 21
008c33a2
PR
22int become_daemon(struct cmd_context *cmd, int skip_lvm);
23
51d96a17
PR
24/*
25 * The "struct processing_handle" is used as a handle for processing
26 * functions (process_each_* and related).
27 *
28 * The "custom_handle" is any handle used to pass custom data into
29 * process_each_* and related functions.
30 *
31 * The "internal_report_for_select=0" makes processing function to
32 * skip checking the report/selection criteria (if given on cmd line)
33 * before executing the action on the item.
34 *
35 * The "selection_handle" is only used if "internal_report_for_select=1".
36 *
37 * Some important notes about selection:
38 * =====================================
39 * In case we're processing for display, the selection is directly
40 * a part of reporting for the display on output so we don't need to
41 * report the item in memory to get the selection result, then dropping
42 * the report and then reporting the same thing again for it to be
43 * displayed on output.
44 * For example, compare these code paths:
45 *
46 * - when reporting for display on output:
47 * _report -> process_each_* -> ... -> dm_report_object
48 * (Here the dm_report_object does both selection and
49 * reporting for display on output.)
50 *
51 * - for any other processing and reporting for selection:
52 * process_each_* -> _select_match_* -> ... -> dm_report_object_is_selected
53 * |
54 * --> (selection result) --> ...
55 * (Here the dm_report_object_is_selected just gets
56 * the selection result and it drops reporting buffer
57 * immediately. Then based on the selection result,
58 * the process_each_* action on the item is executed
59 * or not...)
60 *
61 * Simply, we want to avoid this double reporting when reporting
62 * for display on output:
63 * _report -> process_each_* -> _select_match_* -> ... -> dm_report_object_is_selected
64 * |
65 * --> (selection result) -> dm_report_object
66 *
67 * So whenever the processing action is "to display item on output", use
68 * "internal_report_for_select=0" as report/selection is already
69 * a part of that reporting for display (dm_report_object).
70 */
71struct processing_handle {
f752a953 72 struct processing_handle *parent;
51d96a17 73 int internal_report_for_select;
f7e0a4cc 74 int include_historical_lvs;
51d96a17
PR
75 struct selection_handle *selection_handle;
76 void *custom_handle;
77};
78
6c4f65fe
AK
79typedef int (*process_single_vg_fn_t) (struct cmd_context * cmd,
80 const char *vg_name,
81 struct volume_group * vg,
51d96a17 82 struct processing_handle *handle);
6c4f65fe
AK
83typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
84 struct volume_group *vg,
85 struct physical_volume *pv,
51d96a17 86 struct processing_handle *handle);
1ef2c3c4
PR
87typedef int (*process_single_label_fn_t) (struct cmd_context *cmd,
88 struct label *label,
51d96a17 89 struct processing_handle *handle);
6c4f65fe
AK
90typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
91 struct logical_volume *lv,
51d96a17 92 struct processing_handle *handle);
6c4f65fe
AK
93typedef int (*process_single_seg_fn_t) (struct cmd_context * cmd,
94 struct lv_segment * seg,
51d96a17 95 struct processing_handle *handle);
6c4f65fe
AK
96typedef int (*process_single_pvseg_fn_t) (struct cmd_context * cmd,
97 struct volume_group * vg,
98 struct pv_segment * pvseg,
51d96a17 99 struct processing_handle *handle);
6c4f65fe 100
9c6c55c3
DT
101/*
102 * Called prior to process_single_lv() to decide if the LV should be
103 * processed. If this returns 0, the LV is not processed.
104 *
105 * This can evaluate the combination of command definition and
106 * the LV object to decide if the combination is allowed.
107 */
108typedef int (*check_single_lv_fn_t) (struct cmd_context *cmd,
109 struct logical_volume *lv,
110 struct processing_handle *handle,
111 int lv_is_named_arg);
112
55683a65
DT
113int process_each_vg(struct cmd_context *cmd,
114 int argc, char **argv,
115 const char *one_vgname,
116 struct dm_list *use_vgnames,
117 uint32_t flags,
8cfc3854 118 int include_internal,
ea74215f 119 struct processing_handle *handle,
6c4f65fe 120 process_single_vg_fn_t process_single_vg);
677a06d5 121
71671778
DT
122int process_each_pv(struct cmd_context *cmd, int argc, char **argv, const char *vg_name,
123 int all_is_set, uint32_t read_flags,
51d96a17
PR
124 struct processing_handle *handle,
125 process_single_pv_fn_t process_single_pv);
ea0cdd28 126
1ef2c3c4 127int process_each_label(struct cmd_context *cmd, int argc, char **argv,
51d96a17
PR
128 struct processing_handle *handle,
129 process_single_label_fn_t process_single_label);
1ef2c3c4 130
c54a9405
AK
131int process_each_segment_in_pv(struct cmd_context *cmd,
132 struct volume_group *vg,
133 struct physical_volume *pv,
51d96a17 134 struct processing_handle *handle,
6c4f65fe 135 process_single_pvseg_fn_t process_single_pvseg);
5a52dca9 136
60274aba 137int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
2f2b3c91 138 const char *one_vgname, const char *one_lvname,
51d96a17 139 uint32_t flags, struct processing_handle *handle,
9c6c55c3 140 check_single_lv_fn_t check_single_lv,
6c4f65fe
AK
141 process_single_lv_fn_t process_single_lv);
142
7f3859bb 143
4c64ed4c 144int process_each_segment_in_lv(struct cmd_context *cmd,
51d96a17
PR
145 struct logical_volume *lv,
146 struct processing_handle *handle,
6c4f65fe 147 process_single_seg_fn_t process_single_seg);
08c9ff43 148
60274aba 149int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
51d96a17
PR
150 struct processing_handle *handle,
151 process_single_pv_fn_t process_single_pv);
08c9ff43 152
5a52dca9 153
f3bb1c01
AK
154int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
155 struct dm_list *arg_lvnames, const struct dm_list *tagsl,
51d96a17 156 int stop_on_error, struct processing_handle *handle,
9c6c55c3 157 check_single_lv_fn_t check_single_lv,
6c4f65fe 158 process_single_lv_fn_t process_single_lv);
677a06d5 159
f752a953 160struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct processing_handle *parent_handle);
7f2eebf5 161int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle,
9dfe5ce2 162 unsigned initial_report_type);
969d2bf4 163void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle *handle);
a91bc7a1 164
c3180c4a 165int select_match_vg(struct cmd_context *cmd, struct processing_handle *handle,
815f1ee2 166 struct volume_group *vg);
c3180c4a 167int select_match_lv(struct cmd_context *cmd, struct processing_handle *handle,
815f1ee2 168 struct volume_group *vg, struct logical_volume *lv);
c3180c4a 169int select_match_pv(struct cmd_context *cmd, struct processing_handle *handle,
815f1ee2 170 struct volume_group *vg, struct physical_volume *pv);
455ef6f2 171
8ef2b021 172const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
aec21154
ZK
173const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
174 unsigned *dev_dir_found);
cfd658da 175
1c396598 176int opt_in_list_is_set(struct cmd_context *cmd, const uint16_t *opts, int count,
1e2420bc
DT
177 int *match_count, int *unmatch_count);
178
1c396598 179void opt_array_to_str(struct cmd_context *cmd, const uint16_t *opts, int count,
1e2420bc
DT
180 char *buf, int len);
181
a77ded30
DT
182int pvcreate_params_from_args(struct cmd_context *cmd, struct pvcreate_params *pp);
183int pvcreate_each_device(struct cmd_context *cmd, struct processing_handle *handle, struct pvcreate_params *pp);
71671778 184
f0cafc92
PR
185int vgcreate_params_set_defaults(struct cmd_context *cmd,
186 struct vgcreate_params *vp_def,
c6ea6bf5 187 struct volume_group *vg);
2a924b3e
DW
188int vgcreate_params_set_from_args(struct cmd_context *cmd,
189 struct vgcreate_params *vp_new,
190 struct vgcreate_params *vp_def);
a81a2406
ZK
191int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
192 activation_change_t activate);
3ad47d16 193int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
da1ba4ed 194int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
93bbc31c
AK
195void lv_spawn_background_polling(struct cmd_context *cmd,
196 struct logical_volume *lv);
197
a6bc975a
MS
198int get_activation_monitoring_mode(struct cmd_context *cmd,
199 int *monitoring_mode);
f06dd872 200
24a84549 201int get_pool_params(struct cmd_context *cmd,
894eda47 202 const struct segment_type *segtype,
4ccedcea 203 int *pool_data_vdo,
894eda47 204 uint64_t *pool_metadata_size,
fdc252ec 205 int *pool_metadata_spare,
f4137640
ZK
206 uint32_t *chunk_size,
207 thin_discards_t *discards,
b8cd0f48 208 thin_zero_t *zero_new_blocks);
b36a776a 209
4ffe15bf 210int get_stripe_params(struct cmd_context *cmd, const struct segment_type *segtype,
c1a0a2c7
AK
211 uint32_t *stripes, uint32_t *stripe_size,
212 unsigned *stripes_supplied, unsigned *stripe_size_supplied);
68176be1 213
969ee25a 214int get_cache_params(struct cmd_context *cmd,
c598e65d 215 uint32_t *chunk_size,
4d2b1a06 216 cache_metadata_format_t *format,
197066c8 217 cache_mode_t *cache_mode,
969ee25a
ZK
218 const char **name,
219 struct dm_config_tree **settings);
f67e1fad 220
5e060b8f
ZK
221#define VDO_CHANGE_ONLINE 1
222#define VDO_CHANGE_OFFLINE 2
223int get_vdo_settings(struct cmd_context *cmd,
224 struct dm_vdo_target_params *vtp,
225 int *updated);
226
1ee42f13
DT
227int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings *settings,
228 uint32_t *block_size_sectors);
229
78d14a80
DT
230int get_integrity_settings(struct cmd_context *cmd, struct integrity_settings *settings);
231
b51cd542
AK
232int change_tag(struct cmd_context *cmd, struct volume_group *vg,
233 struct logical_volume *lv, struct physical_volume *pv, int arg);
234
89e1190e
ZK
235int get_and_validate_major_minor(const struct cmd_context *cmd,
236 const struct format_type *fmt,
237 int32_t *major, int32_t *minor);
238
0d4baeba
ZK
239int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
240 const char **lv_name);
b59335fb
ZK
241int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_name,
242 const char **lv_name);
0d4baeba 243
f3bb1c01 244int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
51d96a17 245 struct processing_handle *handle __attribute__((unused)));
f3bb1c01 246
0e3e611a
DT
247int get_lvt_enum(struct logical_volume *lv);
248
88e0060a
ZK
249int get_rootvg_dev_uuid(struct cmd_context *cmd, char **dm_uuid_out);
250
269930c0 251#endif
This page took 0.281207 seconds and 6 git commands to generate.