Skip to content

Commit 024d37e

Browse files
Milan Brozkergon
authored andcommitted
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 75f1dc0 block: check bdev_read_only() from blkdev_get() was applied, loading such tables began to fail. The patch was reverted by e51900f 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>
1 parent 4bbba11 commit 024d37e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/md/dm-log.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int disk_ctr(struct dm_dirty_log *log, struct dm_target *ti,
543543
return -EINVAL;
544544
}
545545

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);
547547
if (r)
548548
return r;
549549

‎drivers/md/dm-snap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
10801080
argv++;
10811081
argc--;
10821082

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);
10841084
if (r) {
10851085
ti->error = "Cannot get COW device";
10861086
goto bad_cow;

0 commit comments

Comments
 (0)