dm: fix opening log and cow devices for read only tables

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>

authored by Milan Broz and committed by Alasdair G Kergon 024d37e9 4bbba111

+2 -2
+1 -1
drivers/md/dm-log.c
··· 543 543 return -EINVAL; 544 544 } 545 545 546 - r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &dev); 546 + r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev); 547 547 if (r) 548 548 return r; 549 549
+1 -1
drivers/md/dm-snap.c
··· 1080 1080 argv++; 1081 1081 argc--; 1082 1082 1083 - r = dm_get_device(ti, cow_path, FMODE_READ | FMODE_WRITE, &s->cow); 1083 + r = dm_get_device(ti, cow_path, dm_table_get_mode(ti->table), &s->cow); 1084 1084 if (r) { 1085 1085 ti->error = "Cannot get COW device"; 1086 1086 goto bad_cow;