diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-29 18:41:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-29 18:41:27 -0500 |
commit | 1c999c47a9f1772e6d53028b6bf965c6ddb743bd (patch) | |
tree | d096d2f13887eab2880078e4d769a10fd479e203 | |
parent | 353a0c6fcc957939c58cadbd342870445f996a7a (diff) | |
parent | 2a7eaea02b99b6e267b1e89c79acc6e9a51cee3b (diff) |
Merge tag 'dm-3.19-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/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 9b1cc9f251)
- 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
-rw-r--r-- | drivers/md/dm-cache-metadata.c | 9 | ||||
-rw-r--r-- | drivers/md/dm-thin.c | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 21b156242e42..c1c010498a21 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c | |||
@@ -683,7 +683,7 @@ static struct dm_cache_metadata *metadata_open(struct block_device *bdev, | |||
683 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | 683 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
684 | if (!cmd) { | 684 | if (!cmd) { |
685 | DMERR("could not allocate metadata struct"); | 685 | DMERR("could not allocate metadata struct"); |
686 | return NULL; | 686 | return ERR_PTR(-ENOMEM); |
687 | } | 687 | } |
688 | 688 | ||
689 | atomic_set(&cmd->ref_count, 1); | 689 | atomic_set(&cmd->ref_count, 1); |
@@ -745,7 +745,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev, | |||
745 | return cmd; | 745 | return cmd; |
746 | 746 | ||
747 | cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size); | 747 | cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size); |
748 | if (cmd) { | 748 | if (!IS_ERR(cmd)) { |
749 | mutex_lock(&table_lock); | 749 | mutex_lock(&table_lock); |
750 | cmd2 = lookup(bdev); | 750 | cmd2 = lookup(bdev); |
751 | if (cmd2) { | 751 | if (cmd2) { |
@@ -780,9 +780,10 @@ struct dm_cache_metadata *dm_cache_metadata_open(struct block_device *bdev, | |||
780 | { | 780 | { |
781 | struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size, | 781 | struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size, |
782 | may_format_device, policy_hint_size); | 782 | may_format_device, policy_hint_size); |
783 | if (cmd && !same_params(cmd, data_block_size)) { | 783 | |
784 | if (!IS_ERR(cmd) && !same_params(cmd, data_block_size)) { | ||
784 | dm_cache_metadata_close(cmd); | 785 | dm_cache_metadata_close(cmd); |
785 | return NULL; | 786 | return ERR_PTR(-EINVAL); |
786 | } | 787 | } |
787 | 788 | ||
788 | return cmd; | 789 | return cmd; |
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 493478989dbd..07705ee181e3 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -3385,6 +3385,12 @@ static int pool_message(struct dm_target *ti, unsigned argc, char **argv) | |||
3385 | struct pool_c *pt = ti->private; | 3385 | struct pool_c *pt = ti->private; |
3386 | struct pool *pool = pt->pool; | 3386 | struct pool *pool = pt->pool; |
3387 | 3387 | ||
3388 | if (get_pool_mode(pool) >= PM_READ_ONLY) { | ||
3389 | DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode", | ||
3390 | dm_device_name(pool->pool_md)); | ||
3391 | return -EINVAL; | ||
3392 | } | ||
3393 | |||
3388 | if (!strcasecmp(argv[0], "create_thin")) | 3394 | if (!strcasecmp(argv[0], "create_thin")) |
3389 | r = process_create_thin_mesg(argc, argv, pool); | 3395 | r = process_create_thin_mesg(argc, argv, pool); |
3390 | 3396 | ||