diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-03-07 01:20:36 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-04-25 04:05:28 -0400 |
commit | 72438cddd6d39b293dbc37836a4d3e691d26c356 (patch) | |
tree | 39e013ea1749c2227d8f8a1580191febf779e68f | |
parent | 2ec5a8c118139e756d4d39844550ba77ec3543cc (diff) |
iscsi-target: Add iser network portal attribute
This patch adds a new network portal attribute for iser, that lives
under existing iscsi-target configfs layout at:
/sys/kernel/config/target/iscsi/$TARGETNAME/$TPGT/np/$PORTAL/iser
When lio_target_np_store_iser() is enabled, iscsit_tpg_add_network_portal()
will attempt to start an rdma_cma network portal for iser-target, only if
the external ib_isert module transport has been loaded.
When disabled, iscsit_tpg_del_network_portal() will cease iser login service
on the network portal, and release any external ib_isert module reference.
v4 changes:
- Add request_module for ib_isert to lio_target_np_store_iser()
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 2704daf6ba74..13e9e715ad2e 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -125,8 +125,87 @@ out: | |||
125 | 125 | ||
126 | TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR); | 126 | TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR); |
127 | 127 | ||
128 | static ssize_t lio_target_np_show_iser( | ||
129 | struct se_tpg_np *se_tpg_np, | ||
130 | char *page) | ||
131 | { | ||
132 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | ||
133 | struct iscsi_tpg_np, se_tpg_np); | ||
134 | struct iscsi_tpg_np *tpg_np_iser; | ||
135 | ssize_t rb; | ||
136 | |||
137 | tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND); | ||
138 | if (tpg_np_iser) | ||
139 | rb = sprintf(page, "1\n"); | ||
140 | else | ||
141 | rb = sprintf(page, "0\n"); | ||
142 | |||
143 | return rb; | ||
144 | } | ||
145 | |||
146 | static ssize_t lio_target_np_store_iser( | ||
147 | struct se_tpg_np *se_tpg_np, | ||
148 | const char *page, | ||
149 | size_t count) | ||
150 | { | ||
151 | struct iscsi_np *np; | ||
152 | struct iscsi_portal_group *tpg; | ||
153 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | ||
154 | struct iscsi_tpg_np, se_tpg_np); | ||
155 | struct iscsi_tpg_np *tpg_np_iser = NULL; | ||
156 | char *endptr; | ||
157 | u32 op; | ||
158 | int rc; | ||
159 | |||
160 | op = simple_strtoul(page, &endptr, 0); | ||
161 | if ((op != 1) && (op != 0)) { | ||
162 | pr_err("Illegal value for tpg_enable: %u\n", op); | ||
163 | return -EINVAL; | ||
164 | } | ||
165 | np = tpg_np->tpg_np; | ||
166 | if (!np) { | ||
167 | pr_err("Unable to locate struct iscsi_np from" | ||
168 | " struct iscsi_tpg_np\n"); | ||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | tpg = tpg_np->tpg; | ||
173 | if (iscsit_get_tpg(tpg) < 0) | ||
174 | return -EINVAL; | ||
175 | |||
176 | if (op) { | ||
177 | int rc = request_module("ib_isert"); | ||
178 | if (rc != 0) | ||
179 | pr_warn("Unable to request_module for ib_isert\n"); | ||
180 | |||
181 | tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr, | ||
182 | np->np_ip, tpg_np, ISCSI_INFINIBAND); | ||
183 | if (!tpg_np_iser || IS_ERR(tpg_np_iser)) | ||
184 | goto out; | ||
185 | } else { | ||
186 | tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND); | ||
187 | if (!tpg_np_iser) | ||
188 | goto out; | ||
189 | |||
190 | rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser); | ||
191 | if (rc < 0) | ||
192 | goto out; | ||
193 | } | ||
194 | |||
195 | printk("lio_target_np_store_iser() done, op: %d\n", op); | ||
196 | |||
197 | iscsit_put_tpg(tpg); | ||
198 | return count; | ||
199 | out: | ||
200 | iscsit_put_tpg(tpg); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR); | ||
205 | |||
128 | static struct configfs_attribute *lio_target_portal_attrs[] = { | 206 | static struct configfs_attribute *lio_target_portal_attrs[] = { |
129 | &lio_target_np_sctp.attr, | 207 | &lio_target_np_sctp.attr, |
208 | &lio_target_np_iser.attr, | ||
130 | NULL, | 209 | NULL, |
131 | }; | 210 | }; |
132 | 211 | ||