Commit 2e68c4e6 authored by Mike Snitzer's avatar Mike Snitzer

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: default avatarJonathan Brassow <jbrassow@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 74aa45c3
...@@ -221,7 +221,7 @@ Status ...@@ -221,7 +221,7 @@ Status
<cache block size> <#used cache blocks>/<#total cache blocks> <cache block size> <#used cache blocks>/<#total cache blocks>
<#read hits> <#read misses> <#write hits> <#write misses> <#read hits> <#read misses> <#write hits> <#write misses>
<#demotions> <#promotions> <#dirty> <#features> <features>* <#demotions> <#promotions> <#dirty> <#features> <features>*
<#core args> <core args>* <#policy args> <policy args>* <#core args> <core args>* <policy name> <#policy args> <policy args>*
metadata block size : Fixed block size for each metadata block in metadata block size : Fixed block size for each metadata block in
sectors sectors
...@@ -250,6 +250,7 @@ feature args : 'writethrough' (optional) ...@@ -250,6 +250,7 @@ feature args : 'writethrough' (optional)
#core args : Number of core arguments (must be even) #core args : Number of core arguments (must be even)
core args : Key/value pairs for tuning the core core args : Key/value pairs for tuning the core
e.g. migration_threshold e.g. migration_threshold
policy name : Name of the policy
#policy args : Number of policy arguments to follow (must be even) #policy args : Number of policy arguments to follow (must be even)
policy args : Key/value pairs policy args : Key/value pairs
e.g. sequential_threshold e.g. sequential_threshold
......
...@@ -1276,7 +1276,8 @@ static struct dm_cache_policy_type default_policy_type = { ...@@ -1276,7 +1276,8 @@ static struct dm_cache_policy_type default_policy_type = {
.version = {1, 2, 0}, .version = {1, 2, 0},
.hint_size = 4, .hint_size = 4,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.create = mq_create .create = mq_create,
.real = &mq_policy_type
}; };
static int __init mq_init(void) static int __init mq_init(void)
......
...@@ -146,6 +146,10 @@ const char *dm_cache_policy_get_name(struct dm_cache_policy *p) ...@@ -146,6 +146,10 @@ const char *dm_cache_policy_get_name(struct dm_cache_policy *p)
{ {
struct dm_cache_policy_type *t = p->private; struct dm_cache_policy_type *t = p->private;
/* if t->real is set then an alias was used (e.g. "default") */
if (t->real)
return t->real->name;
return t->name; return t->name;
} }
EXPORT_SYMBOL_GPL(dm_cache_policy_get_name); EXPORT_SYMBOL_GPL(dm_cache_policy_get_name);
......
...@@ -222,6 +222,12 @@ struct dm_cache_policy_type { ...@@ -222,6 +222,12 @@ struct dm_cache_policy_type {
char name[CACHE_POLICY_NAME_SIZE]; char name[CACHE_POLICY_NAME_SIZE];
unsigned version[CACHE_POLICY_VERSION_SIZE]; unsigned version[CACHE_POLICY_VERSION_SIZE];
/*
* For use by an alias dm_cache_policy_type to point to the
* real dm_cache_policy_type.
*/
struct dm_cache_policy_type *real;
/* /*
* Policies may store a hint for each each cache block. * Policies may store a hint for each each cache block.
* Currently the size of this hint must be 0 or 4 bytes but we * Currently the size of this hint must be 0 or 4 bytes but we
......
...@@ -2832,7 +2832,7 @@ static void cache_resume(struct dm_target *ti) ...@@ -2832,7 +2832,7 @@ static void cache_resume(struct dm_target *ti)
* <#demotions> <#promotions> <#dirty> * <#demotions> <#promotions> <#dirty>
* <#features> <features>* * <#features> <features>*
* <#core args> <core args> * <#core args> <core args>
* <#policy args> <policy args>* * <policy name> <#policy args> <policy args>*
*/ */
static void cache_status(struct dm_target *ti, status_type_t type, static void cache_status(struct dm_target *ti, status_type_t type,
unsigned status_flags, char *result, unsigned maxlen) unsigned status_flags, char *result, unsigned maxlen)
...@@ -2900,6 +2900,8 @@ static void cache_status(struct dm_target *ti, status_type_t type, ...@@ -2900,6 +2900,8 @@ static void cache_status(struct dm_target *ti, status_type_t type,
} }
DMEMIT("2 migration_threshold %llu ", (unsigned long long) cache->migration_threshold); DMEMIT("2 migration_threshold %llu ", (unsigned long long) cache->migration_threshold);
DMEMIT("%s ", dm_cache_policy_get_name(cache->policy));
if (sz < maxlen) { if (sz < maxlen) {
r = policy_emit_config_values(cache->policy, result + sz, maxlen - sz); r = policy_emit_config_values(cache->policy, result + sz, maxlen - sz);
if (r) if (r)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment