Project

General

Profile

Notes on libmultipath » History » Version 2

Gerhard Gonter (uni), 2012-10-02 06:36

1 1 Gerhard Gonter (uni)
h1. Wiki
2 1 Gerhard Gonter (uni)
3 1 Gerhard Gonter (uni)
File source:libmultipath/print.c:
4 1 Gerhard Gonter (uni)
5 1 Gerhard Gonter (uni)
<pre><code class="c">
6 1 Gerhard Gonter (uni)
static int
7 1 Gerhard Gonter (uni)
snprint_hcil (char * buff, size_t len, struct path * pp)
8 1 Gerhard Gonter (uni)
{
9 1 Gerhard Gonter (uni)
        if (pp->sg_id.host_no < 0)
10 1 Gerhard Gonter (uni)
                return snprintf(buff, len, "#:#:#:#");
11 1 Gerhard Gonter (uni)
12 1 Gerhard Gonter (uni)
        return snprintf(buff, len, "%i:%i:%i:%i",
13 1 Gerhard Gonter (uni)
                        pp->sg_id.host_no,
14 1 Gerhard Gonter (uni)
                        pp->sg_id.channel,
15 1 Gerhard Gonter (uni)
                        pp->sg_id.scsi_id,
16 1 Gerhard Gonter (uni)
                        pp->sg_id.lun);
17 1 Gerhard Gonter (uni)
}
18 1 Gerhard Gonter (uni)
</code></pre>
19 1 Gerhard Gonter (uni)
20 1 Gerhard Gonter (uni)
hcil == host channel ID LUN
21 1 Gerhard Gonter (uni)
definiert inf @struct path pp@, siehe 
22 1 Gerhard Gonter (uni)
file source:libmultipath/structs.h:
23 1 Gerhard Gonter (uni)
24 1 Gerhard Gonter (uni)
<pre><code class="c">
25 1 Gerhard Gonter (uni)
struct sg_id {
26 1 Gerhard Gonter (uni)
        int host_no;
27 1 Gerhard Gonter (uni)
        int channel;
28 1 Gerhard Gonter (uni)
        int scsi_id;
29 1 Gerhard Gonter (uni)
        int lun;
30 1 Gerhard Gonter (uni)
        short h_cmd_per_lun;
31 1 Gerhard Gonter (uni)
        short d_queue_depth;
32 1 Gerhard Gonter (uni)
        int unused1;
33 1 Gerhard Gonter (uni)
        int unused2;
34 1 Gerhard Gonter (uni)
};
35 1 Gerhard Gonter (uni)
36 1 Gerhard Gonter (uni)
struct path {
37 1 Gerhard Gonter (uni)
        char dev[FILE_NAME_SIZE];
38 1 Gerhard Gonter (uni)
        char dev_t[BLK_DEV_SIZE];
39 1 Gerhard Gonter (uni)
        struct scsi_idlun scsi_id;
40 1 Gerhard Gonter (uni)
        struct sg_id sg_id;
41 1 Gerhard Gonter (uni)
        char wwid[WWID_SIZE];
42 1 Gerhard Gonter (uni)
        char vendor_id[SCSI_VENDOR_SIZE];
43 1 Gerhard Gonter (uni)
        char product_id[SCSI_PRODUCT_SIZE];
44 1 Gerhard Gonter (uni)
        char rev[SCSI_REV_SIZE];
45 1 Gerhard Gonter (uni)
        char serial[SERIAL_SIZE];
46 1 Gerhard Gonter (uni)
        char tgt_node_name[NODE_NAME_SIZE];
47 1 Gerhard Gonter (uni)
        unsigned long long size;
48 1 Gerhard Gonter (uni)
        unsigned int checkint;
49 1 Gerhard Gonter (uni)
        unsigned int tick;
50 1 Gerhard Gonter (uni)
        int bus;
51 1 Gerhard Gonter (uni)
        int state;
52 1 Gerhard Gonter (uni)
        int dmstate;
53 1 Gerhard Gonter (uni)
        int failcount;
54 1 Gerhard Gonter (uni)
        int priority;
55 1 Gerhard Gonter (uni)
        int pgindex;
56 1 Gerhard Gonter (uni)
        char * getuid;
57 1 Gerhard Gonter (uni)
        char * getprio;
58 1 Gerhard Gonter (uni)
        int getprio_selected;
59 1 Gerhard Gonter (uni)
        struct checker checker;
60 1 Gerhard Gonter (uni)
        struct multipath * mpp;
61 1 Gerhard Gonter (uni)
        int fd;
62 1 Gerhard Gonter (uni)
63 1 Gerhard Gonter (uni)
        /* configlet pointers */
64 1 Gerhard Gonter (uni)
        struct hwentry * hwe;
65 1 Gerhard Gonter (uni)
};
66 1 Gerhard Gonter (uni)
</code></pre>
67 1 Gerhard Gonter (uni)
68 1 Gerhard Gonter (uni)
Befuellt wird @sg_id@ in file source:libmultipath/discovery.c:
69 1 Gerhard Gonter (uni)
70 1 Gerhard Gonter (uni)
<pre><code class="c">
71 1 Gerhard Gonter (uni)
static int
72 1 Gerhard Gonter (uni)
scsi_sysfs_pathinfo (struct path * pp)
73 1 Gerhard Gonter (uni)
{
74 1 Gerhard Gonter (uni)
...
75 1 Gerhard Gonter (uni)
        /*
76 1 Gerhard Gonter (uni)
         * host / bus / target / lun
77 1 Gerhard Gonter (uni)
         */
78 1 Gerhard Gonter (uni)
        if(safe_sprintf(attr_path, "%s/block/%s/device",
79 1 Gerhard Gonter (uni)
                        sysfs_path, pp->dev)) {
80 1 Gerhard Gonter (uni)
                condlog(0, "attr_path too small");
81 1 Gerhard Gonter (uni)
                return 1;
82 1 Gerhard Gonter (uni)
        }
83 1 Gerhard Gonter (uni)
        if (0 > sysfs_get_link(attr_path, attr_buff, sizeof(attr_buff)))
84 1 Gerhard Gonter (uni)
                return 1;
85 1 Gerhard Gonter (uni)
86 1 Gerhard Gonter (uni)
        basename(attr_buff, attr_path);
87 1 Gerhard Gonter (uni)
88 1 Gerhard Gonter (uni)
        sscanf(attr_path, "%i:%i:%i:%i",
89 1 Gerhard Gonter (uni)
                        &pp->sg_id.host_no,
90 1 Gerhard Gonter (uni)
                        &pp->sg_id.channel,
91 1 Gerhard Gonter (uni)
                        &pp->sg_id.scsi_id,
92 1 Gerhard Gonter (uni)
                        &pp->sg_id.lun);
93 1 Gerhard Gonter (uni)
...
94 1 Gerhard Gonter (uni)
        /*
95 1 Gerhard Gonter (uni)
         * target node name
96 1 Gerhard Gonter (uni)
         */
97 1 Gerhard Gonter (uni)
        if(safe_sprintf(attr_path,
98 1 Gerhard Gonter (uni)
                        "%s/class/fc_transport/target%i:%i:%i/node_name",
99 1 Gerhard Gonter (uni)
                        sysfs_path,
100 1 Gerhard Gonter (uni)
                        pp->sg_id.host_no,
101 1 Gerhard Gonter (uni)
                        pp->sg_id.channel,
102 1 Gerhard Gonter (uni)
                        pp->sg_id.scsi_id)) { ... }
103 1 Gerhard Gonter (uni)
...
104 1 Gerhard Gonter (uni)
}
105 1 Gerhard Gonter (uni)
</code></pre>
106 1 Gerhard Gonter (uni)
107 1 Gerhard Gonter (uni)
basename() ist keine libc Funktion, sie ist in util.c definiert und kopiert string1 ab dem letzten Slash auf string2 um.
108 1 Gerhard Gonter (uni)
109 1 Gerhard Gonter (uni)
110 2 Gerhard Gonter (uni)
Interessant auch das File source:libmultipath/hwtable.c#L925:
111 1 Gerhard Gonter (uni)
112 1 Gerhard Gonter (uni)
<pre><code class="c">
113 1 Gerhard Gonter (uni)
114 1 Gerhard Gonter (uni)
        /*
115 1 Gerhard Gonter (uni)
         * NETAPP controller family
116 1 Gerhard Gonter (uni)
         *
117 1 Gerhard Gonter (uni)
         * Maintainer : Dave Wysochanski
118 1 Gerhard Gonter (uni)
         * Mail : davidw@netapp.com
119 1 Gerhard Gonter (uni)
         */
120 1 Gerhard Gonter (uni)
        {
121 1 Gerhard Gonter (uni)
                .vendor        = "NETAPP",
122 1 Gerhard Gonter (uni)
                .product       = "LUN.*",
123 1 Gerhard Gonter (uni)
                .getuid        = DEFAULT_GETUID,
124 1 Gerhard Gonter (uni)
                .getprio       = "/sbin/mpath_prio_netapp /dev/%n",
125 1 Gerhard Gonter (uni)
                .features      = "1 queue_if_no_path",
126 1 Gerhard Gonter (uni)
                .hwhandler     = DEFAULT_HWHANDLER,
127 1 Gerhard Gonter (uni)
                .selector      = DEFAULT_SELECTOR,
128 1 Gerhard Gonter (uni)
                .pgpolicy      = GROUP_BY_PRIO,
129 1 Gerhard Gonter (uni)
                .pgfailback    = -FAILBACK_IMMEDIATE,
130 1 Gerhard Gonter (uni)
                .rr_weight     = RR_WEIGHT_NONE,
131 1 Gerhard Gonter (uni)
                .no_path_retry = NO_PATH_RETRY_UNDEF,
132 1 Gerhard Gonter (uni)
                .minio         = 128,
133 1 Gerhard Gonter (uni)
                .checker_name  = READSECTOR0,
134 1 Gerhard Gonter (uni)
        },
135 1 Gerhard Gonter (uni)
136 1 Gerhard Gonter (uni)
</pre>