~brightbox/ubuntu/raring/lvm2/fix-for-1076304

« back to all changes in this revision

Viewing changes to lib/cache/lvmcache.h

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-08-14 14:35:57 UTC
  • mfrom: (3.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120814143557-93aill2tp3kf3o30
Tags: 2.02.95-4ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.

 * libdevmapper-dev:
  - move .so symlinks and pkgconfig files to multiarched locations.
  - mark libdevmapper-dev M-A: same

 * libdevmapper-event1.02.1:
  - Add Breaks: dmeventd (<< 2.02.95-4ubuntu1) due to debian symbol rename

 * debian/lvm2.{preinst,postinst,postrm}:
  - Implement removal of obsolete /etc/init.d/lvm2 conffile, which
    should not have been re-introduced in Quantal.

 * Dropped Changes, included in Debian:
  - Mostly included packages for upstream event manager (Debian bug 514706).
  - debian/patches/rules-subdir.patch: removed as reordering will cause
    build failure with dmeventd.
  - debian/patches/libdm-event-static.patch: removed as other static libs
    aren't being built anymore either.
  - Update symbols for libdevmapper-event.
  - Update libdevmapper-event, dmeventd descriptions to match Debian
    boilerplate.

 * Disappeared Changes:
  - Don't install documentation in udebs. No diff found, but no docs are
    installed into udebs either.

 * Resurected Changes:
  - corrected dropping the wrong init script. Now clvm.init is shipped
    and lvm2.init is dropped in favor of udev rules as per original
    intention (LP: #1037033).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#define ORPHAN_PREFIX VG_ORPHANS
25
25
#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "_" fmt
26
26
 
27
 
#define CACHE_INVALID   0x00000001
28
 
#define CACHE_LOCKED    0x00000002
29
 
 
30
27
/* LVM specific per-volume info */
31
28
/* Eventual replacement for struct physical_volume perhaps? */
32
29
 
33
30
struct cmd_context;
34
31
struct format_type;
35
32
struct volume_group;
36
 
struct config_tree;
37
 
 
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
 
        size_t vgmetadata_size;
50
 
        char *vgmetadata;       /* Copy of VG metadata as format_text string */
51
 
        struct config_tree *cft; /* Config tree created from vgmetadata */
52
 
                                /* Lifetime is directly tied to vgmetadata */
53
 
        struct volume_group *cached_vg;
54
 
        unsigned holders;
55
 
        unsigned vg_use_count;  /* Counter of vg reusage */
56
 
        unsigned precommitted;  /* Is vgmetadata live or precommitted? */
57
 
};
58
 
 
59
 
/* One per device */
60
 
struct lvmcache_info {
61
 
        struct dm_list list;    /* Join VG members together */
62
 
        struct dm_list mdas;    /* list head for metadata areas */
63
 
        struct dm_list das;     /* list head for data areas */
64
 
        struct lvmcache_vginfo *vginfo; /* NULL == unknown */
65
 
        struct label *label;
66
 
        const struct format_type *fmt;
67
 
        struct device *dev;
68
 
        uint64_t device_size;   /* Bytes */
69
 
        uint32_t status;
70
 
};
 
33
struct physical_volume;
 
34
struct dm_config_tree;
 
35
struct format_instance;
 
36
struct metadata_area;
 
37
struct disk_locn;
 
38
 
 
39
struct lvmcache_vginfo;
71
40
 
72
41
int lvmcache_init(void);
 
42
void lvmcache_allow_reads_with_lvmetad(void);
 
43
 
73
44
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans);
74
45
 
75
46
/* Set full_scan to 1 to reread every filtered device label or
95
66
int lvmcache_verify_lock_order(const char *vgname);
96
67
 
97
68
/* Queries */
98
 
const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels);
 
69
const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd, const char *vgname, const char *vgid, unsigned revalidate_labels);
 
70
 
99
71
/* Decrement and test if there are still vg holders in vginfo. */
100
 
int vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo);
101
 
struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
 
72
int lvmcache_vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo);
 
73
 
 
74
struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname,
102
75
                                           const char *vgid);
103
 
struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
104
 
struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
105
 
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
106
 
struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
 
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,
107
80
                                unsigned *scan_done_once, uint64_t *label_sector);
108
 
const char *pvid_from_devname(struct cmd_context *cmd,
 
81
const char *lvmcache_pvid_from_devname(struct cmd_context *cmd,
109
82
                              const char *dev_name);
110
83
char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid);
111
 
int vgs_locked(void);
112
 
int vgname_is_locked(const char *vgname);
 
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);
 
87
 
 
88
void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd);
113
89
 
114
90
/* Returns list of struct str_lists containing pool-allocated copy of vgnames */
115
91
/* If include_internal is not set, return only proper vg names. */
126
102
                                const char *vgid);
127
103
 
128
104
/* Returns cached volume group metadata. */
129
 
struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
 
105
struct volume_group *lvmcache_get_vg(struct cmd_context *cmd, const char *vgname,
 
106
                                     const char *vgid, unsigned precommitted);
130
107
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted);
131
108
void lvmcache_commit_metadata(const char *vgname);
132
109
 
 
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);
 
124
 
 
125
const struct format_type *lvmcache_fmt(struct lvmcache_info *info);
 
126
struct label *lvmcache_get_label(struct lvmcache_info *info);
 
127
 
 
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 *),
 
133
                         void *baton);
 
134
 
 
135
int lvmcache_foreach_da(struct lvmcache_info *info,
 
136
                        int (*fun)(struct disk_locn *, void *),
 
137
                        void *baton);
 
138
 
 
139
int lvmcache_foreach_pv(struct lvmcache_vginfo *vg,
 
140
                        int (*fun)(struct lvmcache_info *, void *), void * baton);
 
141
 
 
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);
 
151
 
133
152
#endif