cregit-Linux how code gets into the kernel

Release 4.7 drivers/md/dm-target.c

Directory: drivers/md
/*
 * Copyright (C) 2001 Sistina Software (UK) Limited
 *
 * This file is released under the GPL.
 */

#include "dm.h"

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/bio.h>


#define DM_MSG_PREFIX "target"

static LIST_HEAD(_targets);
static DECLARE_RWSEM(_lock);


#define DM_MOD_NAME_SIZE 32


static inline struct target_type *__find_target_type(const char *name) { struct target_type *tt; list_for_each_entry(tt, &_targets, list) if (!strcmp(name, tt->name)) return tt; return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox3782.22%133.33%
cheng renquancheng renquan613.33%133.33%
andrew mortonandrew morton24.44%133.33%
Total45100.00%3100.00%


static struct target_type *get_target_type(const char *name) { struct target_type *tt; down_read(&_lock); tt = __find_target_type(name); if (tt && !try_module_get(tt->module)) tt = NULL; up_read(&_lock); return tt; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox4071.43%120.00%
cheng renquancheng renquan814.29%120.00%
joe thornberjoe thornber610.71%240.00%
christoph hellwigchristoph hellwig23.57%120.00%
Total56100.00%5100.00%


static void load_module(const char *name) { request_module("dm-%s", name); }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox1688.89%150.00%
linus torvaldslinus torvalds211.11%150.00%
Total18100.00%2100.00%


struct target_type *dm_get_target_type(const char *name) { struct target_type *tt = get_target_type(name); if (!tt) { load_module(name); tt = get_target_type(name); } return tt; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox4090.91%150.00%
cheng renquancheng renquan49.09%150.00%
Total44100.00%2100.00%


void dm_put_target_type(struct target_type *tt) { down_read(&_lock); module_put(tt->module); up_read(&_lock); }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox2482.76%125.00%
cheng renquancheng renquan26.90%125.00%
joe thornberjoe thornber26.90%125.00%
christoph hellwigchristoph hellwig13.45%125.00%
Total29100.00%4100.00%


int dm_target_iterate(void (*iter_func)(struct target_type *tt, void *param), void *param) { struct target_type *tt; down_read(&_lock); list_for_each_entry(tt, &_targets, list) iter_func(tt, param); up_read(&_lock); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton5795.00%150.00%
cheng renquancheng renquan35.00%150.00%
Total60100.00%2100.00%


int dm_register_target(struct target_type *tt) { int rv = 0; down_write(&_lock); if (__find_target_type(tt->name)) rv = -EEXIST; else list_add(&tt->list, &_targets); up_write(&_lock); return rv; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox5191.07%133.33%
cheng renquancheng renquan35.36%133.33%
joe thornberjoe thornber23.57%133.33%
Total56100.00%3100.00%


void dm_unregister_target(struct target_type *tt) { down_write(&_lock); if (!__find_target_type(tt->name)) { DMCRIT("Unregistering unrecognised target: %s", tt->name); BUG(); } list_del(&tt->list); up_write(&_lock); }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox3972.22%125.00%
mikulas patockamikulas patocka916.67%125.00%
cheng renquancheng renquan47.41%125.00%
joe thornberjoe thornber23.70%125.00%
Total54100.00%4100.00%

/* * io-err: always fails an io, useful for bringing * up LVs that have holes in them. */
static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args) { /* * Return error for discards instead of -EOPNOTSUPP */ tt->num_discard_bios = 1; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox2170.00%120.00%
mike snitzermike snitzer620.00%120.00%
joe thornberjoe thornber13.33%120.00%
alasdair kergonalasdair kergon13.33%120.00%
cheng renquancheng renquan13.33%120.00%
Total30100.00%5100.00%


static void io_err_dtr(struct dm_target *tt) { /* empty */ }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox1191.67%150.00%
cheng renquancheng renquan18.33%150.00%
Total12100.00%2100.00%


static int io_err_map(struct dm_target *tt, struct bio *bio) { return -EIO; }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox1785.00%133.33%
joe thornberjoe thornber210.00%133.33%
cheng renquancheng renquan15.00%133.33%
Total20100.00%3100.00%


static int io_err_map_rq(struct dm_target *ti, struct request *clone, union map_info *map_context) { return -EIO; }

Contributors

PersonTokensPropCommitsCommitProp
mike snitzermike snitzer25100.00%1100.00%
Total25100.00%1100.00%


static int io_err_clone_and_map_rq(struct dm_target *ti, struct request *rq, union map_info *map_context, struct request **clone) { return -EIO; }

Contributors

PersonTokensPropCommitsCommitProp
mike snitzermike snitzer31100.00%1100.00%
Total31100.00%1100.00%


static void io_err_release_clone_rq(struct request *clone) { }

Contributors

PersonTokensPropCommitsCommitProp
mike snitzermike snitzer10100.00%1100.00%
Total10100.00%1100.00%

static struct target_type error_target = { .name = "error", .version = {1, 4, 0}, .features = DM_TARGET_WILDCARD, .ctr = io_err_ctr, .dtr = io_err_dtr, .map = io_err_map, .map_rq = io_err_map_rq, .clone_and_map_rq = io_err_clone_and_map_rq, .release_clone_rq = io_err_release_clone_rq, };
int __init dm_target_init(void) { return dm_register_target(&error_target); }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox1493.33%150.00%
andrew mortonandrew morton16.67%150.00%
Total15100.00%2100.00%


void dm_target_exit(void) { dm_unregister_target(&error_target); }

Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox13100.00%1100.00%
Total13100.00%1100.00%

EXPORT_SYMBOL(dm_register_target); EXPORT_SYMBOL(dm_unregister_target);

Overall Contributors

PersonTokensPropCommitsCommitProp
alan coxalan cox38661.96%15.26%
mike snitzermike snitzer9314.93%421.05%
andrew mortonandrew morton7111.40%315.79%
cheng renquancheng renquan335.30%15.26%
joe thornberjoe thornber193.05%421.05%
mikulas patockamikulas patocka111.77%210.53%
alasdair kergonalasdair kergon50.80%210.53%
christoph hellwigchristoph hellwig30.48%15.26%
linus torvaldslinus torvalds20.32%15.26%
Total623100.00%19100.00%
Directory: drivers/md
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}