From ce1d64e84dbea98d41deaf5db0fe91fd729ad2cd Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 3 May 2017 12:01:27 -0400 Subject: dm cache policy smq: allow demotions to happen even during continuous IO dm-cache's smq policy tries hard to do it's work during the idle periods when there is no IO. But if there are no idle periods (eg, a long fio run) we still need to allow some demotions and promotions to occur. To achieve this, pass @idle=true to queue_promotion()'s free_target_met() call so that free_target_met() doesn't short-circuit the possibility of demotion simply because it isn't an idle period. Fixes: b29d4986d0 ("dm cache: significant rework to leverage dm-bio-prison-v2") Reported-by: John Harrigan Signed-off-by: Joe Thornber Signed-off-by: Mike Snitzer --- drivers/md/dm-cache-policy-smq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c index e0c40aec5e96..d13d9edf8dfe 100644 --- a/drivers/md/dm-cache-policy-smq.c +++ b/drivers/md/dm-cache-policy-smq.c @@ -1214,7 +1214,11 @@ static void queue_promotion(struct smq_policy *mq, dm_oblock_t oblock, return; if (allocator_empty(&mq->cache_alloc)) { - if (!free_target_met(mq, false)) + /* + * We always claim to be 'idle' to ensure some demotions happen + * with continuous loads. + */ + if (!free_target_met(mq, true)) queue_demotion(mq); return; } -- cgit v1.2.3 From 97dfb20309e0ad4fa22deb5bc5ed85604d5014ef Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Thu, 4 May 2017 10:04:18 -0400 Subject: dm cache policy smq: cleanup free_target_met() and clean_target_met() Depending on the passed @idle arg, there may be no need to calculate 'nr_free' or 'nr_clean' respectively in free_target_met() and clean_target_met(). Signed-off-by: Mike Snitzer --- drivers/md/dm-cache-policy-smq.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c index d13d9edf8dfe..72479bd61e11 100644 --- a/drivers/md/dm-cache-policy-smq.c +++ b/drivers/md/dm-cache-policy-smq.c @@ -1120,28 +1120,30 @@ static bool clean_target_met(struct smq_policy *mq, bool idle) * Cache entries may not be populated. So we cannot rely on the * size of the clean queue. */ - unsigned nr_clean = from_cblock(mq->cache_size) - q_size(&mq->dirty); + unsigned nr_clean; - if (idle) + if (idle) { /* * We'd like to clean everything. */ return q_size(&mq->dirty) == 0u; - else - return (nr_clean + btracker_nr_writebacks_queued(mq->bg_work)) >= - percent_to_target(mq, CLEAN_TARGET); + } + + nr_clean = from_cblock(mq->cache_size) - q_size(&mq->dirty); + return (nr_clean + btracker_nr_writebacks_queued(mq->bg_work)) >= + percent_to_target(mq, CLEAN_TARGET); } static bool free_target_met(struct smq_policy *mq, bool idle) { - unsigned nr_free = from_cblock(mq->cache_size) - - mq->cache_alloc.nr_allocated; + unsigned nr_free; - if (idle) - return (nr_free + btracker_nr_demotions_queued(mq->bg_work)) >= - percent_to_target(mq, FREE_TARGET); - else + if (!idle) return true; + + nr_free = from_cblock(mq->cache_size) - mq->cache_alloc.nr_allocated; + return (nr_free + btracker_nr_demotions_queued(mq->bg_work)) >= + percent_to_target(mq, FREE_TARGET); } /*----------------------------------------------------------------*/ -- cgit v1.2.3 From 7ab84db64f119e03b2c42ed919dfee7d6cf0dc3c Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Thu, 4 May 2017 10:32:07 -0400 Subject: dm integrity: improve the Kconfig help text for DM_INTEGRITY Signed-off-by: Mike Snitzer Signed-off-by: Milan Broz --- drivers/md/Kconfig | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 7468a22f9d10..23dbf20a8999 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -502,13 +502,24 @@ config DM_LOG_WRITES If unsure, say N. config DM_INTEGRITY - tristate "Integrity target" + tristate "Integrity target support" depends on BLK_DEV_DM select BLK_DEV_INTEGRITY select DM_BUFIO select CRYPTO select ASYNC_XOR ---help--- - This is the integrity target. + This device-mapper target emulates a block device that has + additional per-sector tags that can be used for storing + integrity information. + + This integrity target is used with the dm-crypt target to + provide authenticated disk encryption or it can be used + standalone. + + To compile this code as a module, choose M here: the module will + be called dm-integrity. + + If unsure, say N. endif # MD -- cgit v1.2.3 From 10add84e276432d9dd8044679a1028dd4084117e Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Fri, 5 May 2017 14:40:13 -0400 Subject: dm cache metadata: fail operations if fail_io mode has been established Otherwise it is possible to trigger crashes due to the metadata being inaccessible yet these methods don't safely account for that possibility without these checks. Cc: stable@vger.kernel.org Reported-by: Mikulas Patocka Signed-off-by: Mike Snitzer --- drivers/md/dm-cache-metadata.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 8568dbd50ba4..4a4e9c75fc4c 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -1624,17 +1624,19 @@ void dm_cache_metadata_set_stats(struct dm_cache_metadata *cmd, int dm_cache_commit(struct dm_cache_metadata *cmd, bool clean_shutdown) { - int r; + int r = -EINVAL; flags_mutator mutator = (clean_shutdown ? set_clean_shutdown : clear_clean_shutdown); WRITE_LOCK(cmd); + if (cmd->fail_io) + goto out; + r = __commit_transaction(cmd, mutator); if (r) goto out; r = __begin_transaction(cmd); - out: WRITE_UNLOCK(cmd); return r; @@ -1646,7 +1648,8 @@ int dm_cache_get_free_metadata_block_count(struct dm_cache_metadata *cmd, int r = -EINVAL; READ_LOCK(cmd); - r = dm_sm_get_nr_free(cmd->metadata_sm, result); + if (!cmd->fail_io) + r = dm_sm_get_nr_free(cmd->metadata_sm, result); READ_UNLOCK(cmd); return r; @@ -1658,7 +1661,8 @@ int dm_cache_get_metadata_dev_size(struct dm_cache_metadata *cmd, int r = -EINVAL; READ_LOCK(cmd); - r = dm_sm_get_nr_blocks(cmd->metadata_sm, result); + if (!cmd->fail_io) + r = dm_sm_get_nr_blocks(cmd->metadata_sm, result); READ_UNLOCK(cmd); return r; -- cgit v1.2.3