cregit-Linux how code gets into the kernel

Release 4.11 drivers/md/dm-target.c

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

#include "dm-core.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 Cox3782.22%133.33%
Cheng Renquan613.33%133.33%
Andrew 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 Cox4071.43%120.00%
Cheng Renquan814.29%120.00%
Joe Thornber610.71%240.00%
Christoph Hellwig23.57%120.00%
Total56100.00%5100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox1688.89%150.00%
Linus 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 Cox4090.91%150.00%
Cheng 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 Cox2482.76%125.00%
Cheng Renquan26.90%125.00%
Joe Thornber26.90%125.00%
Christoph 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 Morton5795.00%150.00%
Cheng 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 Cox5191.07%133.33%
Cheng Renquan35.36%133.33%
Joe 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 Cox3972.22%125.00%
Mikulas Patocka916.67%125.00%
Cheng Renquan47.41%125.00%
Joe 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 Cox2170.00%120.00%
Mike Snitzer620.00%120.00%
Cheng Renquan13.33%120.00%
Joe Thornber13.33%120.00%
Alasdair G. Kergon13.33%120.00%
Total30100.00%5100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox1191.67%150.00%
Cheng 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 Cox1785.00%133.33%
Joe Thornber210.00%133.33%
Cheng Renquan15.00%133.33%
Total20100.00%3100.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 Snitzer31100.00%1100.00%
Total31100.00%1100.00%


static void io_err_release_clone_rq(struct request *clone) { }

Contributors

PersonTokensPropCommitsCommitProp
Mike Snitzer10100.00%1100.00%
Total10100.00%1100.00%


static long io_err_direct_access(struct dm_target *ti, sector_t sector, void **kaddr, pfn_t *pfn, long size) { return -EIO; }

Contributors

PersonTokensPropCommitsCommitProp
Mike Snitzer30100.00%1100.00%
Total30100.00%1100.00%

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

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox1493.33%150.00%
Andrew Morton16.67%150.00%
Total15100.00%2100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox13100.00%1100.00%
Total13100.00%1100.00%

EXPORT_SYMBOL(dm_register_target); EXPORT_SYMBOL(dm_unregister_target);

Overall Contributors

PersonTokensPropCommitsCommitProp
Alan Cox38561.31%14.76%
Mike Snitzer9915.76%628.57%
Andrew Morton7111.31%314.29%
Cheng Renquan335.25%14.76%
Joe Thornber193.03%419.05%
Mikulas Patocka111.75%29.52%
Alasdair G. Kergon50.80%29.52%
Christoph Hellwig30.48%14.76%
Linus Torvalds20.32%14.76%
Total628100.00%21100.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.