Skip to content

Commit

Permalink
Merge tag 'dm-3.19-fixes-3' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:
 "One stable fix for a dm-cache 3.19-rc6 regression and one stable fix
  for dm-thin:

   - fix DM cache metadata open/lookup error paths to properly use
     ERR_PTR and IS_ERR (fixes: 3.19-rc6 "stable" commit 9b1cc9f)

   - fix DM thin-provisioning to disallow userspace from sending
     messages to the thin-pool if the pool is in READ_ONLY or FAIL mode
     since no metadata changes are allowed in these modes"

* tag 'dm-3.19-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm thin: don't allow messages to be sent to a pool target in READ_ONLY or FAIL mode
  dm cache: fix missing ERR_PTR returns and handling
  • Loading branch information
Linus Torvalds committed Jan 29, 2015
2 parents 353a0c6 + 2a7eaea commit 1c999c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/md/dm-cache-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ static struct dm_cache_metadata *metadata_open(struct block_device *bdev,
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
DMERR("could not allocate metadata struct");
return NULL;
return ERR_PTR(-ENOMEM);
}

atomic_set(&cmd->ref_count, 1);
Expand Down Expand Up @@ -745,7 +745,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev,
return cmd;

cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size);
if (cmd) {
if (!IS_ERR(cmd)) {
mutex_lock(&table_lock);
cmd2 = lookup(bdev);
if (cmd2) {
Expand Down Expand Up @@ -780,9 +780,10 @@ struct dm_cache_metadata *dm_cache_metadata_open(struct block_device *bdev,
{
struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size,
may_format_device, policy_hint_size);
if (cmd && !same_params(cmd, data_block_size)) {

if (!IS_ERR(cmd) && !same_params(cmd, data_block_size)) {
dm_cache_metadata_close(cmd);
return NULL;
return ERR_PTR(-EINVAL);
}

return cmd;
Expand Down
6 changes: 6 additions & 0 deletions drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,12 @@ static int pool_message(struct dm_target *ti, unsigned argc, char **argv)
struct pool_c *pt = ti->private;
struct pool *pool = pt->pool;

if (get_pool_mode(pool) >= PM_READ_ONLY) {
DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode",
dm_device_name(pool->pool_md));
return -EINVAL;
}

if (!strcasecmp(argv[0], "create_thin"))
r = process_create_thin_mesg(argc, argv, pool);

Expand Down

0 comments on commit 1c999c4

Please sign in to comment.