cregit-Linux how code gets into the kernel

Release 4.11 drivers/md/dm-path-selector.c

Directory: drivers/md
/*
 * Copyright (C) 2003 Sistina Software.
 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
 *
 * Module Author: Heinz Mauelshagen
 *
 * This file is released under the GPL.
 *
 * Path selector registration.
 */

#include <linux/device-mapper.h>
#include <linux/module.h>

#include "dm-path-selector.h"

#include <linux/slab.h>


struct ps_internal {
	
struct path_selector_type pst;
	
struct list_head list;
};


#define pst_to_psi(__pst) container_of((__pst), struct ps_internal, pst)

static LIST_HEAD(_path_selectors);
static DECLARE_RWSEM(_ps_lock);


static struct ps_internal *__find_path_selector_type(const char *name) { struct ps_internal *psi; list_for_each_entry(psi, &_path_selectors, list) { if (!strcmp(name, psi->pst.name)) return psi; } return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon48100.00%2100.00%
Total48100.00%2100.00%


static struct ps_internal *get_path_selector(const char *name) { struct ps_internal *psi; down_read(&_ps_lock); psi = __find_path_selector_type(name); if (psi && !try_module_get(psi->pst.module)) psi = NULL; up_read(&_ps_lock); return psi; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon58100.00%1100.00%
Total58100.00%1100.00%


struct path_selector_type *dm_get_path_selector(const char *name) { struct ps_internal *psi; if (!name) return NULL; psi = get_path_selector(name); if (!psi) { request_module("dm-%s", name); psi = get_path_selector(name); } return psi ? &psi->pst : NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon63100.00%1100.00%
Total63100.00%1100.00%


void dm_put_path_selector(struct path_selector_type *pst) { struct ps_internal *psi; if (!pst) return; down_read(&_ps_lock); psi = __find_path_selector_type(pst->name); if (!psi) goto out; module_put(psi->pst.module); out: up_read(&_ps_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon61100.00%1100.00%
Total61100.00%1100.00%


static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst) { struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL); if (psi) psi->pst = *pst; return psi; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon4297.67%150.00%
Dmitriy Monakhov12.33%150.00%
Total43100.00%2100.00%


int dm_register_path_selector(struct path_selector_type *pst) { int r = 0; struct ps_internal *psi = _alloc_path_selector(pst); if (!psi) return -ENOMEM; down_write(&_ps_lock); if (__find_path_selector_type(pst->name)) { kfree(psi); r = -EEXIST; } else list_add(&psi->list, &_path_selectors); up_write(&_ps_lock); return r; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon82100.00%1100.00%
Total82100.00%1100.00%


int dm_unregister_path_selector(struct path_selector_type *pst) { struct ps_internal *psi; down_write(&_ps_lock); psi = __find_path_selector_type(pst->name); if (!psi) { up_write(&_ps_lock); return -EINVAL; } list_del(&psi->list); up_write(&_ps_lock); kfree(psi); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon69100.00%1100.00%
Total69100.00%1100.00%

EXPORT_SYMBOL_GPL(dm_register_path_selector); EXPORT_SYMBOL_GPL(dm_unregister_path_selector);

Overall Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon47498.96%350.00%
Paul Gortmaker30.63%116.67%
Mikulas Patocka10.21%116.67%
Dmitriy Monakhov10.21%116.67%
Total479100.00%6100.00%
Directory: drivers/md
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.