~ubuntu-branches/ubuntu/vivid/lvm2/vivid

« back to all changes in this revision

Viewing changes to debian/patches/upstream-fix-discard-3.patch

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-11-26 10:35:00 UTC
  • mfrom: (3.1.26 sid)
  • Revision ID: package-import@ubuntu.com-20121126103500-a1zw30282cu9kdev
Tags: 2.02.95-5ubuntu1
* Merge from Debian unstable, remaining changes (LP: #1082325):
  - 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.
      - In libdevmapper-event1.02.1 add Breaks: dmeventd
        (<< 2.02.95-4ubuntu1) due to debian symbol rename
    - 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.
  - Complete libdevmapper-dev multiarch:
    - move .so symlinks and pkgconfig files to multiarched locations.
    - mark libdevmapper-dev M-A: same

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Alasdair G Kergon <agk@redhat.com>
 
2
Subject: discards: don't discard reconfigured extents
 
3
 
 
4
Update release_lv_segment_area not to discard any PV extents,
 
5
as it also gets used when moving extents between LVs.
 
6
Instead, call a new function release_and_discard_lv_segment_area() in
 
7
the two places where data should be discarded - lv_reduce() and
 
8
remove_mirrors_from_segments().
 
9
 
 
10
Origin: upstream, https://lists.fedorahosted.org/pipermail/lvm2-commits/2012-June/000039.html
 
11
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=832392
 
12
Bug-Debian: http://bugs.debian.org/691271
 
13
---
 
14
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
 
15
index 71ca1ab..9f8e0e3 100644
 
16
--- a/lib/metadata/lv_alloc.h
 
17
+++ b/lib/metadata/lv_alloc.h
 
18
@@ -42,6 +42,7 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
 
19
                         struct lv_segment *seg_from, uint32_t area_from);
 
20
 int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
 
21
                            uint32_t area_reduction);
 
22
+int release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction);
 
23
 
 
24
 struct alloc_handle;
 
25
 struct alloc_handle *allocate_extents(struct volume_group *vg,
 
26
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
 
27
index bdcc925..a0be887 100644
 
28
--- a/lib/metadata/lv_manip.c
 
29
+++ b/lib/metadata/lv_manip.c
 
30
@@ -299,17 +299,22 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
 
31
        return seg;
 
32
 }
 
33
 
 
34
-int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
 
35
-                           uint32_t area_reduction)
 
36
+static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s,
 
37
+                                               uint32_t area_reduction, int with_discard)
 
38
 {
 
39
        if (seg_type(seg, s) == AREA_UNASSIGNED)
 
40
                return 1;
 
41
 
 
42
        if (seg_type(seg, s) == AREA_PV) {
 
43
+               if (with_discard && !discard_pv_segment(seg_pvseg(seg, s), area_reduction))
 
44
+                       return_0;
 
45
+
 
46
                if (!release_pv_segment(seg_pvseg(seg, s), area_reduction))
 
47
                        return_0;
 
48
+
 
49
                if (seg->area_len == area_reduction)
 
50
                        seg_type(seg, s) = AREA_UNASSIGNED;
 
51
+
 
52
                return 1;
 
53
        }
 
54
 
 
55
@@ -365,6 +370,16 @@ int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
 
56
        return 1;
 
57
 }
 
58
 
 
59
+int release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction)
 
60
+{
 
61
+       return _release_and_discard_lv_segment_area(seg, s, area_reduction, 1);
 
62
+}
 
63
+
 
64
+int release_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction)
 
65
+{
 
66
+       return _release_and_discard_lv_segment_area(seg, s, area_reduction, 0);
 
67
+}
 
68
+
 
69
 /*
 
70
  * Move a segment area from one segment to another
 
71
  */
 
72
@@ -501,7 +516,7 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
 
73
                area_reduction = reduction;
 
74
 
 
75
        for (s = 0; s < seg->area_count; s++)
 
76
-               if (!release_lv_segment_area(seg, s, area_reduction))
 
77
+               if (!release_and_discard_lv_segment_area(seg, s, area_reduction))
 
78
                        return_0;
 
79
 
 
80
        seg->len -= reduction;
 
81
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
 
82
index d943175..61e4b47 100644
 
83
--- a/lib/metadata/mirror.c
 
84
+++ b/lib/metadata/mirror.c
 
85
@@ -1469,7 +1469,7 @@ int remove_mirrors_from_segments(struct logical_volume *lv,
 
86
                }
 
87
 
 
88
                for (s = new_mirrors + 1; s < seg->area_count; s++)
 
89
-                       if (!release_lv_segment_area(seg, s, seg->area_len))
 
90
+                       if (!release_and_discard_lv_segment_area(seg, s, seg->area_len))
 
91
                                return_0;
 
92
 
 
93
                seg->area_count = new_mirrors + 1;