Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm cache policy mq: simplify ability to promote sequential IO to the cache

Before, if the user wanted sequential IO to be promoted to the cache
they'd have to set sequential_threshold to some nebulous large value.

Now, the user may easily disable sequential IO detection (and sequential
IO's implicit bypass of the cache) by setting sequential_threshold to 0.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>

+15 -8
+11 -5
Documentation/device-mapper/cache-policies.txt
··· 47 47 'discard_promote_adjustment <value>' 48 48 49 49 The sequential threshold indicates the number of contiguous I/Os 50 - required before a stream is treated as sequential. The random threshold 50 + required before a stream is treated as sequential. Once a stream is 51 + considered sequential it will bypass the cache. The random threshold 51 52 is the number of intervening non-contiguous I/Os that must be seen 52 53 before the stream is treated as random again. 53 54 54 55 The sequential and random thresholds default to 512 and 4 respectively. 55 56 56 - Large, sequential ios are probably better left on the origin device 57 - since spindles tend to have good bandwidth. The io_tracker counts 58 - contiguous I/Os to try to spot when the io is in one of these sequential 59 - modes. 57 + Large, sequential I/Os are probably better left on the origin device 58 + since spindles tend to have good sequential I/O bandwidth. The 59 + io_tracker counts contiguous I/Os to try to spot when the I/O is in one 60 + of these sequential modes. But there are use-cases for wanting to 61 + promote sequential blocks to the cache (e.g. fast application startup). 62 + If sequential threshold is set to 0 the sequential I/O detection is 63 + disabled and sequential I/O will no longer implicitly bypass the cache. 64 + Setting the random threshold to 0 does _not_ disable the random I/O 65 + stream detection. 60 66 61 67 Internally the mq policy determines a promotion threshold. If the hit 62 68 count of a block not in the cache goes above this threshold it gets
+4 -3
drivers/md/dm-cache-policy-mq.c
··· 865 865 if (e && in_cache(mq, e)) 866 866 r = cache_entry_found(mq, e, result); 867 867 868 - else if (iot_pattern(&mq->tracker) == PATTERN_SEQUENTIAL) 868 + else if (mq->tracker.thresholds[PATTERN_SEQUENTIAL] && 869 + iot_pattern(&mq->tracker) == PATTERN_SEQUENTIAL) 869 870 result->op = POLICY_MISS; 870 871 871 872 else if (e) ··· 1291 1290 1292 1291 static struct dm_cache_policy_type mq_policy_type = { 1293 1292 .name = "mq", 1294 - .version = {1, 2, 0}, 1293 + .version = {1, 3, 0}, 1295 1294 .hint_size = 4, 1296 1295 .owner = THIS_MODULE, 1297 1296 .create = mq_create ··· 1299 1298 1300 1299 static struct dm_cache_policy_type default_policy_type = { 1301 1300 .name = "default", 1302 - .version = {1, 2, 0}, 1301 + .version = {1, 3, 0}, 1303 1302 .hint_size = 4, 1304 1303 .owner = THIS_MODULE, 1305 1304 .create = mq_create,