]>
sourceware.org Git - lvm2.git/blob - lib/cache/lvmcache.h
2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2008 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
19 #include "dev-cache.h"
24 #define ORPHAN_PREFIX VG_ORPHANS
25 #define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "_" fmt
27 /* LVM specific per-volume info */
28 /* Eventual replacement for struct physical_volume perhaps? */
33 struct physical_volume
;
34 struct dm_config_tree
;
35 struct format_instance
;
39 struct lvmcache_vginfo
;
41 int lvmcache_init(void);
42 void lvmcache_allow_reads_with_lvmetad(void);
44 void lvmcache_destroy(struct cmd_context
*cmd
, int retain_orphans
);
46 /* Set full_scan to 1 to reread every filtered device label or
47 * 2 to rescan /dev for new devices */
48 int lvmcache_label_scan(struct cmd_context
*cmd
, int full_scan
);
50 /* Add/delete a device */
51 struct lvmcache_info
*lvmcache_add(struct labeller
*labeller
, const char *pvid
,
53 const char *vgname
, const char *vgid
,
55 int lvmcache_add_orphan_vginfo(const char *vgname
, struct format_type
*fmt
);
56 void lvmcache_del(struct lvmcache_info
*info
);
59 int lvmcache_update_vgname_and_id(struct lvmcache_info
*info
,
60 const char *vgname
, const char *vgid
,
61 uint32_t vgstatus
, const char *hostname
);
62 int lvmcache_update_vg(struct volume_group
*vg
, unsigned precommitted
);
64 void lvmcache_lock_vgname(const char *vgname
, int read_only
);
65 void lvmcache_unlock_vgname(const char *vgname
);
66 int lvmcache_verify_lock_order(const char *vgname
);
69 const struct format_type
*lvmcache_fmt_from_vgname(struct cmd_context
*cmd
, const char *vgname
, const char *vgid
, unsigned revalidate_labels
);
71 /* Decrement and test if there are still vg holders in vginfo. */
72 int lvmcache_vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo
*vginfo
);
74 struct lvmcache_vginfo
*lvmcache_vginfo_from_vgname(const char *vgname
,
76 struct lvmcache_vginfo
*lvmcache_vginfo_from_vgid(const char *vgid
);
77 struct lvmcache_info
*lvmcache_info_from_pvid(const char *pvid
, int valid_only
);
78 const char *lvmcache_vgname_from_vgid(struct dm_pool
*mem
, const char *vgid
);
79 struct device
*lvmcache_device_from_pvid(struct cmd_context
*cmd
, const struct id
*pvid
,
80 unsigned *scan_done_once
, uint64_t *label_sector
);
81 const char *lvmcache_pvid_from_devname(struct cmd_context
*cmd
,
82 const char *dev_name
);
83 char *lvmcache_vgname_from_pvid(struct cmd_context
*cmd
, const char *pvid
);
84 const char *lvmcache_vgname_from_info(struct lvmcache_info
*info
);
85 int lvmcache_vgs_locked(void);
86 int lvmcache_vgname_is_locked(const char *vgname
);
88 void lvmcache_seed_infos_from_lvmetad(struct cmd_context
*cmd
);
90 /* Returns list of struct str_lists containing pool-allocated copy of vgnames */
91 /* If include_internal is not set, return only proper vg names. */
92 struct dm_list
*lvmcache_get_vgnames(struct cmd_context
*cmd
,
93 int include_internal
);
95 /* Returns list of struct str_lists containing pool-allocated copy of vgids */
96 /* If include_internal is not set, return only proper vg ids. */
97 struct dm_list
*lvmcache_get_vgids(struct cmd_context
*cmd
,
98 int include_internal
);
100 /* Returns list of struct str_lists containing pool-allocated copy of pvids */
101 struct dm_list
*lvmcache_get_pvids(struct cmd_context
*cmd
, const char *vgname
,
104 /* Returns cached volume group metadata. */
105 struct volume_group
*lvmcache_get_vg(struct cmd_context
*cmd
, const char *vgname
,
106 const char *vgid
, unsigned precommitted
);
107 void lvmcache_drop_metadata(const char *vgname
, int drop_precommitted
);
108 void lvmcache_commit_metadata(const char *vgname
);
110 int lvmcache_pvid_is_locked(const char *pvid
);
111 int lvmcache_fid_add_mdas(struct lvmcache_info
*info
, struct format_instance
*fid
,
112 const char *id
, int id_len
);
113 int lvmcache_fid_add_mdas_pv(struct lvmcache_info
*info
, struct format_instance
*fid
);
114 int lvmcache_fid_add_mdas_vg(struct lvmcache_vginfo
*vginfo
, struct format_instance
*fid
);
115 int lvmcache_populate_pv_fields(struct lvmcache_info
*info
,
116 struct physical_volume
*pv
,
117 int scan_label_only
);
118 int lvmcache_check_format(struct lvmcache_info
*info
, const struct format_type
*fmt
);
119 void lvmcache_del_mdas(struct lvmcache_info
*info
);
120 void lvmcache_del_das(struct lvmcache_info
*info
);
121 int lvmcache_add_mda(struct lvmcache_info
*info
, struct device
*dev
,
122 uint64_t start
, uint64_t size
, unsigned ignored
);
123 int lvmcache_add_da(struct lvmcache_info
*info
, uint64_t start
, uint64_t size
);
125 const struct format_type
*lvmcache_fmt(struct lvmcache_info
*info
);
126 struct label
*lvmcache_get_label(struct lvmcache_info
*info
);
128 void lvmcache_update_pv(struct lvmcache_info
*info
, struct physical_volume
*pv
,
129 const struct format_type
*fmt
);
130 int lvmcache_update_das(struct lvmcache_info
*info
, struct physical_volume
*pv
);
131 int lvmcache_foreach_mda(struct lvmcache_info
*info
,
132 int (*fun
)(struct metadata_area
*, void *),
135 int lvmcache_foreach_da(struct lvmcache_info
*info
,
136 int (*fun
)(struct disk_locn
*, void *),
139 int lvmcache_foreach_pv(struct lvmcache_vginfo
*vg
,
140 int (*fun
)(struct lvmcache_info
*, void *), void * baton
);
142 uint64_t lvmcache_device_size(struct lvmcache_info
*info
);
143 void lvmcache_set_device_size(struct lvmcache_info
*info
, uint64_t size
);
144 struct device
*lvmcache_device(struct lvmcache_info
*info
);
145 void lvmcache_make_valid(struct lvmcache_info
*info
);
146 int lvmcache_is_orphan(struct lvmcache_info
*info
);
147 int lvmcache_uncertain_ownership(struct lvmcache_info
*info
);
148 int lvmcache_mda_count(struct lvmcache_info
*info
);
149 int lvmcache_vgid_is_cached(const char *vgid
);
150 int lvmcache_smallest_mda_size(struct lvmcache_info
*info
);
This page took 0.042401 seconds and 5 git commands to generate.