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

« back to all changes in this revision

Viewing changes to lib/metadata/merge.c

  • 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:
75
75
        struct replicator_site *rsite;
76
76
        struct replicator_device *rdev;
77
77
 
 
78
        /* Check LV flags match first segment type */
 
79
        if (complete_vg) {
 
80
                if (lv_is_thin_volume(lv) &&
 
81
                    (!(seg2 = first_seg(lv)) || !seg_is_thin_volume(seg2))) {
 
82
                        log_error("LV %s is thin volume without first thin volume segment",
 
83
                                  lv->name);
 
84
                        inc_error_count;
 
85
                }
 
86
 
 
87
                if (lv_is_thin_pool(lv) &&
 
88
                    (!(seg2 = first_seg(lv)) || !seg_is_thin_pool(seg2))) {
 
89
                        log_error("LV %s is thin pool without first thin pool segment",
 
90
                                  lv->name);
 
91
                        inc_error_count;
 
92
                }
 
93
 
 
94
                if (lv_is_thin_pool_data(lv) &&
 
95
                    (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
 
96
                     seg2->area_count != 1 || seg_type(seg2, 0) != AREA_LV ||
 
97
                     seg_lv(seg2, 0) != lv)) {
 
98
                        log_error("LV %s: segment 1 pool data LV does not point back to same LV",
 
99
                                  lv->name);
 
100
                        inc_error_count;
 
101
                }
 
102
 
 
103
                if (lv_is_thin_pool_metadata(lv) &&
 
104
                    (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
 
105
                     seg2->metadata_lv != lv)) {
 
106
                        log_error("LV %s: segment 1 pool metadata LV does not point back to same LV",
 
107
                                  lv->name);
 
108
                        inc_error_count;
 
109
                }
 
110
        }
 
111
 
78
112
        dm_list_iterate_items(seg, &lv->segments) {
79
113
                seg_count++;
80
114
                if (seg->le != le) {
132
166
                        }
133
167
                }
134
168
 
 
169
                /* Check the various thin segment types */
 
170
                if (complete_vg) {
 
171
                        if (seg_is_thin_pool(seg)) {
 
172
                                if (!lv_is_thin_pool(lv)) {
 
173
                                        log_error("LV %s is missing thin pool flag for segment %u",
 
174
                                                  lv->name, seg_count);
 
175
                                        inc_error_count;
 
176
                                }
 
177
 
 
178
                                if (lv_is_thin_volume(lv)) {
 
179
                                        log_error("LV %s is a thin volume that must not contain thin pool segment %u",
 
180
                                                  lv->name, seg_count);
 
181
                                        inc_error_count;
 
182
                                }
 
183
 
 
184
                                if (seg->area_count != 1 || seg_type(seg, 0) != AREA_LV) {
 
185
                                        log_error("LV %s: thin pool segment %u is missing a pool data LV",
 
186
                                                  lv->name, seg_count);
 
187
                                        inc_error_count;
 
188
                                } else if (!(seg2 = first_seg(seg_lv(seg, 0))) || find_pool_seg(seg2) != seg) {
 
189
                                        log_error("LV %s: thin pool segment %u data LV does not refer back to pool LV",
 
190
                                                  lv->name, seg_count);
 
191
                                        inc_error_count;
 
192
                                }
 
193
 
 
194
                                if (!seg->metadata_lv) {
 
195
                                        log_error("LV %s: thin pool segment %u is missing a pool metadata LV",
 
196
                                                  lv->name, seg_count);
 
197
                                        inc_error_count;
 
198
                                } else if (!(seg2 = first_seg(seg->metadata_lv)) ||
 
199
                                           find_pool_seg(seg2) != seg) {
 
200
                                        log_error("LV %s: thin pool segment %u metadata LV does not refer back to pool LV",
 
201
                                                  lv->name, seg_count);
 
202
                                        inc_error_count;
 
203
                                }
 
204
 
 
205
                                if (seg->chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE ||
 
206
                                    seg->chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) {
 
207
                                        log_error("LV %s: thin pool segment %u  chunk size %d is out of range",
 
208
                                                  lv->name, seg_count, seg->chunk_size);
 
209
                                        inc_error_count;
 
210
                                }
 
211
                        } else {
 
212
                                if (seg->metadata_lv) {
 
213
                                        log_error("LV %s: segment %u must not have thin pool metadata LV set",
 
214
                                                  lv->name, seg_count);
 
215
                                        inc_error_count;
 
216
                                }
 
217
                        }
 
218
 
 
219
                        if (seg_is_thin_volume(seg)) {
 
220
                                if (!lv_is_thin_volume(lv)) {
 
221
                                        log_error("LV %s is missing thin volume flag for segment %u",
 
222
                                                  lv->name, seg_count);
 
223
                                        inc_error_count;
 
224
                                }
 
225
 
 
226
                                if (lv_is_thin_pool(lv)) {
 
227
                                        log_error("LV %s is a thin pool that must not contain thin volume segment %u",
 
228
                                                  lv->name, seg_count);
 
229
                                        inc_error_count;
 
230
                                }
 
231
 
 
232
                                if (!seg->pool_lv) {
 
233
                                        log_error("LV %s: segment %u is missing thin pool LV",
 
234
                                                  lv->name, seg_count);
 
235
                                        inc_error_count;
 
236
                                } else if (!lv_is_thin_pool(seg->pool_lv)) {
 
237
                                        log_error("LV %s: thin volume segment %u pool LV is not flagged as a pool LV",
 
238
                                                  lv->name, seg_count);
 
239
                                        inc_error_count;
 
240
                                }
 
241
 
 
242
                                if (seg->device_id > DM_THIN_MAX_DEVICE_ID) {
 
243
                                        log_error("LV %s: thin volume segment %u has too large device id %d",
 
244
                                                  lv->name, seg_count, seg->device_id);
 
245
                                        inc_error_count;
 
246
                                }
 
247
                        } else {
 
248
                                if (seg->pool_lv) {
 
249
                                        log_error("LV %s: segment %u must not have thin pool LV set",
 
250
                                                  lv->name, seg_count);
 
251
                                        inc_error_count;
 
252
                                }
 
253
                        }
 
254
                }
 
255
 
135
256
                if (seg_is_snapshot(seg)) {
136
257
                        if (seg->cow && seg->cow == seg->origin) {
137
258
                                log_error("LV %s: segment %u has same LV %s for "
250
371
                                seg_found++;
251
372
                if (seg->log_lv == lv)
252
373
                        seg_found++;
 
374
                if (seg->metadata_lv == lv || seg->pool_lv == lv)
 
375
                        seg_found++;
 
376
                if (seg_is_thin_volume(seg) && seg->origin == lv)
 
377
                        seg_found++;
253
378
                if (!seg_found) {
254
379
                        log_error("LV %s is used by LV %s:%" PRIu32 "-%" PRIu32
255
380
                                  ", but missing ptr from %s to %s",
310
435
        }
311
436
 
312
437
        /* Clone the existing segment */
313
 
        if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype,
 
438
        if (!(split_seg = alloc_lv_segment(seg->segtype,
314
439
                                           seg->lv, seg->le, seg->len,
315
440
                                           seg->status, seg->stripe_size,
316
 
                                           seg->log_lv,
 
441
                                           seg->log_lv, seg->pool_lv,
317
442
                                           seg->area_count, seg->area_len,
318
443
                                           seg->chunk_size, seg->region_size,
319
444
                                           seg->extents_copied, seg->pvmove_source_seg))) {