#include "dm-cache-policy-internal.h"
#include <linux/module.h>
#define DM_MSG_PREFIX "cache-policy"
static DEFINE_SPINLOCK(register_lock);
static LIST_HEAD(register_list);
static struct dm_cache_policy_type *__find_policy(const char *name)
struct dm_cache_policy_type *t;
list_for_each_entry(t, ®ister_list, list)
if (!strcmp(t->name, name))
static struct dm_cache_policy_type *__get_policy_once(const char *name)
struct dm_cache_policy_type *t = __find_policy(name);
if (t && !try_module_get(t->owner)) {
DMWARN("couldn't get module %s", name);
static struct dm_cache_policy_type *get_policy_once(const char *name)
struct dm_cache_policy_type *t;
spin_lock(®ister_lock);
t = __get_policy_once(name);
spin_unlock(®ister_lock);
static struct dm_cache_policy_type *get_policy(const char *name)
struct dm_cache_policy_type *t;
t = get_policy_once(name);