Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | iscsi-initiator-utils to use var for config |
| 2 | |
| 3 | Upstream-status: Backport |
| 4 | This patch is from fedora. |
| 5 | |
| 6 | Use /var/lib/iscsi/ instead of /etc/iscsi/ for holding |
| 7 | state files. |
| 8 | |
| 9 | Signed-off-by: Yao Zhao <yao.zhao@windriver.com> |
| 10 | Signed-off-by: Vu Tran <vu.tran@windriver.com> |
| 11 | |
| 12 | diff --git a/README b/README |
| 13 | index 7364b2d..5e8bff8 100644 |
| 14 | --- a/README |
| 15 | +++ b/README |
| 16 | @@ -164,10 +164,10 @@ available on all Linux installations. |
| 17 | |
| 18 | The database contains two tables: |
| 19 | |
| 20 | -- Discovery table (/etc/iscsi/send_targets); |
| 21 | -- Node table (/etc/iscsi/nodes). |
| 22 | +- Discovery table (/var/lib/iscsi/send_targets); |
| 23 | +- Node table (/var/lib/iscsi/nodes). |
| 24 | |
| 25 | -The regular place for iSCSI database files: /etc/iscsi/nodes |
| 26 | +The regular place for iSCSI database files: /var/lib/iscsi/nodes |
| 27 | |
| 28 | The iscsiadm utility is a command-line tool to manage (update, delete, |
| 29 | insert, query) the persistent database. |
| 30 | @@ -444,7 +444,7 @@ a scsi_host per HBA port). |
| 31 | To manage both types of initiator stacks, iscsiadm uses the interface (iface) |
| 32 | structure. For each HBA port or for software iscsi for each network |
| 33 | device (ethX) or NIC, that you wish to bind sessions to you must create |
| 34 | -a iface config /etc/iscsi/ifaces. |
| 35 | +a iface config /var/lib/iscsi/ifaces. |
| 36 | |
| 37 | Prep: |
| 38 | |
| 39 | @@ -478,29 +478,29 @@ Running: |
| 40 | iface0 qla4xxx,00:c0:dd:08:63:e8,20.15.0.7,default,iqn.2005-06.com.redhat:madmax |
| 41 | iface1 qla4xxx,00:c0:dd:08:63:ea,20.15.0.9,default,iqn.2005-06.com.redhat:madmax |
| 42 | |
| 43 | -Will report iface configurations that are setup in /etc/iscsi/ifaces. |
| 44 | +Will report iface configurations that are setup in /var/lib/iscsi/ifaces. |
| 45 | The format is: |
| 46 | |
| 47 | iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname |
| 48 | |
| 49 | For software iscsi, you can create the iface configs by hand, but it is |
| 50 | reccomended that you use iscsiadm's iface mode. There is a iface.example in |
| 51 | -/etc/iscsi/ifaces which can be used as a template for the daring. |
| 52 | +/var/lib/iscsi/ifaces which can be used as a template for the daring. |
| 53 | |
| 54 | For each network object you wish to bind a session to you must create |
| 55 | -a seperate iface config in /etc/iscsi/ifaces and each iface config file |
| 56 | +a seperate iface config in /var/lib/iscsi/ifaces and each iface config file |
| 57 | must have a unique name which is less than or equal to 64 characters. |
| 58 | |
| 59 | Example: |
| 60 | |
| 61 | If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with |
| 62 | MAC address 00:C0:DD:08:63:E7 and you wanted to do software iscsi over |
| 63 | -TCP/IP. Then in /etc/iscsi/ifaces/iface0 you would enter: |
| 64 | +TCP/IP. Then in /var/lib/iscsi/ifaces/iface0 you would enter: |
| 65 | |
| 66 | iface.transport_name = tcp |
| 67 | iface.hwaddress = 00:0F:1F:92:6B:BF |
| 68 | |
| 69 | -and in /etc/iscsi/ifaces/iface1 you would enter: |
| 70 | +and in /var/lib/iscsi/ifaces/iface1 you would enter: |
| 71 | |
| 72 | iface.transport_name = tcp |
| 73 | iface.hwaddress = 00:C0:DD:08:63:E7 |
| 74 | @@ -550,7 +550,7 @@ cxgb3i.00:07:43:05:97:07 cxgb3i,00:07:43:05:97:07,<empty>,<empty>,<empty> |
| 75 | qla4xxx.00:0e:1e:04:8b:2e qla4xxx,00:0e:1e:04:8b:2e,<empty>,<empty>,<empty> |
| 76 | |
| 77 | |
| 78 | -Will report iface configurations that are setup in /etc/iscsi/ifaces. |
| 79 | +Will report iface configurations that are setup in /var/lib/iscsi/ifaces. |
| 80 | The format is: |
| 81 | |
| 82 | iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname |
| 83 | @@ -636,7 +636,7 @@ need a seperate network connection to the target for discovery purposes. |
| 84 | *This will be fixed in the next version of open-iscsi* |
| 85 | |
| 86 | For compatibility reasons, when you run iscsiadm to do discovery, it |
| 87 | -will check for interfaces in /etc/iscsi/iscsi/ifaces that are using |
| 88 | +will check for interfaces in /var/lib/iscsi/iscsi/ifaces that are using |
| 89 | tcp for the iface.transport and it will bind the portals that are discovered |
| 90 | so that they will be logged in through those ifaces. This behavior can also |
| 91 | be overriden by passing in the interfaces you want to use. For the case |
| 92 | @@ -654,7 +654,7 @@ we do not bind a session to a iface, then you can use the special iface |
| 93 | |
| 94 | iscsiadm -m discoverydb -t st -p ip:port -I default --discover -P 1 |
| 95 | |
| 96 | -And if you did not define any interfaces in /etc/iscsi/ifaces and do |
| 97 | +And if you did not define any interfaces in /var/lib/iscsi/ifaces and do |
| 98 | not pass anything into iscsiadm, running iscsiadm will do the default |
| 99 | behavior, where we allow the network subsystem to decide which |
| 100 | device to use. |
| 101 | @@ -696,7 +696,7 @@ To now log into targets it is the same as with sofware iscsi. See section |
| 102 | |
| 103 | ./iscsiadm -m discoverydb -t st -p 192.168.1.1:3260 --discover |
| 104 | |
| 105 | - This will search /etc/iscsi/send_targets for a record with the |
| 106 | + This will search /var/lib/iscsi/send_targets for a record with the |
| 107 | ID [portal = 192.168.1.1:3260 and type = sendtargets. If found it |
| 108 | will perform discovery using the settings stored in the record. |
| 109 | If a record does not exist, it will be created using the iscsid.conf |
| 110 | @@ -705,7 +705,7 @@ To now log into targets it is the same as with sofware iscsi. See section |
| 111 | The argument to -p may also be a hostname instead of an address. |
| 112 | ./iscsiadm -m discoverydb -t st -p smoehost --discover |
| 113 | |
| 114 | - For the ifaces, iscsiadm will first search /etc/iscsi/ifaces for |
| 115 | + For the ifaces, iscsiadm will first search /var/lib/iscsi/ifaces for |
| 116 | interfaces using software iscsi. If any are found then nodes found |
| 117 | during discovery will be setup so that they can logged in through |
| 118 | those interfaces. To specify a specific iface, pass the |
| 119 | @@ -761,7 +761,7 @@ To now log into targets it is the same as with sofware iscsi. See section |
| 120 | This command will perform discovery, but not manipulate the node DB. |
| 121 | |
| 122 | - SendTargets iSCSI Discovery with a specific interface. If you |
| 123 | - wish to only use a subset of the interfaces in /etc/iscsi/ifaces |
| 124 | + wish to only use a subset of the interfaces in /var/lib/iscsi/ifaces |
| 125 | then you can pass them in during discovery: |
| 126 | |
| 127 | ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \ |
| 128 | @@ -1072,8 +1072,8 @@ where targetname is the name of the target and ip_address:port is the address |
| 129 | and port of the portal. tpgt, is the portal group tag of |
| 130 | the portal, and is not used in iscsiadm commands except for static |
| 131 | record creation. And iface name is the name of the iscsi interface |
| 132 | -defined in /etc/iscsi/ifaces. If no interface was defined in |
| 133 | -/etc/iscsi/ifaces or passed in, the default behavior is used. |
| 134 | +defined in /var/lib/iscsi/ifaces. If no interface was defined in |
| 135 | +/var/lib/iscsi/ifaces or passed in, the default behavior is used. |
| 136 | Default here is iscsi_tcp/tcp to be used over which ever NIC the |
| 137 | network layer decides is best. |
| 138 | |
| 139 | @@ -1188,7 +1188,7 @@ If set, iscsid will perform discovery to the address every |
| 140 | discovery.isns.discoveryd_poll_inval or |
| 141 | discovery.sendtargets.discoveryd_poll_inval seconds, |
| 142 | and it will log into any portals found from the discovery source using |
| 143 | -the ifaces in /etc/iscsi/ifaces. |
| 144 | +the ifaces in /var/lib/iscsi/ifaces. |
| 145 | |
| 146 | Note that for iSNS the poll_interval does not have to be set. If not set, |
| 147 | iscsid will only perform rediscovery when it gets a SCN from the server. |
| 148 | diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8 |
| 149 | index 7c209f6..e94cca0 100644 |
| 150 | --- a/doc/iscsiadm.8 |
| 151 | +++ b/doc/iscsiadm.8 |
| 152 | @@ -89,7 +89,7 @@ This option is only valid for ping submode. |
| 153 | .TP |
| 154 | \fB\-I\fR, \fB\-\-interface=\fI[iface]\fR |
| 155 | The interface argument specifies the iSCSI interface to use for the operation. |
| 156 | -iSCSI interfaces (iface) are defined in /etc/iscsi/ifaces. For hardware |
| 157 | +iSCSI interfaces (iface) are defined in /var/lib/iscsi/ifaces. For hardware |
| 158 | iSCSI (qla4xxx) the iface config must have the hardware address |
| 159 | (iface.hwaddress = port's MAC address) |
| 160 | and the driver/transport_name (iface.transport_name). The iface's name is |
| 161 | @@ -166,7 +166,7 @@ If no other options are specified: for \fIdiscoverydb\fR and \fInode\fR, all |
| 162 | of their respective records are displayed; for \fIsession\fR, all active |
| 163 | sessions and connections are displayed; for \fIfw\fR, all boot firmware |
| 164 | values are displayed; for \fIhost\fR, all iSCSI hosts are displayed; and |
| 165 | -for \fIiface\fR, all ifaces setup in /etc/iscsi/ifaces are displayed. |
| 166 | +for \fIiface\fR, all ifaces setup in /var/lib/iscsi/ifaces are displayed. |
| 167 | |
| 168 | .TP |
| 169 | \fB\-n\fR, \fB\-\-name=\fIname\fR |
| 170 | @@ -535,10 +535,10 @@ The configuration file read by \fBiscsid\fR and \fBiscsiadm\fR on startup. |
| 171 | The file containing the iSCSI InitiatorName and InitiatorAlias read by |
| 172 | \fBiscsid\fR and \fBiscsiadm\fR on startup. |
| 173 | .TP |
| 174 | -/etc/iscsi/nodes/ |
| 175 | +/var/lib/iscsi/nodes/ |
| 176 | This directory contains the nodes with their targets. |
| 177 | .TP |
| 178 | -/etc/iscsi/send_targets |
| 179 | +/var/lib/iscsi/send_targets |
| 180 | This directory contains the portals. |
| 181 | |
| 182 | .SH "SEE ALSO" |
| 183 | diff --git a/usr/idbm.c b/usr/idbm.c |
| 184 | index 4d30aa9..316e54f 100644 |
| 185 | --- a/usr/idbm.c |
| 186 | +++ b/usr/idbm.c |
| 187 | @@ -2468,9 +2468,9 @@ free_info: |
| 188 | int idbm_init(idbm_get_config_file_fn *fn) |
| 189 | { |
| 190 | /* make sure root db dir is there */ |
| 191 | - if (access(ISCSI_CONFIG_ROOT, F_OK) != 0) { |
| 192 | - if (mkdir(ISCSI_CONFIG_ROOT, 0660) != 0) { |
| 193 | - log_error("Could not make %s %d\n", ISCSI_CONFIG_ROOT, |
| 194 | + if (access(ISCSIVAR, F_OK) != 0) { |
| 195 | + if (mkdir(ISCSIVAR, 0660) != 0) { |
| 196 | + log_error("Could not make %s %d\n", ISCSIVAR, |
| 197 | errno); |
| 198 | return errno; |
| 199 | } |
| 200 | diff --git a/usr/idbm.h b/usr/idbm.h |
| 201 | index 245f046..f45e86e 100644 |
| 202 | --- a/usr/idbm.h |
| 203 | +++ b/usr/idbm.h |
| 204 | @@ -28,12 +28,16 @@ |
| 205 | #include "config.h" |
| 206 | #include "list.h" |
| 207 | |
| 208 | -#define NODE_CONFIG_DIR ISCSI_CONFIG_ROOT"nodes" |
| 209 | -#define SLP_CONFIG_DIR ISCSI_CONFIG_ROOT"slp" |
| 210 | -#define ISNS_CONFIG_DIR ISCSI_CONFIG_ROOT"isns" |
| 211 | -#define STATIC_CONFIG_DIR ISCSI_CONFIG_ROOT"static" |
| 212 | -#define FW_CONFIG_DIR ISCSI_CONFIG_ROOT"fw" |
| 213 | -#define ST_CONFIG_DIR ISCSI_CONFIG_ROOT"send_targets" |
| 214 | +#define ISCSIVAR "/var/lib/iscsi/" |
| 215 | + |
| 216 | +#define NODE_CONFIG_DIR ISCSIVAR"nodes" |
| 217 | +#define SLP_CONFIG_DIR ISCSIVAR"slp" |
| 218 | +#define ISNS_CONFIG_DIR ISCSIVAR"isns" |
| 219 | +#define STATIC_CONFIG_DIR ISCSIVAR"static" |
| 220 | +#define FW_CONFIG_DIR ISCSIVAR"fw" |
| 221 | +#define ST_CONFIG_DIR ISCSIVAR"send_targets" |
| 222 | + |
| 223 | + |
| 224 | #define ST_CONFIG_NAME "st_config" |
| 225 | #define ISNS_CONFIG_NAME "isns_config" |
| 226 | |
| 227 | diff --git a/usr/iface.h b/usr/iface.h |
| 228 | index 01f7074..2c6ef72 100644 |
| 229 | --- a/usr/iface.h |
| 230 | +++ b/usr/iface.h |
| 231 | @@ -20,7 +20,8 @@ |
| 232 | #ifndef ISCSI_IFACE_H |
| 233 | #define ISCSI_IFACE_H |
| 234 | |
| 235 | -#define IFACE_CONFIG_DIR ISCSI_CONFIG_ROOT"ifaces" |
| 236 | +#include "idbm.h" |
| 237 | +#define IFACE_CONFIG_DIR ISCSIVAR"ifaces" |
| 238 | |
| 239 | struct iface_rec; |
| 240 | struct list_head; |