Skip to content

Commit b98d6cb

Browse files
committed
Merge tag 'for-4.19/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Mike writes: "device mapper fixes - Fix a DM thinp __udivdi3 undefined on 32-bit bug introduced during 4.19 merge window. - Fix leak and dangling pointer in DM multipath's scsi_dh related code. - A couple stable@ fixes for DM cache's resize support. - A DM raid fix to remove "const" from decipher_sync_action()'s return type." * tag 'for-4.19/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm cache: fix resize crash if user doesn't reload cache table dm cache metadata: ignore hints array being too small during resize dm raid: remove bogus const from decipher_sync_action() return type dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer dm thin metadata: fix __udivdi3 undefined on 32-bit
2 parents 3830711 + 5d07384 commit b98d6cb

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

drivers/md/dm-cache-metadata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,8 @@ static int __load_mappings(struct dm_cache_metadata *cmd,
14551455
if (hints_valid) {
14561456
r = dm_array_cursor_next(&cmd->hint_cursor);
14571457
if (r) {
1458-
DMERR("dm_array_cursor_next for hint failed");
1459-
goto out;
1458+
dm_array_cursor_end(&cmd->hint_cursor);
1459+
hints_valid = false;
14601460
}
14611461
}
14621462

drivers/md/dm-cache-target.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,8 +3009,13 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
30093009

30103010
static bool can_resize(struct cache *cache, dm_cblock_t new_size)
30113011
{
3012-
if (from_cblock(new_size) > from_cblock(cache->cache_size))
3013-
return true;
3012+
if (from_cblock(new_size) > from_cblock(cache->cache_size)) {
3013+
if (cache->sized) {
3014+
DMERR("%s: unable to extend cache due to missing cache table reload",
3015+
cache_device_name(cache));
3016+
return false;
3017+
}
3018+
}
30143019

30153020
/*
30163021
* We can't drop a dirty block when shrinking the cache.

drivers/md/dm-mpath.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,19 +806,19 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
806806
}
807807

808808
static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
809-
const char *attached_handler_name, char **error)
809+
const char **attached_handler_name, char **error)
810810
{
811811
struct request_queue *q = bdev_get_queue(bdev);
812812
int r;
813813

814814
if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) {
815815
retain:
816-
if (attached_handler_name) {
816+
if (*attached_handler_name) {
817817
/*
818818
* Clear any hw_handler_params associated with a
819819
* handler that isn't already attached.
820820
*/
821-
if (m->hw_handler_name && strcmp(attached_handler_name, m->hw_handler_name)) {
821+
if (m->hw_handler_name && strcmp(*attached_handler_name, m->hw_handler_name)) {
822822
kfree(m->hw_handler_params);
823823
m->hw_handler_params = NULL;
824824
}
@@ -830,7 +830,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
830830
* handler instead of the original table passed in.
831831
*/
832832
kfree(m->hw_handler_name);
833-
m->hw_handler_name = attached_handler_name;
833+
m->hw_handler_name = *attached_handler_name;
834+
*attached_handler_name = NULL;
834835
}
835836
}
836837

@@ -867,7 +868,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
867868
struct pgpath *p;
868869
struct multipath *m = ti->private;
869870
struct request_queue *q;
870-
const char *attached_handler_name;
871+
const char *attached_handler_name = NULL;
871872

872873
/* we need at least a path arg */
873874
if (as->argc < 1) {
@@ -890,7 +891,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
890891
attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
891892
if (attached_handler_name || m->hw_handler_name) {
892893
INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
893-
r = setup_scsi_dh(p->path.dev->bdev, m, attached_handler_name, &ti->error);
894+
r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
894895
if (r) {
895896
dm_put_device(ti, p->path.dev);
896897
goto bad;
@@ -905,6 +906,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
905906

906907
return p;
907908
bad:
909+
kfree(attached_handler_name);
908910
free_pgpath(p);
909911
return ERR_PTR(r);
910912
}

drivers/md/dm-raid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3353,7 +3353,7 @@ static const char *sync_str(enum sync_state state)
33533353
};
33543354

33553355
/* Return enum sync_state for @mddev derived from @recovery flags */
3356-
static const enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery)
3356+
static enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery)
33573357
{
33583358
if (test_bit(MD_RECOVERY_FROZEN, &recovery))
33593359
return st_frozen;

drivers/md/dm-thin-metadata.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,8 @@ static void __set_metadata_reserve(struct dm_pool_metadata *pmd)
832832
if (r) {
833833
DMERR("could not get size of metadata device");
834834
pmd->metadata_reserve = max_blocks;
835-
} else {
836-
sector_div(total, 10);
837-
pmd->metadata_reserve = min(max_blocks, total);
838-
}
835+
} else
836+
pmd->metadata_reserve = min(max_blocks, div_u64(total, 10));
839837
}
840838

841839
struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,

0 commit comments

Comments
 (0)