summaryrefslogtreecommitdiff
path: root/lib/cache/lvmcache.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cache/lvmcache.h')
-rw-r--r--lib/cache/lvmcache.h110
1 files changed, 69 insertions, 41 deletions
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 06838dc..615f466 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -24,45 +24,23 @@
#define ORPHAN_PREFIX VG_ORPHANS
#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "_" fmt
-#define CACHE_INVALID 0x00000001
-#define CACHE_LOCKED 0x00000002
-
/* LVM specific per-volume info */
/* Eventual replacement for struct physical_volume perhaps? */
struct cmd_context;
struct format_type;
struct volume_group;
+struct physical_volume;
+struct dm_config_tree;
+struct format_instance;
+struct metadata_area;
+struct disk_locn;
-/* One per VG */
-struct lvmcache_vginfo {
- struct dm_list list; /* Join these vginfos together */
- struct dm_list infos; /* List head for lvmcache_infos */
- const struct format_type *fmt;
- char *vgname; /* "" == orphan */
- uint32_t status;
- char vgid[ID_LEN + 1];
- char _padding[7];
- struct lvmcache_vginfo *next; /* Another VG with same name? */
- char *creation_host;
- char *vgmetadata; /* Copy of VG metadata as format_text string */
- unsigned precommitted; /* Is vgmetadata live or precommitted? */
-};
-
-/* One per device */
-struct lvmcache_info {
- struct dm_list list; /* Join VG members together */
- struct dm_list mdas; /* list head for metadata areas */
- struct dm_list das; /* list head for data areas */
- struct lvmcache_vginfo *vginfo; /* NULL == unknown */
- struct label *label;
- const struct format_type *fmt;
- struct device *dev;
- uint64_t device_size; /* Bytes */
- uint32_t status;
-};
+struct lvmcache_vginfo;
int lvmcache_init(void);
+void lvmcache_allow_reads_with_lvmetad(void);
+
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans);
/* Set full_scan to 1 to reread every filtered device label or
@@ -88,19 +66,26 @@ void lvmcache_unlock_vgname(const char *vgname);
int lvmcache_verify_lock_order(const char *vgname);
/* Queries */
-const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels);
-struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
+const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd, const char *vgname, const char *vgid, unsigned revalidate_labels);
+
+/* Decrement and test if there are still vg holders in vginfo. */
+int lvmcache_vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo);
+
+struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname,
const char *vgid);
-struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
-struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
-const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
-struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
- unsigned *scan_done_once);
-const char *pvid_from_devname(struct cmd_context *cmd,
+struct lvmcache_vginfo *lvmcache_vginfo_from_vgid(const char *vgid);
+struct lvmcache_info *lvmcache_info_from_pvid(const char *pvid, int valid_only);
+const char *lvmcache_vgname_from_vgid(struct dm_pool *mem, const char *vgid);
+struct device *lvmcache_device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
+ unsigned *scan_done_once, uint64_t *label_sector);
+const char *lvmcache_pvid_from_devname(struct cmd_context *cmd,
const char *dev_name);
char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid);
-int vgs_locked(void);
-int vgname_is_locked(const char *vgname);
+const char *lvmcache_vgname_from_info(struct lvmcache_info *info);
+int lvmcache_vgs_locked(void);
+int lvmcache_vgname_is_locked(const char *vgname);
+
+void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd);
/* Returns list of struct str_lists containing pool-allocated copy of vgnames */
/* If include_internal is not set, return only proper vg names. */
@@ -117,8 +102,51 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
const char *vgid);
/* Returns cached volume group metadata. */
-struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
+struct volume_group *lvmcache_get_vg(struct cmd_context *cmd, const char *vgname,
+ const char *vgid, unsigned precommitted);
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted);
void lvmcache_commit_metadata(const char *vgname);
+int lvmcache_pvid_is_locked(const char *pvid);
+int lvmcache_fid_add_mdas(struct lvmcache_info *info, struct format_instance *fid,
+ const char *id, int id_len);
+int lvmcache_fid_add_mdas_pv(struct lvmcache_info *info, struct format_instance *fid);
+int lvmcache_fid_add_mdas_vg(struct lvmcache_vginfo *vginfo, struct format_instance *fid);
+int lvmcache_populate_pv_fields(struct lvmcache_info *info,
+ struct physical_volume *pv,
+ int scan_label_only);
+int lvmcache_check_format(struct lvmcache_info *info, const struct format_type *fmt);
+void lvmcache_del_mdas(struct lvmcache_info *info);
+void lvmcache_del_das(struct lvmcache_info *info);
+int lvmcache_add_mda(struct lvmcache_info *info, struct device *dev,
+ uint64_t start, uint64_t size, unsigned ignored);
+int lvmcache_add_da(struct lvmcache_info *info, uint64_t start, uint64_t size);
+
+const struct format_type *lvmcache_fmt(struct lvmcache_info *info);
+struct label *lvmcache_get_label(struct lvmcache_info *info);
+
+void lvmcache_update_pv(struct lvmcache_info *info, struct physical_volume *pv,
+ const struct format_type *fmt);
+int lvmcache_update_das(struct lvmcache_info *info, struct physical_volume *pv);
+int lvmcache_foreach_mda(struct lvmcache_info *info,
+ int (*fun)(struct metadata_area *, void *),
+ void *baton);
+
+int lvmcache_foreach_da(struct lvmcache_info *info,
+ int (*fun)(struct disk_locn *, void *),
+ void *baton);
+
+int lvmcache_foreach_pv(struct lvmcache_vginfo *vg,
+ int (*fun)(struct lvmcache_info *, void *), void * baton);
+
+uint64_t lvmcache_device_size(struct lvmcache_info *info);
+void lvmcache_set_device_size(struct lvmcache_info *info, uint64_t size);
+struct device *lvmcache_device(struct lvmcache_info *info);
+void lvmcache_make_valid(struct lvmcache_info *info);
+int lvmcache_is_orphan(struct lvmcache_info *info);
+int lvmcache_uncertain_ownership(struct lvmcache_info *info);
+int lvmcache_mda_count(struct lvmcache_info *info);
+int lvmcache_vgid_is_cached(const char *vgid);
+int lvmcache_smallest_mda_size(struct lvmcache_info *info);
+
#endif