Skip to content

Commit adeba81

Browse files
committed
Merge tag 'for-4.15/dm-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull more device mapper updates from Mike Snitzer: "Given your expected travel I figured I'd get these fixes to you sooner rather than later. - a DM multipath stable@ fix to silence an annoying error message that isn't _really_ an error - a DM core @stable fix for discard support that was enabled for an entire DM device despite only having partial support for discards due to a mix of discard capabilities across the underlying devices. - a couple other DM core discard fixes. - a DM bufio @stable fix that resolves a 32-bit overflow" * tag 'for-4.15/dm-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm bufio: fix integer overflow when limiting maximum cache size dm: clear all discard attributes in queue_limits when discards are disabled dm: do not set 'discards_supported' in targets that do not need it dm: discard support requires all targets in a table support discards dm mpath: remove annoying message of 'blk_get_request() returned -11'
2 parents 854ac87 + 74d4108 commit adeba81

5 files changed

Lines changed: 28 additions & 39 deletions

File tree

‎drivers/md/dm-bufio.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ static void __get_memory_limit(struct dm_bufio_client *c,
974974
buffers = c->minimum_buffers;
975975

976976
*limit_buffers = buffers;
977-
*threshold_buffers = buffers * DM_BUFIO_WRITEBACK_PERCENT / 100;
977+
*threshold_buffers = mult_frac(buffers,
978+
DM_BUFIO_WRITEBACK_PERCENT, 100);
978979
}
979980

980981
/*
@@ -1910,19 +1911,15 @@ static int __init dm_bufio_init(void)
19101911
memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
19111912
memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
19121913

1913-
mem = (__u64)((totalram_pages - totalhigh_pages) *
1914-
DM_BUFIO_MEMORY_PERCENT / 100) << PAGE_SHIFT;
1914+
mem = (__u64)mult_frac(totalram_pages - totalhigh_pages,
1915+
DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT;
19151916

19161917
if (mem > ULONG_MAX)
19171918
mem = ULONG_MAX;
19181919

19191920
#ifdef CONFIG_MMU
1920-
/*
1921-
* Get the size of vmalloc space the same way as VMALLOC_TOTAL
1922-
* in fs/proc/internal.h
1923-
*/
1924-
if (mem > (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100)
1925-
mem = (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100;
1921+
if (mem > mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100))
1922+
mem = mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100);
19261923
#endif
19271924

19281925
dm_bufio_default_cache_size = mem;

‎drivers/md/dm-era-target.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,6 @@ static int era_ctr(struct dm_target *ti, unsigned argc, char **argv)
15131513
ti->flush_supported = true;
15141514

15151515
ti->num_discard_bios = 1;
1516-
ti->discards_supported = true;
15171516
era->callbacks.congested_fn = era_is_congested;
15181517
dm_table_add_target_callbacks(ti->table, &era->callbacks);
15191518

‎drivers/md/dm-mpath.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
499499
if (IS_ERR(clone)) {
500500
/* EBUSY, ENODEV or EWOULDBLOCK: requeue */
501501
bool queue_dying = blk_queue_dying(q);
502-
DMERR_LIMIT("blk_get_request() returned %ld%s - requeuing",
503-
PTR_ERR(clone), queue_dying ? " (path offline)" : "");
504502
if (queue_dying) {
505503
atomic_inc(&m->pg_init_in_progress);
506504
activate_or_offline_path(pgpath);

‎drivers/md/dm-raid.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,9 +2887,6 @@ static void configure_discard_support(struct raid_set *rs)
28872887
bool raid456;
28882888
struct dm_target *ti = rs->ti;
28892889

2890-
/* Assume discards not supported until after checks below. */
2891-
ti->discards_supported = false;
2892-
28932890
/*
28942891
* XXX: RAID level 4,5,6 require zeroing for safety.
28952892
*/
@@ -2914,9 +2911,6 @@ static void configure_discard_support(struct raid_set *rs)
29142911
}
29152912
}
29162913

2917-
/* All RAID members properly support discards */
2918-
ti->discards_supported = true;
2919-
29202914
/*
29212915
* RAID1 and RAID10 personalities require bio splitting,
29222916
* RAID0/4/5/6 don't and process large discard bios properly.

‎drivers/md/dm-table.c‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,42 +1758,37 @@ static bool dm_table_supports_write_zeroes(struct dm_table *t)
17581758
return true;
17591759
}
17601760

1761-
1762-
static int device_discard_capable(struct dm_target *ti, struct dm_dev *dev,
1763-
sector_t start, sector_t len, void *data)
1761+
static int device_not_discard_capable(struct dm_target *ti, struct dm_dev *dev,
1762+
sector_t start, sector_t len, void *data)
17641763
{
17651764
struct request_queue *q = bdev_get_queue(dev->bdev);
17661765

1767-
return q && blk_queue_discard(q);
1766+
return q && !blk_queue_discard(q);
17681767
}
17691768

17701769
static bool dm_table_supports_discards(struct dm_table *t)
17711770
{
17721771
struct dm_target *ti;
17731772
unsigned i;
17741773

1775-
/*
1776-
* Unless any target used by the table set discards_supported,
1777-
* require at least one underlying device to support discards.
1778-
* t->devices includes internal dm devices such as mirror logs
1779-
* so we need to use iterate_devices here, which targets
1780-
* supporting discard selectively must provide.
1781-
*/
17821774
for (i = 0; i < dm_table_get_num_targets(t); i++) {
17831775
ti = dm_table_get_target(t, i);
17841776

17851777
if (!ti->num_discard_bios)
1786-
continue;
1787-
1788-
if (ti->discards_supported)
1789-
return true;
1778+
return false;
17901779

1791-
if (ti->type->iterate_devices &&
1792-
ti->type->iterate_devices(ti, device_discard_capable, NULL))
1793-
return true;
1780+
/*
1781+
* Either the target provides discard support (as implied by setting
1782+
* 'discards_supported') or it relies on _all_ data devices having
1783+
* discard support.
1784+
*/
1785+
if (!ti->discards_supported &&
1786+
(!ti->type->iterate_devices ||
1787+
ti->type->iterate_devices(ti, device_not_discard_capable, NULL)))
1788+
return false;
17941789
}
17951790

1796-
return false;
1791+
return true;
17971792
}
17981793

17991794
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
@@ -1806,9 +1801,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18061801
*/
18071802
q->limits = *limits;
18081803

1809-
if (!dm_table_supports_discards(t))
1804+
if (!dm_table_supports_discards(t)) {
18101805
queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
1811-
else
1806+
/* Must also clear discard limits... */
1807+
q->limits.max_discard_sectors = 0;
1808+
q->limits.max_hw_discard_sectors = 0;
1809+
q->limits.discard_granularity = 0;
1810+
q->limits.discard_alignment = 0;
1811+
q->limits.discard_misaligned = 0;
1812+
} else
18121813
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
18131814

18141815
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) {

0 commit comments

Comments
 (0)