linux/drivers/md/dm-path-selector.c
<<
4" > /spa20" > /form0" > a 4" > href="../linux+v3 op7/drivers/md/dm-path-selector.c">4" > img src="../.static/gfx/right.png" alt=">>">4" /spa20"4" spa2 class="lxr_search">4" 4" > input typ/ophidden" nam/opnavtarget" .204" > input typ/optext" nam/opsearch" idopsearch">4" > butt.14typ/opsubmit">Search /form0" /spa20"4" spa2 class="lxr_prefs"0" > a href="+prefs?return=drivers/md/dm-path-selector.c"4" > onclick="return ajax_prefs();">4" >Prefs" > /a>4" /spa20" > > /div0" > > form ac14.2="ajax+*" method="post" onsubmit="return false;">4" input typ/ophidden" nam/opajax_lookup" idopajax_lookup" .204 > > /form0"4 > > div class="headingbott.m"> > > div idopsearch_results" class="search_results"" 0" > > /div0" div idopcontent">" div idopfile_contents"0
> >1
/a>
spa2 class="comment">/*
/spa20"> >2
/a>
spa2 class="comment"> * Copyright (C) 2003 Sistina Software.
/spa20"> >3
/a>
spa2 class="comment"> * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
/spa20"> >4
/a>
spa2 class="comment"> *
/spa20"> >5
/a>
spa2 class="comment"> * Module Author: Heinz Mauelshagen
/spa20"> >6
/a>
spa2 class="comment"> *
/spa20"> >7
/a>
spa2 class="comment"> * This file is released under the GPL.
/spa20"> >8
/a>
spa2 class="comment"> *
/spa20"> >9
/a>
spa2 class="comment"> * Path selector registra14.2.
/spa20"> e="va>
spa2 class="comment"> */
/spa20"> 11
/a>"> 12
/a>#include <linux/device-mapper.h
/a>>"> 13
/a>#include <linux/module.h
/a>>"> 14
/a>"> 15
/a>#include "dm-path-selector.h
/a>""> 16
/a>"> 17
/a>#include <linux/slab.h
/a>>"> 18
/a>"> 19
/a>struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> {"> 2="va>        struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> 
a href="+code=pst" class="sref">pst"va>;"> 21"va>        struct>
a href="+code=list_head" class="sref">list_head"va> 
a href="+code=list" class="sref">list"va>;"> 22
/a>};"> 23
/a>"> 24
/a>#define 
a href="+code=pst_to_psi" class="sref">pst_to_psi
/a>(
a href="+code=__pst" class="sref">__pst
/a>) 
a href="+code=container_of" class="sref">container_of
/a>((
a href="+code=__pst" class="sref">__pst
/a>), struct>
a href="+code=ps_internal" class="sref">ps_internal
/a>, 
a href="+code=pst" class="sref">pst"va>)"> 25
/a>"> 26
/a>static 
a href="+code=LIST_HEAD" class="sref">LIST_HEAD
/a>(
a href="+code=_path_selectors" class="sref">_path_selectors"va>);"> 27
/a>static 
a href="+code=DECLARE_RWSEM" class="sref">DECLARE_RWSEM
/a>(
a href="+code=_ps_lock" class="sref">_ps_lock"va>);"> 28
/a>"> 29
/a>static struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=__find_path_selector_typ/" class="sref">__find_path_selector_typ/
/a>(const char *
a href="+code=nam/" class="sref">nam/"va>)"> 3="va>{"> 31"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va>;"> 32
/a>"> 33"va>        
a href="+code=list_for_each_entry" class="sref">list_for_each_entry
/a>(
a href="+code=psi" class="sref">psi"va>, &
a href="+code=_path_selectors" class="sref">_path_selectors"va>, 
a href="+code=list" class="sref">list"va>) {"> 34"va>                if (!
a href="+code=strcmp" class="sref">strcmp
/a>(
a href="+code=nam/" class="sref">nam/"va>, 
a href="+code=psi" class="sref">psi"va>->
a href="+code=pst" class="sref">pst"va>.
a href="+code=nam/" class="sref">nam/"va>))"> 35"va>                        return 
a href="+code=psi" class="sref">psi"va>;"> 36"va>        }"> 37
/a>"> 38"va>        return 
a href="+code=NULL" class="sref">NULL"va>;"> 39
/a>}"> 40
/a>"> 41
/a>static struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=get_path_selector" class="sref">get_path_selector
/a>(const char *
a href="+code=nam/" class="sref">nam/"va>)"> 42"va>{"> 43"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va>;"> 44
/a>"> 45"va>        
a href="+code=down_read" class="sref">down_read
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);"> 46"va>        
a href="+code=psi" class="sref">psi"va> = 
a href="+code=__find_path_selector_typ/" class="sref">__find_path_selector_typ/
/a>(
a href="+code=nam/" class="sref">nam/"va>);"> 47"va>        if (
a href="+code=psi" class="sref">psi"va> && !
a href="+code=try_module_get" class="sref">try_module_get
/a>(
a href="+code=psi" class="sref">psi"va>->
a href="+code=pst" class="sref">pst"va>.
a href="+code=module" class="sref">module"va>))"> 48"va>                
a href="+code=psi" class="sref">psi"va> = 
a href="+code=NULL" class="sref">NULL"va>;"> 49"va>        
a href="+code=up_read" class="sref">up_read
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);"> 50
/a>"> 51"va>        return 
a href="+code=psi" class="sref">psi"va>;"> 52
/a>}"> 53
/a>"> 54
/a>struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> *
a href="+code=dm_get_path_selector" class="sref">dm_get_path_selector
/a>(const char *
a href="+code=nam/" class="sref">nam/"va>)"> 55"va>{"> 56"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va>;"> 57
/a>"> 58"va>        if (!
a href="+code=nam/" class="sref">nam/"va>)"> 59"va>                return 
a href="+code=NULL" class="sref">NULL"va>;"> 60
/a>"> 61"va>        
a href="+code=psi" class="sref">psi"va> = 
a href="+code=get_path_selector" class="sref">get_path_selector
/a>(
a href="+code=nam/" class="sref">nam/"va>);"> 62"va>        if (!
a href="+code=psi" class="sref">psi"va>) {"> 63"va>                
a href="+code=request_module" class="sref">request_module
/a>(
spa2 class="string">"dm-%s"nam/"va>);"> 64"va>                
a href="+code=psi" class="sref">psi"va> = 
a href="+code=get_path_selector" class="sref">get_path_selector
/a>(
a href="+code=nam/" class="sref">nam/"va>);"> 65"va>        }"> 66
/a>"> 67"va>        return 
a href="+code=psi" class="sref">psi"va> ? &
a href="+code=psi" class="sref">psi"va>->
a href="+code=pst" class="sref">pst"va> : 
a href="+code=NULL" class="sref">NULL"va>;"> 68
/a>}"> 69
/a>"> 70
/a>void 
a href="+code=dm_put_path_selector" class="sref">dm_put_path_selector
/a>(struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> *
a href="+code=pst" class="sref">pst"va>)"> 71"va>{"> 72"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va>;"> 73
/a>"> 74"va>        if (!
a href="+code=pst" class="sref">pst"va>)"> 75"va>                return;"> 76
/a>"> 77"va>        
a href="+code=down_read" class="sref">down_read
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);"> 78"va>        
a href="+code=psi" class="sref">psi"va> = 
a href="+code=__find_path_selector_typ/" class="sref">__find_path_selector_typ/
/a>(
a href="+code=pst" class="sref">pst"va>->
a href="+code=nam/" class="sref">nam/"va>);"> 79"va>        if (!
a href="+code=psi" class="sref">psi"va>)"> 80"va>                goto 
a href="+code=out" class="sref">out"va>;"> 81
/a>"> 82"va>        
a href="+code=module_put" class="sref">module_put
/a>(
a href="+code=psi" class="sref">psi"va>->
a href="+code=pst" class="sref">pst"va>.
a href="+code=module" class="sref">module"va>);"> 83
/a>
a href="+code=out" class="sref">out"va>:"> 84"va>        
a href="+code=up_read" class="sref">up_read
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);"> 85
/a>}"> 86
/a>"> 87
/a>static struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=_alloc_path_selector" class="sref">_alloc_path_selector
/a>(struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> *
a href="+code=pst" class="sref">pst"va>)"> 88"va>{"> 89"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va> = 
a href="+code=kzalloc" class="sref">kzalloc
/a>(sizeof(*
a href="+code=psi" class="sref">psi"va>), 
a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL"va>);"> 90
/a>"> 91"va>        if (
a href="+code=psi" class="sref">psi"va>)"> 92"va>                
a href="+code=psi" class="sref">psi"va>->
a href="+code=pst" class="sref">pst"va> = *
a href="+code=pst" class="sref">pst"va>;"> 93
/a>"> 94"va>        return 
a href="+code=psi" class="sref">psi"va>;"> 95
/a>}"> 96
/a>"> 97
/a>int 
a href="+code=dm_register_path_selector" class="sref">dm_register_path_selector
/a>(struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> *
a href="+code=pst" class="sref">pst"va>)"> 98"va>{"> 99"va>        int 
a href="+code=r" class="sref">r"va> = 0;">100"va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va> = 
a href="+code=_alloc_path_selector" class="sref">_alloc_path_selector
/a>(
a href="+code=pst" class="sref">pst"va>);">101
/a>">102"va>        if (!
a href="+code=psi" class="sref">psi"va>)">103"va>                return -
a href="+code=ENOMEM" class="sref">ENOMEM"va>;">104
/a>">105"va>        
a href="+code=down_writ/" class="sref">down_writ/
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);">106
/a>">107"va>        if (
a href="+code=__find_path_selector_typ/" class="sref">__find_path_selector_typ/
/a>(
a href="+code=pst" class="sref">pst"va>->
a href="+code=nam/" class="sref">nam/"va>)) {">108"va>                
a href="+code=kfre/" class="sref">kfre/
/a>(
a href="+code=psi" class="sref">psi"va>);">109"va>                
a href="+code=r" class="sref">r"va> = -
a href="+code=EEXIST" class="sref">EEXIST"va>;">110"va>        } else">111"va>                
a href="+code=list_add" class="sref">list_add
/a>(&
a href="+code=psi" class="sref">psi"va>->
a href="+code=list" class="sref">list"va>, &
a href="+code=_path_selectors" class="sref">_path_selectors"va>);">112
/a>">113"va>        
a href="+code=up_writ/" class="sref">up_writ/
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);">114
/a>">115"va>        return 
a href="+code=r" class="sref">r"va>;">116
/a>}">117
/a>">118
/a>int 
a href="+code=dm_unregister_path_selector" class="sref">dm_unregister_path_selector
/a>(struct>
a href="+code=path_selector_typ/" class="sref">path_selector_typ/"va> *
a href="+code=pst" class="sref">pst"va>)">119
/a>{">12="va>        struct>
a href="+code=ps_internal" class="sref">ps_internal
/a> *
a href="+code=psi" class="sref">psi"va>;">121
/a>">122"va>        
a href="+code=down_writ/" class="sref">down_writ/
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);">123
/a>">124"va>        
a href="+code=psi" class="sref">psi"va> = 
a href="+code=__find_path_selector_typ/" class="sref">__find_path_selector_typ/
/a>(
a href="+code=pst" class="sref">pst"va>->
a href="+code=nam/" class="sref">nam/"va>);">125"va>        if (!
a href="+code=psi" class="sref">psi"va>) {">126"va>                
a href="+code=up_writ/" class="sref">up_writ/
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);">127"va>                return -
a href="+code=EINVAL" class="sref">EINVAL"va>;">128"va>        }">129
/a>">130"va>        
a href="+code=list_del" class="sref">list_del
/a>(&
a href="+code=psi" class="sref">psi"va>->
a href="+code=list" class="sref">list"va>);">131
/a>">132"va>        
a href="+code=up_writ/" class="sref">up_writ/
/a>(&
a href="+code=_ps_lock" class="sref">_ps_lock"va>);">133
/a>">134"va>        
a href="+code=kfre/" class="sref">kfre/
/a>(
a href="+code=psi" class="sref">psi"va>);">135
/a>">136"va>        return 0;">137
/a>}">138
/a>">139
/a>
a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL
/a>(
a href="+code=dm_register_path_selector" class="sref">dm_register_path_selector
/a>);">140
/a>
a href="+code=EXPORT_SYMBOL_GPL" class="sref">EXPORT_SYMBOL_GPL
/a>(
a href="+code=dm_unregister_path_selector" class="sref">dm_unregister_path_selector
/a>);">141
/a>
The original LXR software by the LXR community"va>, this experimental vers3.14by lxr@linux.no"va>. /div0" div class="subfooter"> lxr.linux.no kindly hosted4by Redpill Linpro AS"va>, provider of Linux consulting and opera14.2s services since 1995. /div0" /body0" /html0"