Skip to content

Commit

Permalink
dm: fix opening log and cow devices for read only tables
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Mar 24, 2011
1 parent 4bbba11 commit 024d37e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/md/dm-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 024d37e

Please sign in to comment.