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

dm cache: add policy name to status output

The cache's policy may have been established using the "default" alias,
which is currently the "mq" policy but the default policy may change in
the future. It is useful to know exactly which policy is being used.

Add a 'real' member to the dm_cache_policy_type structure and have the
"default" dm_cache_policy_type point to the real "mq"
dm_cache_policy_type. Update dm_cache_policy_get_name() to check if
real is set, if so report the name of the real policy (not the alias).

Requested-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

+17 -3
+2 -1
Documentation/device-mapper/cache.txt
··· 221 221 <cache block size> <#used cache blocks>/<#total cache blocks> 222 222 <#read hits> <#read misses> <#write hits> <#write misses> 223 223 <#demotions> <#promotions> <#dirty> <#features> <features>* 224 - <#core args> <core args>* <#policy args> <policy args>* 224 + <#core args> <core args>* <policy name> <#policy args> <policy args>* 225 225 226 226 metadata block size : Fixed block size for each metadata block in 227 227 sectors ··· 250 250 #core args : Number of core arguments (must be even) 251 251 core args : Key/value pairs for tuning the core 252 252 e.g. migration_threshold 253 + policy name : Name of the policy 253 254 #policy args : Number of policy arguments to follow (must be even) 254 255 policy args : Key/value pairs 255 256 e.g. sequential_threshold
+2 -1
drivers/md/dm-cache-policy-mq.c
··· 1276 1276 .version = {1, 2, 0}, 1277 1277 .hint_size = 4, 1278 1278 .owner = THIS_MODULE, 1279 - .create = mq_create 1279 + .create = mq_create, 1280 + .real = &mq_policy_type 1280 1281 }; 1281 1282 1282 1283 static int __init mq_init(void)
+4
drivers/md/dm-cache-policy.c
··· 146 146 { 147 147 struct dm_cache_policy_type *t = p->private; 148 148 149 + /* if t->real is set then an alias was used (e.g. "default") */ 150 + if (t->real) 151 + return t->real->name; 152 + 149 153 return t->name; 150 154 } 151 155 EXPORT_SYMBOL_GPL(dm_cache_policy_get_name);
+6
drivers/md/dm-cache-policy.h
··· 223 223 unsigned version[CACHE_POLICY_VERSION_SIZE]; 224 224 225 225 /* 226 + * For use by an alias dm_cache_policy_type to point to the 227 + * real dm_cache_policy_type. 228 + */ 229 + struct dm_cache_policy_type *real; 230 + 231 + /* 226 232 * Policies may store a hint for each each cache block. 227 233 * Currently the size of this hint must be 0 or 4 bytes but we 228 234 * expect to relax this in future.
+3 -1
drivers/md/dm-cache-target.c
··· 2832 2832 * <#demotions> <#promotions> <#dirty> 2833 2833 * <#features> <features>* 2834 2834 * <#core args> <core args> 2835 - * <#policy args> <policy args>* 2835 + * <policy name> <#policy args> <policy args>* 2836 2836 */ 2837 2837 static void cache_status(struct dm_target *ti, status_type_t type, 2838 2838 unsigned status_flags, char *result, unsigned maxlen) ··· 2900 2900 } 2901 2901 2902 2902 DMEMIT("2 migration_threshold %llu ", (unsigned long long) cache->migration_threshold); 2903 + 2904 + DMEMIT("%s ", dm_cache_policy_get_name(cache->policy)); 2903 2905 if (sz < maxlen) { 2904 2906 r = policy_emit_config_values(cache->policy, result + sz, maxlen - sz); 2905 2907 if (r)