Bug#612439:

Daniel Black daniel.black at openquery.com
Mon Apr 8 03:49:06 UTC 2013


For ref I did a comparison against the only long term supported 2.6.33+ kernel, 2.6.34.14 released 2013-01-16 (ref: https://www.kernel.org/). Note dm-snap got merged into the 2.6.32 kernel on 2009-12-03.

Looking at changes in dm-snap.c (https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/log/drivers/md/dm-snap.c?showmsg=1 ), the log shows two performance improvements, an introduction of a throttling mechanism and a bunch of code clean-ups.

dm-exception-store.c ( https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/log/drivers/md/dm-exception-store.c ) contains two bug fixes.

dm-snap-persistent.c ( https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/log/drivers/md/dm-snap-persistent.c?showmsg=1 )contains a prevention of disk corruption bug fix and moves to non-single threaded work queues.

dm-snap-transient.c ( https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/log/drivers/md/dm-snap-transient.c?showmsg=1 ) added an include of export.h.

If you choose to use the 2.6.34.4 as the base for a backport, the same procedure works with one more change is required due to an API change on dm_get_device.

--- include/linux/device-mapper.h       2009-12-03 14:51:21.000000000 +1100
+++ ../linux-2.6.34.14/include/linux/device-mapper.h    2013-01-17 08:55:31.000000000 +1100
@@ -118,10 +118,9 @@
 /*
  * Constructors should call these functions to ensure destination devices
  * are opened/closed correctly.
- * FIXME: too many arguments.
  */
-int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
-                 sector_t len, fmode_t mode, struct dm_dev **result);
+int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
+                                                struct dm_dev **result);

Basicly 0 for start and ti->len for length is added, the same as the original use of dm_get_device in dm-snap.c. As indicated here: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/md/dm-snap.c?id=8215d6ec5fee1e76545decea2cd73717efb5cb42 these parameters aren't actually used.

So:
--- dm-snap.c-2.6.34.14 2013-03-30 15:06:09.000000000 +1100
+++ dm-snap.c   2013-03-30 15:08:41.000000000 +1100
@@ -1083,7 +1083,7 @@
        argv++;
        argc--;
 
-       r = dm_get_device(ti, origin_path, origin_mode, &s->origin);
+       r = dm_get_device(ti, origin_path, 0, ti->len, origin_mode, &s->origin);
        if (r) {
                ti->error = "Cannot get origin device";
                goto bad_origin;
@@ -1093,7 +1093,7 @@
        argv++;
        argc--;
 
-       r = dm_get_device(ti, cow_path, FMODE_READ | FMODE_WRITE, &s->cow);
+       r = dm_get_device(ti, cow_path, 0, ti->len, FMODE_READ | FMODE_WRITE, &s->cow);
        if (r) {
                ti->error = "Cannot get COW device";
                goto bad_cow;
@@ -2111,7 +2111,7 @@
                return -EINVAL;
        }
 
-       r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev);
+       r = dm_get_device(ti, argv[0], 0, ti->len, dm_table_get_mode(ti->table), &dev);
        if (r) {
                ti->error = "Cannot get target device";
                return r;


I copied dm-snap* and dm-exception* from a 2.6.34.4 kernel with the above modification and INIT_WORK_ON_STACK -> INIT_WORK in dm-exception.c in the linux-source-2.6.32 release. Used the /boot/config-2.6.32 with all modules disabled except for BLK_DEV_MD, BLK_DEV_DM, DM_SNAPSHOT.

Moved the dm-snapshot.ko as above, depmod -a, modprobe -f dm-snaphot, and got the same dmsetup table results.

Testing in a qemu-kvm vm:

lvcreate -s v/src -n src-snap -L 100M

lvs v
  LV       VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  src      v    owi-ao   1.68g                                      
  src-snap v    swi-a- 100.00m src      0.10   

rm /usr/src/README .....

lvconvert --merge v/src-snap
  Can't merge over origin volume
  Merging of snapshot src-snap will start next activitation

umount /usr/src
lvchange -an v/src
lvs v
  LV       VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  src      v    Owi---   1.68g                                      

lvchange -ay v/src
mount /dev/v/src /usr/src
ls /usr/src

(showed files I deleted)

So the 2.6.34.4 is a suitable backport for dm-snaphot as above to allow merge to origin.



More information about the pkg-lvm-maintainers mailing list