]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dm: fix opening log and cow devices for read only tables
authorMilan Broz <mbroz@redhat.com>
Thu, 24 Mar 2011 13:52:14 +0000 (13:52 +0000)
committerAlasdair G Kergon <agk@redhat.com>
Thu, 24 Mar 2011 13:52:14 +0000 (13:52 +0000)
If a table is read-only, also open any log and cow devices it uses read-only.

Previously, even read-only devices were opened read-write internally.
After patch 75f1dc0d076d1c1168f2115f1941ea627d38bd5a
  block: check bdev_read_only() from blkdev_get()
was applied, loading such tables began to fail.  The patch
was reverted by e51900f7d38cbcfb481d84567fd92540e7e1d23a
  block: revert block_dev read-only check
but this patch fixes this part of the code to work with the original patch.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-log.c
drivers/md/dm-snap.c

index 6951536ea29ceab63c8dca6facdb8253ac311dac..8e8a868ca8579d8add68125e7cfc4f188192da31 100644 (file)
@@ -543,7 +543,7 @@ static int disk_ctr(struct dm_dirty_log *log, struct dm_target *ti,
                return -EINVAL;
        }
 
-       r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &dev);
+       r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev);
        if (r)
                return r;
 
index fdde53cd12b7ef4f2bd910939bd5d08f49597829..a2d330942cb29f824c029973ae12a98a2d39efec 100644 (file)
@@ -1080,7 +1080,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        argv++;
        argc--;
 
-       r = dm_get_device(ti, cow_path, FMODE_READ | FMODE_WRITE, &s->cow);
+       r = dm_get_device(ti, cow_path, dm_table_get_mode(ti->table), &s->cow);
        if (r) {
                ti->error = "Cannot get COW device";
                goto bad_cow;