Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / include / lvmcache.h
blob200da56789c361991daf71f53035f373ec9f8295
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifndef _LVM_CACHE_H
19 #define _LVM_CACHE_H
21 #include "dev-cache.h"
22 #include "uuid.h"
23 #include "label.h"
25 #define ORPHAN_PREFIX "#"
26 #define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "orphans_" fmt
28 #define CACHE_INVALID 0x00000001
29 #define CACHE_LOCKED 0x00000002
31 /* LVM specific per-volume info */
32 /* Eventual replacement for struct physical_volume perhaps? */
34 struct cmd_context;
35 struct format_type;
36 struct volume_group;
38 /* One per VG */
39 struct lvmcache_vginfo {
40 struct dm_list list; /* Join these vginfos together */
41 struct dm_list infos; /* List head for lvmcache_infos */
42 const struct format_type *fmt;
43 char *vgname; /* "" == orphan */
44 uint32_t status;
45 char vgid[ID_LEN + 1];
46 char _padding[7];
47 struct lvmcache_vginfo *next; /* Another VG with same name? */
48 char *creation_host;
49 char *vgmetadata; /* Copy of VG metadata as format_text string */
50 unsigned precommitted; /* Is vgmetadata live or precommitted? */
53 /* One per device */
54 struct lvmcache_info {
55 struct dm_list list; /* Join VG members together */
56 struct dm_list mdas; /* list head for metadata areas */
57 struct dm_list das; /* list head for data areas */
58 struct lvmcache_vginfo *vginfo; /* NULL == unknown */
59 struct label *label;
60 const struct format_type *fmt;
61 struct device *dev;
62 uint64_t device_size; /* Bytes */
63 uint32_t status;
66 int lvmcache_init(void);
67 void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans);
69 /* Set full_scan to 1 to reread every filtered device label or
70 * 2 to rescan /dev for new devices */
71 int lvmcache_label_scan(struct cmd_context *cmd, int full_scan);
73 /* Add/delete a device */
74 struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
75 struct device *dev,
76 const char *vgname, const char *vgid,
77 uint32_t vgstatus);
78 int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt);
79 void lvmcache_del(struct lvmcache_info *info);
81 /* Update things */
82 int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
83 const char *vgname, const char *vgid,
84 uint32_t vgstatus, const char *hostname);
85 int lvmcache_update_vg(struct volume_group *vg, unsigned precommitted);
87 void lvmcache_lock_vgname(const char *vgname, int read_only);
88 void lvmcache_unlock_vgname(const char *vgname);
89 int lvmcache_verify_lock_order(const char *vgname);
91 /* Queries */
92 const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid);
93 struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
94 const char *vgid);
95 struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
96 struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
97 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
98 struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid);
99 int vgs_locked(void);
100 int vgname_is_locked(const char *vgname);
102 /* Returns list of struct str_lists containing pool-allocated copy of vgnames */
103 /* Set full_scan to 1 to reread every filtered device label */
104 struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
106 /* Returns list of struct str_lists containing pool-allocated copy of vgids */
107 /* Set full_scan to 1 to reread every filtered device label */
108 struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan);
110 /* Returns list of struct str_lists containing pool-allocated copy of pvids */
111 struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
112 const char *vgid);
114 /* Returns cached volume group metadata. */
115 struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
116 void lvmcache_drop_metadata(const char *vgname);
118 #endif