]>
Commit | Line | Data |
---|---|---|
c66ac9db NB |
1 | /******************************************************************************* |
2 | * Filename: target_core_configfs.c | |
3 | * | |
4 | * This file contains ConfigFS logic for the Generic Target Engine project. | |
5 | * | |
12d23384 NB |
6 | * Copyright (c) 2008-2011 Rising Tide Systems |
7 | * Copyright (c) 2008-2011 Linux-iSCSI.org | |
c66ac9db NB |
8 | * |
9 | * Nicholas A. Bellinger <nab@kernel.org> | |
10 | * | |
11 | * based on configfs Copyright (C) 2005 Oracle. All rights reserved. | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or modify | |
14 | * it under the terms of the GNU General Public License as published by | |
15 | * the Free Software Foundation; either version 2 of the License, or | |
16 | * (at your option) any later version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | * GNU General Public License for more details. | |
22 | ****************************************************************************/ | |
23 | ||
24 | #include <linux/module.h> | |
25 | #include <linux/moduleparam.h> | |
26 | #include <linux/version.h> | |
27 | #include <generated/utsrelease.h> | |
28 | #include <linux/utsname.h> | |
29 | #include <linux/init.h> | |
30 | #include <linux/fs.h> | |
31 | #include <linux/namei.h> | |
32 | #include <linux/slab.h> | |
33 | #include <linux/types.h> | |
34 | #include <linux/delay.h> | |
35 | #include <linux/unistd.h> | |
36 | #include <linux/string.h> | |
37 | #include <linux/parser.h> | |
38 | #include <linux/syscalls.h> | |
39 | #include <linux/configfs.h> | |
e3d6f909 | 40 | #include <linux/spinlock.h> |
c66ac9db NB |
41 | |
42 | #include <target/target_core_base.h> | |
43 | #include <target/target_core_device.h> | |
44 | #include <target/target_core_transport.h> | |
45 | #include <target/target_core_fabric_ops.h> | |
46 | #include <target/target_core_fabric_configfs.h> | |
47 | #include <target/target_core_configfs.h> | |
48 | #include <target/configfs_macros.h> | |
49 | ||
50 | #include "target_core_alua.h" | |
51 | #include "target_core_hba.h" | |
52 | #include "target_core_pr.h" | |
53 | #include "target_core_rd.h" | |
12d23384 | 54 | #include "target_core_stat.h" |
c66ac9db | 55 | |
e3d6f909 AG |
56 | extern struct t10_alua_lu_gp *default_lu_gp; |
57 | ||
c66ac9db NB |
58 | static struct list_head g_tf_list; |
59 | static struct mutex g_tf_lock; | |
60 | ||
61 | struct target_core_configfs_attribute { | |
62 | struct configfs_attribute attr; | |
63 | ssize_t (*show)(void *, char *); | |
64 | ssize_t (*store)(void *, const char *, size_t); | |
65 | }; | |
66 | ||
e3d6f909 AG |
67 | static struct config_group target_core_hbagroup; |
68 | static struct config_group alua_group; | |
69 | static struct config_group alua_lu_gps_group; | |
70 | ||
71 | static DEFINE_SPINLOCK(se_device_lock); | |
72 | static LIST_HEAD(se_dev_list); | |
73 | ||
c66ac9db NB |
74 | static inline struct se_hba * |
75 | item_to_hba(struct config_item *item) | |
76 | { | |
77 | return container_of(to_config_group(item), struct se_hba, hba_group); | |
78 | } | |
79 | ||
80 | /* | |
81 | * Attributes for /sys/kernel/config/target/ | |
82 | */ | |
83 | static ssize_t target_core_attr_show(struct config_item *item, | |
84 | struct configfs_attribute *attr, | |
85 | char *page) | |
86 | { | |
87 | return sprintf(page, "Target Engine Core ConfigFS Infrastructure %s" | |
88 | " on %s/%s on "UTS_RELEASE"\n", TARGET_CORE_CONFIGFS_VERSION, | |
89 | utsname()->sysname, utsname()->machine); | |
90 | } | |
91 | ||
92 | static struct configfs_item_operations target_core_fabric_item_ops = { | |
93 | .show_attribute = target_core_attr_show, | |
94 | }; | |
95 | ||
96 | static struct configfs_attribute target_core_item_attr_version = { | |
97 | .ca_owner = THIS_MODULE, | |
98 | .ca_name = "version", | |
99 | .ca_mode = S_IRUGO, | |
100 | }; | |
101 | ||
102 | static struct target_fabric_configfs *target_core_get_fabric( | |
103 | const char *name) | |
104 | { | |
105 | struct target_fabric_configfs *tf; | |
106 | ||
6708bb27 | 107 | if (!name) |
c66ac9db NB |
108 | return NULL; |
109 | ||
110 | mutex_lock(&g_tf_lock); | |
111 | list_for_each_entry(tf, &g_tf_list, tf_list) { | |
6708bb27 | 112 | if (!strcmp(tf->tf_name, name)) { |
c66ac9db NB |
113 | atomic_inc(&tf->tf_access_cnt); |
114 | mutex_unlock(&g_tf_lock); | |
115 | return tf; | |
116 | } | |
117 | } | |
118 | mutex_unlock(&g_tf_lock); | |
119 | ||
120 | return NULL; | |
121 | } | |
122 | ||
123 | /* | |
124 | * Called from struct target_core_group_ops->make_group() | |
125 | */ | |
126 | static struct config_group *target_core_register_fabric( | |
127 | struct config_group *group, | |
128 | const char *name) | |
129 | { | |
130 | struct target_fabric_configfs *tf; | |
131 | int ret; | |
132 | ||
6708bb27 | 133 | pr_debug("Target_Core_ConfigFS: REGISTER -> group: %p name:" |
c66ac9db NB |
134 | " %s\n", group, name); |
135 | /* | |
136 | * Ensure that TCM subsystem plugins are loaded at this point for | |
137 | * using the RAMDISK_DR virtual LUN 0 and all other struct se_port | |
138 | * LUN symlinks. | |
139 | */ | |
140 | if (transport_subsystem_check_init() < 0) | |
141 | return ERR_PTR(-EINVAL); | |
142 | ||
143 | /* | |
144 | * Below are some hardcoded request_module() calls to automatically | |
145 | * local fabric modules when the following is called: | |
146 | * | |
147 | * mkdir -p /sys/kernel/config/target/$MODULE_NAME | |
148 | * | |
149 | * Note that this does not limit which TCM fabric module can be | |
150 | * registered, but simply provids auto loading logic for modules with | |
151 | * mkdir(2) system calls with known TCM fabric modules. | |
152 | */ | |
6708bb27 | 153 | if (!strncmp(name, "iscsi", 5)) { |
c66ac9db NB |
154 | /* |
155 | * Automatically load the LIO Target fabric module when the | |
156 | * following is called: | |
157 | * | |
158 | * mkdir -p $CONFIGFS/target/iscsi | |
159 | */ | |
160 | ret = request_module("iscsi_target_mod"); | |
161 | if (ret < 0) { | |
6708bb27 | 162 | pr_err("request_module() failed for" |
c66ac9db NB |
163 | " iscsi_target_mod.ko: %d\n", ret); |
164 | return ERR_PTR(-EINVAL); | |
165 | } | |
6708bb27 | 166 | } else if (!strncmp(name, "loopback", 8)) { |
c66ac9db NB |
167 | /* |
168 | * Automatically load the tcm_loop fabric module when the | |
169 | * following is called: | |
170 | * | |
171 | * mkdir -p $CONFIGFS/target/loopback | |
172 | */ | |
173 | ret = request_module("tcm_loop"); | |
174 | if (ret < 0) { | |
6708bb27 | 175 | pr_err("request_module() failed for" |
c66ac9db NB |
176 | " tcm_loop.ko: %d\n", ret); |
177 | return ERR_PTR(-EINVAL); | |
178 | } | |
179 | } | |
180 | ||
181 | tf = target_core_get_fabric(name); | |
6708bb27 AG |
182 | if (!tf) { |
183 | pr_err("target_core_get_fabric() failed for %s\n", | |
c66ac9db NB |
184 | name); |
185 | return ERR_PTR(-EINVAL); | |
186 | } | |
6708bb27 | 187 | pr_debug("Target_Core_ConfigFS: REGISTER -> Located fabric:" |
c66ac9db NB |
188 | " %s\n", tf->tf_name); |
189 | /* | |
190 | * On a successful target_core_get_fabric() look, the returned | |
191 | * struct target_fabric_configfs *tf will contain a usage reference. | |
192 | */ | |
6708bb27 | 193 | pr_debug("Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n", |
c66ac9db NB |
194 | &TF_CIT_TMPL(tf)->tfc_wwn_cit); |
195 | ||
196 | tf->tf_group.default_groups = tf->tf_default_groups; | |
197 | tf->tf_group.default_groups[0] = &tf->tf_disc_group; | |
198 | tf->tf_group.default_groups[1] = NULL; | |
199 | ||
200 | config_group_init_type_name(&tf->tf_group, name, | |
201 | &TF_CIT_TMPL(tf)->tfc_wwn_cit); | |
202 | config_group_init_type_name(&tf->tf_disc_group, "discovery_auth", | |
203 | &TF_CIT_TMPL(tf)->tfc_discovery_cit); | |
204 | ||
6708bb27 | 205 | pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" |
c66ac9db NB |
206 | " %s\n", tf->tf_group.cg_item.ci_name); |
207 | /* | |
208 | * Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item() | |
209 | */ | |
210 | tf->tf_ops.tf_subsys = tf->tf_subsys; | |
211 | tf->tf_fabric = &tf->tf_group.cg_item; | |
6708bb27 | 212 | pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric" |
c66ac9db NB |
213 | " for %s\n", name); |
214 | ||
215 | return &tf->tf_group; | |
216 | } | |
217 | ||
218 | /* | |
219 | * Called from struct target_core_group_ops->drop_item() | |
220 | */ | |
221 | static void target_core_deregister_fabric( | |
222 | struct config_group *group, | |
223 | struct config_item *item) | |
224 | { | |
225 | struct target_fabric_configfs *tf = container_of( | |
226 | to_config_group(item), struct target_fabric_configfs, tf_group); | |
227 | struct config_group *tf_group; | |
228 | struct config_item *df_item; | |
229 | int i; | |
230 | ||
6708bb27 | 231 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Looking up %s in" |
c66ac9db NB |
232 | " tf list\n", config_item_name(item)); |
233 | ||
6708bb27 | 234 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> located fabric:" |
c66ac9db NB |
235 | " %s\n", tf->tf_name); |
236 | atomic_dec(&tf->tf_access_cnt); | |
237 | ||
6708bb27 | 238 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing" |
c66ac9db NB |
239 | " tf->tf_fabric for %s\n", tf->tf_name); |
240 | tf->tf_fabric = NULL; | |
241 | ||
6708bb27 | 242 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci" |
c66ac9db NB |
243 | " %s\n", config_item_name(item)); |
244 | ||
245 | tf_group = &tf->tf_group; | |
246 | for (i = 0; tf_group->default_groups[i]; i++) { | |
247 | df_item = &tf_group->default_groups[i]->cg_item; | |
248 | tf_group->default_groups[i] = NULL; | |
249 | config_item_put(df_item); | |
250 | } | |
251 | config_item_put(item); | |
252 | } | |
253 | ||
254 | static struct configfs_group_operations target_core_fabric_group_ops = { | |
255 | .make_group = &target_core_register_fabric, | |
256 | .drop_item = &target_core_deregister_fabric, | |
257 | }; | |
258 | ||
259 | /* | |
260 | * All item attributes appearing in /sys/kernel/target/ appear here. | |
261 | */ | |
262 | static struct configfs_attribute *target_core_fabric_item_attrs[] = { | |
263 | &target_core_item_attr_version, | |
264 | NULL, | |
265 | }; | |
266 | ||
267 | /* | |
268 | * Provides Fabrics Groups and Item Attributes for /sys/kernel/config/target/ | |
269 | */ | |
270 | static struct config_item_type target_core_fabrics_item = { | |
271 | .ct_item_ops = &target_core_fabric_item_ops, | |
272 | .ct_group_ops = &target_core_fabric_group_ops, | |
273 | .ct_attrs = target_core_fabric_item_attrs, | |
274 | .ct_owner = THIS_MODULE, | |
275 | }; | |
276 | ||
277 | static struct configfs_subsystem target_core_fabrics = { | |
278 | .su_group = { | |
279 | .cg_item = { | |
280 | .ci_namebuf = "target", | |
281 | .ci_type = &target_core_fabrics_item, | |
282 | }, | |
283 | }, | |
284 | }; | |
285 | ||
286 | static struct configfs_subsystem *target_core_subsystem[] = { | |
287 | &target_core_fabrics, | |
288 | NULL, | |
289 | }; | |
290 | ||
291 | /*############################################################################## | |
292 | // Start functions called by external Target Fabrics Modules | |
293 | //############################################################################*/ | |
294 | ||
295 | /* | |
296 | * First function called by fabric modules to: | |
297 | * | |
298 | * 1) Allocate a struct target_fabric_configfs and save the *fabric_cit pointer. | |
299 | * 2) Add struct target_fabric_configfs to g_tf_list | |
300 | * 3) Return struct target_fabric_configfs to fabric module to be passed | |
301 | * into target_fabric_configfs_register(). | |
302 | */ | |
303 | struct target_fabric_configfs *target_fabric_configfs_init( | |
304 | struct module *fabric_mod, | |
305 | const char *name) | |
306 | { | |
307 | struct target_fabric_configfs *tf; | |
308 | ||
c66ac9db | 309 | if (!(name)) { |
6708bb27 | 310 | pr_err("Unable to locate passed fabric name\n"); |
e3d6f909 | 311 | return ERR_PTR(-EINVAL); |
c66ac9db | 312 | } |
60d645a4 | 313 | if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) { |
6708bb27 | 314 | pr_err("Passed name: %s exceeds TARGET_FABRIC" |
c66ac9db | 315 | "_NAME_SIZE\n", name); |
e3d6f909 | 316 | return ERR_PTR(-EINVAL); |
c66ac9db NB |
317 | } |
318 | ||
319 | tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL); | |
6708bb27 | 320 | if (!tf) |
e3d6f909 | 321 | return ERR_PTR(-ENOMEM); |
c66ac9db NB |
322 | |
323 | INIT_LIST_HEAD(&tf->tf_list); | |
324 | atomic_set(&tf->tf_access_cnt, 0); | |
325 | /* | |
326 | * Setup the default generic struct config_item_type's (cits) in | |
327 | * struct target_fabric_configfs->tf_cit_tmpl | |
328 | */ | |
329 | tf->tf_module = fabric_mod; | |
330 | target_fabric_setup_cits(tf); | |
331 | ||
332 | tf->tf_subsys = target_core_subsystem[0]; | |
333 | snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", name); | |
334 | ||
335 | mutex_lock(&g_tf_lock); | |
336 | list_add_tail(&tf->tf_list, &g_tf_list); | |
337 | mutex_unlock(&g_tf_lock); | |
338 | ||
6708bb27 | 339 | pr_debug("<<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>" |
c66ac9db | 340 | ">>>>>>>>>>>>>>\n"); |
6708bb27 | 341 | pr_debug("Initialized struct target_fabric_configfs: %p for" |
c66ac9db NB |
342 | " %s\n", tf, tf->tf_name); |
343 | return tf; | |
344 | } | |
345 | EXPORT_SYMBOL(target_fabric_configfs_init); | |
346 | ||
347 | /* | |
348 | * Called by fabric plugins after FAILED target_fabric_configfs_register() call. | |
349 | */ | |
350 | void target_fabric_configfs_free( | |
351 | struct target_fabric_configfs *tf) | |
352 | { | |
353 | mutex_lock(&g_tf_lock); | |
354 | list_del(&tf->tf_list); | |
355 | mutex_unlock(&g_tf_lock); | |
356 | ||
357 | kfree(tf); | |
358 | } | |
359 | EXPORT_SYMBOL(target_fabric_configfs_free); | |
360 | ||
361 | /* | |
362 | * Perform a sanity check of the passed tf->tf_ops before completing | |
363 | * TCM fabric module registration. | |
364 | */ | |
365 | static int target_fabric_tf_ops_check( | |
366 | struct target_fabric_configfs *tf) | |
367 | { | |
368 | struct target_core_fabric_ops *tfo = &tf->tf_ops; | |
369 | ||
6708bb27 AG |
370 | if (!tfo->get_fabric_name) { |
371 | pr_err("Missing tfo->get_fabric_name()\n"); | |
c66ac9db NB |
372 | return -EINVAL; |
373 | } | |
6708bb27 AG |
374 | if (!tfo->get_fabric_proto_ident) { |
375 | pr_err("Missing tfo->get_fabric_proto_ident()\n"); | |
c66ac9db NB |
376 | return -EINVAL; |
377 | } | |
6708bb27 AG |
378 | if (!tfo->tpg_get_wwn) { |
379 | pr_err("Missing tfo->tpg_get_wwn()\n"); | |
c66ac9db NB |
380 | return -EINVAL; |
381 | } | |
6708bb27 AG |
382 | if (!tfo->tpg_get_tag) { |
383 | pr_err("Missing tfo->tpg_get_tag()\n"); | |
c66ac9db NB |
384 | return -EINVAL; |
385 | } | |
6708bb27 AG |
386 | if (!tfo->tpg_get_default_depth) { |
387 | pr_err("Missing tfo->tpg_get_default_depth()\n"); | |
c66ac9db NB |
388 | return -EINVAL; |
389 | } | |
6708bb27 AG |
390 | if (!tfo->tpg_get_pr_transport_id) { |
391 | pr_err("Missing tfo->tpg_get_pr_transport_id()\n"); | |
c66ac9db NB |
392 | return -EINVAL; |
393 | } | |
6708bb27 AG |
394 | if (!tfo->tpg_get_pr_transport_id_len) { |
395 | pr_err("Missing tfo->tpg_get_pr_transport_id_len()\n"); | |
c66ac9db NB |
396 | return -EINVAL; |
397 | } | |
6708bb27 AG |
398 | if (!tfo->tpg_check_demo_mode) { |
399 | pr_err("Missing tfo->tpg_check_demo_mode()\n"); | |
c66ac9db NB |
400 | return -EINVAL; |
401 | } | |
6708bb27 AG |
402 | if (!tfo->tpg_check_demo_mode_cache) { |
403 | pr_err("Missing tfo->tpg_check_demo_mode_cache()\n"); | |
c66ac9db NB |
404 | return -EINVAL; |
405 | } | |
6708bb27 AG |
406 | if (!tfo->tpg_check_demo_mode_write_protect) { |
407 | pr_err("Missing tfo->tpg_check_demo_mode_write_protect()\n"); | |
c66ac9db NB |
408 | return -EINVAL; |
409 | } | |
6708bb27 AG |
410 | if (!tfo->tpg_check_prod_mode_write_protect) { |
411 | pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n"); | |
c66ac9db NB |
412 | return -EINVAL; |
413 | } | |
6708bb27 AG |
414 | if (!tfo->tpg_alloc_fabric_acl) { |
415 | pr_err("Missing tfo->tpg_alloc_fabric_acl()\n"); | |
c66ac9db NB |
416 | return -EINVAL; |
417 | } | |
6708bb27 AG |
418 | if (!tfo->tpg_release_fabric_acl) { |
419 | pr_err("Missing tfo->tpg_release_fabric_acl()\n"); | |
c66ac9db NB |
420 | return -EINVAL; |
421 | } | |
6708bb27 AG |
422 | if (!tfo->tpg_get_inst_index) { |
423 | pr_err("Missing tfo->tpg_get_inst_index()\n"); | |
c66ac9db NB |
424 | return -EINVAL; |
425 | } | |
35462975 | 426 | if (!tfo->release_cmd) { |
6708bb27 | 427 | pr_err("Missing tfo->release_cmd()\n"); |
c66ac9db NB |
428 | return -EINVAL; |
429 | } | |
6708bb27 AG |
430 | if (!tfo->shutdown_session) { |
431 | pr_err("Missing tfo->shutdown_session()\n"); | |
c66ac9db NB |
432 | return -EINVAL; |
433 | } | |
6708bb27 AG |
434 | if (!tfo->close_session) { |
435 | pr_err("Missing tfo->close_session()\n"); | |
c66ac9db NB |
436 | return -EINVAL; |
437 | } | |
6708bb27 AG |
438 | if (!tfo->stop_session) { |
439 | pr_err("Missing tfo->stop_session()\n"); | |
c66ac9db NB |
440 | return -EINVAL; |
441 | } | |
6708bb27 AG |
442 | if (!tfo->fall_back_to_erl0) { |
443 | pr_err("Missing tfo->fall_back_to_erl0()\n"); | |
c66ac9db NB |
444 | return -EINVAL; |
445 | } | |
6708bb27 AG |
446 | if (!tfo->sess_logged_in) { |
447 | pr_err("Missing tfo->sess_logged_in()\n"); | |
c66ac9db NB |
448 | return -EINVAL; |
449 | } | |
6708bb27 AG |
450 | if (!tfo->sess_get_index) { |
451 | pr_err("Missing tfo->sess_get_index()\n"); | |
c66ac9db NB |
452 | return -EINVAL; |
453 | } | |
6708bb27 AG |
454 | if (!tfo->write_pending) { |
455 | pr_err("Missing tfo->write_pending()\n"); | |
c66ac9db NB |
456 | return -EINVAL; |
457 | } | |
6708bb27 AG |
458 | if (!tfo->write_pending_status) { |
459 | pr_err("Missing tfo->write_pending_status()\n"); | |
c66ac9db NB |
460 | return -EINVAL; |
461 | } | |
6708bb27 AG |
462 | if (!tfo->set_default_node_attributes) { |
463 | pr_err("Missing tfo->set_default_node_attributes()\n"); | |
c66ac9db NB |
464 | return -EINVAL; |
465 | } | |
6708bb27 AG |
466 | if (!tfo->get_task_tag) { |
467 | pr_err("Missing tfo->get_task_tag()\n"); | |
c66ac9db NB |
468 | return -EINVAL; |
469 | } | |
6708bb27 AG |
470 | if (!tfo->get_cmd_state) { |
471 | pr_err("Missing tfo->get_cmd_state()\n"); | |
c66ac9db NB |
472 | return -EINVAL; |
473 | } | |
6708bb27 AG |
474 | if (!tfo->queue_data_in) { |
475 | pr_err("Missing tfo->queue_data_in()\n"); | |
c66ac9db NB |
476 | return -EINVAL; |
477 | } | |
6708bb27 AG |
478 | if (!tfo->queue_status) { |
479 | pr_err("Missing tfo->queue_status()\n"); | |
c66ac9db NB |
480 | return -EINVAL; |
481 | } | |
6708bb27 AG |
482 | if (!tfo->queue_tm_rsp) { |
483 | pr_err("Missing tfo->queue_tm_rsp()\n"); | |
c66ac9db NB |
484 | return -EINVAL; |
485 | } | |
6708bb27 AG |
486 | if (!tfo->set_fabric_sense_len) { |
487 | pr_err("Missing tfo->set_fabric_sense_len()\n"); | |
c66ac9db NB |
488 | return -EINVAL; |
489 | } | |
6708bb27 AG |
490 | if (!tfo->get_fabric_sense_len) { |
491 | pr_err("Missing tfo->get_fabric_sense_len()\n"); | |
c66ac9db NB |
492 | return -EINVAL; |
493 | } | |
6708bb27 AG |
494 | if (!tfo->is_state_remove) { |
495 | pr_err("Missing tfo->is_state_remove()\n"); | |
c66ac9db NB |
496 | return -EINVAL; |
497 | } | |
c66ac9db NB |
498 | /* |
499 | * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() | |
500 | * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in | |
501 | * target_core_fabric_configfs.c WWN+TPG group context code. | |
502 | */ | |
6708bb27 AG |
503 | if (!tfo->fabric_make_wwn) { |
504 | pr_err("Missing tfo->fabric_make_wwn()\n"); | |
c66ac9db NB |
505 | return -EINVAL; |
506 | } | |
6708bb27 AG |
507 | if (!tfo->fabric_drop_wwn) { |
508 | pr_err("Missing tfo->fabric_drop_wwn()\n"); | |
c66ac9db NB |
509 | return -EINVAL; |
510 | } | |
6708bb27 AG |
511 | if (!tfo->fabric_make_tpg) { |
512 | pr_err("Missing tfo->fabric_make_tpg()\n"); | |
c66ac9db NB |
513 | return -EINVAL; |
514 | } | |
6708bb27 AG |
515 | if (!tfo->fabric_drop_tpg) { |
516 | pr_err("Missing tfo->fabric_drop_tpg()\n"); | |
c66ac9db NB |
517 | return -EINVAL; |
518 | } | |
519 | ||
520 | return 0; | |
521 | } | |
522 | ||
523 | /* | |
524 | * Called 2nd from fabric module with returned parameter of | |
525 | * struct target_fabric_configfs * from target_fabric_configfs_init(). | |
526 | * | |
527 | * Upon a successful registration, the new fabric's struct config_item is | |
528 | * return. Also, a pointer to this struct is set in the passed | |
529 | * struct target_fabric_configfs. | |
530 | */ | |
531 | int target_fabric_configfs_register( | |
532 | struct target_fabric_configfs *tf) | |
533 | { | |
c66ac9db NB |
534 | int ret; |
535 | ||
6708bb27 AG |
536 | if (!tf) { |
537 | pr_err("Unable to locate target_fabric_configfs" | |
c66ac9db NB |
538 | " pointer\n"); |
539 | return -EINVAL; | |
540 | } | |
6708bb27 AG |
541 | if (!tf->tf_subsys) { |
542 | pr_err("Unable to target struct config_subsystem" | |
c66ac9db NB |
543 | " pointer\n"); |
544 | return -EINVAL; | |
545 | } | |
c66ac9db NB |
546 | ret = target_fabric_tf_ops_check(tf); |
547 | if (ret < 0) | |
548 | return ret; | |
549 | ||
6708bb27 | 550 | pr_debug("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>" |
c66ac9db NB |
551 | ">>>>>>>>>>\n"); |
552 | return 0; | |
553 | } | |
554 | EXPORT_SYMBOL(target_fabric_configfs_register); | |
555 | ||
556 | void target_fabric_configfs_deregister( | |
557 | struct target_fabric_configfs *tf) | |
558 | { | |
c66ac9db NB |
559 | struct configfs_subsystem *su; |
560 | ||
6708bb27 AG |
561 | if (!tf) { |
562 | pr_err("Unable to locate passed target_fabric_" | |
c66ac9db NB |
563 | "configfs\n"); |
564 | return; | |
565 | } | |
566 | su = tf->tf_subsys; | |
6708bb27 AG |
567 | if (!su) { |
568 | pr_err("Unable to locate passed tf->tf_subsys" | |
c66ac9db NB |
569 | " pointer\n"); |
570 | return; | |
571 | } | |
6708bb27 | 572 | pr_debug("<<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>>>" |
c66ac9db NB |
573 | ">>>>>>>>>>>>\n"); |
574 | mutex_lock(&g_tf_lock); | |
575 | if (atomic_read(&tf->tf_access_cnt)) { | |
576 | mutex_unlock(&g_tf_lock); | |
6708bb27 | 577 | pr_err("Non zero tf->tf_access_cnt for fabric %s\n", |
c66ac9db NB |
578 | tf->tf_name); |
579 | BUG(); | |
580 | } | |
581 | list_del(&tf->tf_list); | |
582 | mutex_unlock(&g_tf_lock); | |
583 | ||
6708bb27 | 584 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing tf:" |
c66ac9db NB |
585 | " %s\n", tf->tf_name); |
586 | tf->tf_module = NULL; | |
587 | tf->tf_subsys = NULL; | |
588 | kfree(tf); | |
589 | ||
6708bb27 | 590 | pr_debug("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>" |
c66ac9db | 591 | ">>>>>\n"); |
c66ac9db NB |
592 | } |
593 | EXPORT_SYMBOL(target_fabric_configfs_deregister); | |
594 | ||
595 | /*############################################################################## | |
596 | // Stop functions called by external Target Fabrics Modules | |
597 | //############################################################################*/ | |
598 | ||
599 | /* Start functions for struct config_item_type target_core_dev_attrib_cit */ | |
600 | ||
601 | #define DEF_DEV_ATTRIB_SHOW(_name) \ | |
602 | static ssize_t target_core_dev_show_attr_##_name( \ | |
603 | struct se_dev_attrib *da, \ | |
604 | char *page) \ | |
605 | { \ | |
606 | struct se_device *dev; \ | |
607 | struct se_subsystem_dev *se_dev = da->da_sub_dev; \ | |
608 | ssize_t rb; \ | |
609 | \ | |
610 | spin_lock(&se_dev->se_dev_lock); \ | |
611 | dev = se_dev->se_dev_ptr; \ | |
6708bb27 | 612 | if (!dev) { \ |
c66ac9db NB |
613 | spin_unlock(&se_dev->se_dev_lock); \ |
614 | return -ENODEV; \ | |
615 | } \ | |
e3d6f909 AG |
616 | rb = snprintf(page, PAGE_SIZE, "%u\n", \ |
617 | (u32)dev->se_sub_dev->se_dev_attrib._name); \ | |
c66ac9db NB |
618 | spin_unlock(&se_dev->se_dev_lock); \ |
619 | \ | |
620 | return rb; \ | |
621 | } | |
622 | ||
623 | #define DEF_DEV_ATTRIB_STORE(_name) \ | |
624 | static ssize_t target_core_dev_store_attr_##_name( \ | |
625 | struct se_dev_attrib *da, \ | |
626 | const char *page, \ | |
627 | size_t count) \ | |
628 | { \ | |
629 | struct se_device *dev; \ | |
630 | struct se_subsystem_dev *se_dev = da->da_sub_dev; \ | |
631 | unsigned long val; \ | |
632 | int ret; \ | |
633 | \ | |
634 | spin_lock(&se_dev->se_dev_lock); \ | |
635 | dev = se_dev->se_dev_ptr; \ | |
6708bb27 | 636 | if (!dev) { \ |
c66ac9db NB |
637 | spin_unlock(&se_dev->se_dev_lock); \ |
638 | return -ENODEV; \ | |
639 | } \ | |
640 | ret = strict_strtoul(page, 0, &val); \ | |
641 | if (ret < 0) { \ | |
642 | spin_unlock(&se_dev->se_dev_lock); \ | |
6708bb27 | 643 | pr_err("strict_strtoul() failed with" \ |
c66ac9db NB |
644 | " ret: %d\n", ret); \ |
645 | return -EINVAL; \ | |
646 | } \ | |
647 | ret = se_dev_set_##_name(dev, (u32)val); \ | |
648 | spin_unlock(&se_dev->se_dev_lock); \ | |
649 | \ | |
650 | return (!ret) ? count : -EINVAL; \ | |
651 | } | |
652 | ||
653 | #define DEF_DEV_ATTRIB(_name) \ | |
654 | DEF_DEV_ATTRIB_SHOW(_name); \ | |
655 | DEF_DEV_ATTRIB_STORE(_name); | |
656 | ||
657 | #define DEF_DEV_ATTRIB_RO(_name) \ | |
658 | DEF_DEV_ATTRIB_SHOW(_name); | |
659 | ||
660 | CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib); | |
661 | #define SE_DEV_ATTR(_name, _mode) \ | |
662 | static struct target_core_dev_attrib_attribute \ | |
663 | target_core_dev_attrib_##_name = \ | |
664 | __CONFIGFS_EATTR(_name, _mode, \ | |
665 | target_core_dev_show_attr_##_name, \ | |
666 | target_core_dev_store_attr_##_name); | |
667 | ||
668 | #define SE_DEV_ATTR_RO(_name); \ | |
669 | static struct target_core_dev_attrib_attribute \ | |
670 | target_core_dev_attrib_##_name = \ | |
671 | __CONFIGFS_EATTR_RO(_name, \ | |
672 | target_core_dev_show_attr_##_name); | |
673 | ||
674 | DEF_DEV_ATTRIB(emulate_dpo); | |
675 | SE_DEV_ATTR(emulate_dpo, S_IRUGO | S_IWUSR); | |
676 | ||
677 | DEF_DEV_ATTRIB(emulate_fua_write); | |
678 | SE_DEV_ATTR(emulate_fua_write, S_IRUGO | S_IWUSR); | |
679 | ||
680 | DEF_DEV_ATTRIB(emulate_fua_read); | |
681 | SE_DEV_ATTR(emulate_fua_read, S_IRUGO | S_IWUSR); | |
682 | ||
683 | DEF_DEV_ATTRIB(emulate_write_cache); | |
684 | SE_DEV_ATTR(emulate_write_cache, S_IRUGO | S_IWUSR); | |
685 | ||
686 | DEF_DEV_ATTRIB(emulate_ua_intlck_ctrl); | |
687 | SE_DEV_ATTR(emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); | |
688 | ||
689 | DEF_DEV_ATTRIB(emulate_tas); | |
690 | SE_DEV_ATTR(emulate_tas, S_IRUGO | S_IWUSR); | |
691 | ||
692 | DEF_DEV_ATTRIB(emulate_tpu); | |
693 | SE_DEV_ATTR(emulate_tpu, S_IRUGO | S_IWUSR); | |
694 | ||
695 | DEF_DEV_ATTRIB(emulate_tpws); | |
696 | SE_DEV_ATTR(emulate_tpws, S_IRUGO | S_IWUSR); | |
697 | ||
698 | DEF_DEV_ATTRIB(enforce_pr_isids); | |
699 | SE_DEV_ATTR(enforce_pr_isids, S_IRUGO | S_IWUSR); | |
700 | ||
e22a7f07 RD |
701 | DEF_DEV_ATTRIB(is_nonrot); |
702 | SE_DEV_ATTR(is_nonrot, S_IRUGO | S_IWUSR); | |
703 | ||
c66ac9db NB |
704 | DEF_DEV_ATTRIB_RO(hw_block_size); |
705 | SE_DEV_ATTR_RO(hw_block_size); | |
706 | ||
707 | DEF_DEV_ATTRIB(block_size); | |
708 | SE_DEV_ATTR(block_size, S_IRUGO | S_IWUSR); | |
709 | ||
710 | DEF_DEV_ATTRIB_RO(hw_max_sectors); | |
711 | SE_DEV_ATTR_RO(hw_max_sectors); | |
712 | ||
713 | DEF_DEV_ATTRIB(max_sectors); | |
714 | SE_DEV_ATTR(max_sectors, S_IRUGO | S_IWUSR); | |
715 | ||
716 | DEF_DEV_ATTRIB(optimal_sectors); | |
717 | SE_DEV_ATTR(optimal_sectors, S_IRUGO | S_IWUSR); | |
718 | ||
719 | DEF_DEV_ATTRIB_RO(hw_queue_depth); | |
720 | SE_DEV_ATTR_RO(hw_queue_depth); | |
721 | ||
722 | DEF_DEV_ATTRIB(queue_depth); | |
723 | SE_DEV_ATTR(queue_depth, S_IRUGO | S_IWUSR); | |
724 | ||
725 | DEF_DEV_ATTRIB(task_timeout); | |
726 | SE_DEV_ATTR(task_timeout, S_IRUGO | S_IWUSR); | |
727 | ||
728 | DEF_DEV_ATTRIB(max_unmap_lba_count); | |
729 | SE_DEV_ATTR(max_unmap_lba_count, S_IRUGO | S_IWUSR); | |
730 | ||
731 | DEF_DEV_ATTRIB(max_unmap_block_desc_count); | |
732 | SE_DEV_ATTR(max_unmap_block_desc_count, S_IRUGO | S_IWUSR); | |
733 | ||
734 | DEF_DEV_ATTRIB(unmap_granularity); | |
735 | SE_DEV_ATTR(unmap_granularity, S_IRUGO | S_IWUSR); | |
736 | ||
737 | DEF_DEV_ATTRIB(unmap_granularity_alignment); | |
738 | SE_DEV_ATTR(unmap_granularity_alignment, S_IRUGO | S_IWUSR); | |
739 | ||
740 | CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); | |
741 | ||
742 | static struct configfs_attribute *target_core_dev_attrib_attrs[] = { | |
743 | &target_core_dev_attrib_emulate_dpo.attr, | |
744 | &target_core_dev_attrib_emulate_fua_write.attr, | |
745 | &target_core_dev_attrib_emulate_fua_read.attr, | |
746 | &target_core_dev_attrib_emulate_write_cache.attr, | |
747 | &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr, | |
748 | &target_core_dev_attrib_emulate_tas.attr, | |
749 | &target_core_dev_attrib_emulate_tpu.attr, | |
750 | &target_core_dev_attrib_emulate_tpws.attr, | |
751 | &target_core_dev_attrib_enforce_pr_isids.attr, | |
e22a7f07 | 752 | &target_core_dev_attrib_is_nonrot.attr, |
c66ac9db NB |
753 | &target_core_dev_attrib_hw_block_size.attr, |
754 | &target_core_dev_attrib_block_size.attr, | |
755 | &target_core_dev_attrib_hw_max_sectors.attr, | |
756 | &target_core_dev_attrib_max_sectors.attr, | |
757 | &target_core_dev_attrib_optimal_sectors.attr, | |
758 | &target_core_dev_attrib_hw_queue_depth.attr, | |
759 | &target_core_dev_attrib_queue_depth.attr, | |
760 | &target_core_dev_attrib_task_timeout.attr, | |
761 | &target_core_dev_attrib_max_unmap_lba_count.attr, | |
762 | &target_core_dev_attrib_max_unmap_block_desc_count.attr, | |
763 | &target_core_dev_attrib_unmap_granularity.attr, | |
764 | &target_core_dev_attrib_unmap_granularity_alignment.attr, | |
765 | NULL, | |
766 | }; | |
767 | ||
768 | static struct configfs_item_operations target_core_dev_attrib_ops = { | |
769 | .show_attribute = target_core_dev_attrib_attr_show, | |
770 | .store_attribute = target_core_dev_attrib_attr_store, | |
771 | }; | |
772 | ||
773 | static struct config_item_type target_core_dev_attrib_cit = { | |
774 | .ct_item_ops = &target_core_dev_attrib_ops, | |
775 | .ct_attrs = target_core_dev_attrib_attrs, | |
776 | .ct_owner = THIS_MODULE, | |
777 | }; | |
778 | ||
779 | /* End functions for struct config_item_type target_core_dev_attrib_cit */ | |
780 | ||
781 | /* Start functions for struct config_item_type target_core_dev_wwn_cit */ | |
782 | ||
783 | CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn); | |
784 | #define SE_DEV_WWN_ATTR(_name, _mode) \ | |
785 | static struct target_core_dev_wwn_attribute target_core_dev_wwn_##_name = \ | |
786 | __CONFIGFS_EATTR(_name, _mode, \ | |
787 | target_core_dev_wwn_show_attr_##_name, \ | |
788 | target_core_dev_wwn_store_attr_##_name); | |
789 | ||
790 | #define SE_DEV_WWN_ATTR_RO(_name); \ | |
791 | do { \ | |
792 | static struct target_core_dev_wwn_attribute \ | |
793 | target_core_dev_wwn_##_name = \ | |
794 | __CONFIGFS_EATTR_RO(_name, \ | |
795 | target_core_dev_wwn_show_attr_##_name); \ | |
796 | } while (0); | |
797 | ||
798 | /* | |
799 | * VPD page 0x80 Unit serial | |
800 | */ | |
801 | static ssize_t target_core_dev_wwn_show_attr_vpd_unit_serial( | |
802 | struct t10_wwn *t10_wwn, | |
803 | char *page) | |
804 | { | |
805 | struct se_subsystem_dev *se_dev = t10_wwn->t10_sub_dev; | |
806 | struct se_device *dev; | |
807 | ||
808 | dev = se_dev->se_dev_ptr; | |
6708bb27 | 809 | if (!dev) |
c66ac9db NB |
810 | return -ENODEV; |
811 | ||
812 | return sprintf(page, "T10 VPD Unit Serial Number: %s\n", | |
813 | &t10_wwn->unit_serial[0]); | |
814 | } | |
815 | ||
816 | static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial( | |
817 | struct t10_wwn *t10_wwn, | |
818 | const char *page, | |
819 | size_t count) | |
820 | { | |
821 | struct se_subsystem_dev *su_dev = t10_wwn->t10_sub_dev; | |
822 | struct se_device *dev; | |
823 | unsigned char buf[INQUIRY_VPD_SERIAL_LEN]; | |
824 | ||
825 | /* | |
826 | * If Linux/SCSI subsystem_api_t plugin got a VPD Unit Serial | |
827 | * from the struct scsi_device level firmware, do not allow | |
828 | * VPD Unit Serial to be emulated. | |
829 | * | |
830 | * Note this struct scsi_device could also be emulating VPD | |
831 | * information from its drivers/scsi LLD. But for now we assume | |
832 | * it is doing 'the right thing' wrt a world wide unique | |
833 | * VPD Unit Serial Number that OS dependent multipath can depend on. | |
834 | */ | |
835 | if (su_dev->su_dev_flags & SDF_FIRMWARE_VPD_UNIT_SERIAL) { | |
6708bb27 | 836 | pr_err("Underlying SCSI device firmware provided VPD" |
c66ac9db NB |
837 | " Unit Serial, ignoring request\n"); |
838 | return -EOPNOTSUPP; | |
839 | } | |
840 | ||
60d645a4 | 841 | if (strlen(page) >= INQUIRY_VPD_SERIAL_LEN) { |
6708bb27 | 842 | pr_err("Emulated VPD Unit Serial exceeds" |
c66ac9db NB |
843 | " INQUIRY_VPD_SERIAL_LEN: %d\n", INQUIRY_VPD_SERIAL_LEN); |
844 | return -EOVERFLOW; | |
845 | } | |
846 | /* | |
847 | * Check to see if any active $FABRIC_MOD exports exist. If they | |
848 | * do exist, fail here as changing this information on the fly | |
849 | * (underneath the initiator side OS dependent multipath code) | |
850 | * could cause negative effects. | |
851 | */ | |
852 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 853 | if (dev) { |
c66ac9db | 854 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { |
6708bb27 | 855 | pr_err("Unable to set VPD Unit Serial while" |
c66ac9db NB |
856 | " active %d $FABRIC_MOD exports exist\n", |
857 | atomic_read(&dev->dev_export_obj.obj_access_count)); | |
858 | return -EINVAL; | |
859 | } | |
860 | } | |
861 | /* | |
862 | * This currently assumes ASCII encoding for emulated VPD Unit Serial. | |
863 | * | |
864 | * Also, strip any newline added from the userspace | |
865 | * echo $UUID > $TARGET/$HBA/$STORAGE_OBJECT/wwn/vpd_unit_serial | |
866 | */ | |
867 | memset(buf, 0, INQUIRY_VPD_SERIAL_LEN); | |
868 | snprintf(buf, INQUIRY_VPD_SERIAL_LEN, "%s", page); | |
869 | snprintf(su_dev->t10_wwn.unit_serial, INQUIRY_VPD_SERIAL_LEN, | |
870 | "%s", strstrip(buf)); | |
871 | su_dev->su_dev_flags |= SDF_EMULATED_VPD_UNIT_SERIAL; | |
872 | ||
6708bb27 | 873 | pr_debug("Target_Core_ConfigFS: Set emulated VPD Unit Serial:" |
c66ac9db NB |
874 | " %s\n", su_dev->t10_wwn.unit_serial); |
875 | ||
876 | return count; | |
877 | } | |
878 | ||
879 | SE_DEV_WWN_ATTR(vpd_unit_serial, S_IRUGO | S_IWUSR); | |
880 | ||
881 | /* | |
882 | * VPD page 0x83 Protocol Identifier | |
883 | */ | |
884 | static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier( | |
885 | struct t10_wwn *t10_wwn, | |
886 | char *page) | |
887 | { | |
888 | struct se_subsystem_dev *se_dev = t10_wwn->t10_sub_dev; | |
889 | struct se_device *dev; | |
890 | struct t10_vpd *vpd; | |
891 | unsigned char buf[VPD_TMP_BUF_SIZE]; | |
892 | ssize_t len = 0; | |
893 | ||
894 | dev = se_dev->se_dev_ptr; | |
6708bb27 | 895 | if (!dev) |
c66ac9db NB |
896 | return -ENODEV; |
897 | ||
898 | memset(buf, 0, VPD_TMP_BUF_SIZE); | |
899 | ||
900 | spin_lock(&t10_wwn->t10_vpd_lock); | |
901 | list_for_each_entry(vpd, &t10_wwn->t10_vpd_list, vpd_list) { | |
6708bb27 | 902 | if (!vpd->protocol_identifier_set) |
c66ac9db NB |
903 | continue; |
904 | ||
905 | transport_dump_vpd_proto_id(vpd, buf, VPD_TMP_BUF_SIZE); | |
906 | ||
6708bb27 | 907 | if (len + strlen(buf) >= PAGE_SIZE) |
c66ac9db NB |
908 | break; |
909 | ||
910 | len += sprintf(page+len, "%s", buf); | |
911 | } | |
912 | spin_unlock(&t10_wwn->t10_vpd_lock); | |
913 | ||
914 | return len; | |
915 | } | |
916 | ||
917 | static ssize_t target_core_dev_wwn_store_attr_vpd_protocol_identifier( | |
918 | struct t10_wwn *t10_wwn, | |
919 | const char *page, | |
920 | size_t count) | |
921 | { | |
922 | return -ENOSYS; | |
923 | } | |
924 | ||
925 | SE_DEV_WWN_ATTR(vpd_protocol_identifier, S_IRUGO | S_IWUSR); | |
926 | ||
927 | /* | |
928 | * Generic wrapper for dumping VPD identifiers by association. | |
929 | */ | |
930 | #define DEF_DEV_WWN_ASSOC_SHOW(_name, _assoc) \ | |
931 | static ssize_t target_core_dev_wwn_show_attr_##_name( \ | |
932 | struct t10_wwn *t10_wwn, \ | |
933 | char *page) \ | |
934 | { \ | |
935 | struct se_subsystem_dev *se_dev = t10_wwn->t10_sub_dev; \ | |
936 | struct se_device *dev; \ | |
937 | struct t10_vpd *vpd; \ | |
938 | unsigned char buf[VPD_TMP_BUF_SIZE]; \ | |
939 | ssize_t len = 0; \ | |
940 | \ | |
941 | dev = se_dev->se_dev_ptr; \ | |
6708bb27 | 942 | if (!dev) \ |
c66ac9db NB |
943 | return -ENODEV; \ |
944 | \ | |
945 | spin_lock(&t10_wwn->t10_vpd_lock); \ | |
946 | list_for_each_entry(vpd, &t10_wwn->t10_vpd_list, vpd_list) { \ | |
947 | if (vpd->association != _assoc) \ | |
948 | continue; \ | |
949 | \ | |
950 | memset(buf, 0, VPD_TMP_BUF_SIZE); \ | |
951 | transport_dump_vpd_assoc(vpd, buf, VPD_TMP_BUF_SIZE); \ | |
6708bb27 | 952 | if (len + strlen(buf) >= PAGE_SIZE) \ |
c66ac9db NB |
953 | break; \ |
954 | len += sprintf(page+len, "%s", buf); \ | |
955 | \ | |
956 | memset(buf, 0, VPD_TMP_BUF_SIZE); \ | |
957 | transport_dump_vpd_ident_type(vpd, buf, VPD_TMP_BUF_SIZE); \ | |
6708bb27 | 958 | if (len + strlen(buf) >= PAGE_SIZE) \ |
c66ac9db NB |
959 | break; \ |
960 | len += sprintf(page+len, "%s", buf); \ | |
961 | \ | |
962 | memset(buf, 0, VPD_TMP_BUF_SIZE); \ | |
963 | transport_dump_vpd_ident(vpd, buf, VPD_TMP_BUF_SIZE); \ | |
6708bb27 | 964 | if (len + strlen(buf) >= PAGE_SIZE) \ |
c66ac9db NB |
965 | break; \ |
966 | len += sprintf(page+len, "%s", buf); \ | |
967 | } \ | |
968 | spin_unlock(&t10_wwn->t10_vpd_lock); \ | |
969 | \ | |
970 | return len; \ | |
971 | } | |
972 | ||
973 | /* | |
974 | * VPD page 0x83 Assoication: Logical Unit | |
975 | */ | |
976 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_logical_unit, 0x00); | |
977 | ||
978 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_logical_unit( | |
979 | struct t10_wwn *t10_wwn, | |
980 | const char *page, | |
981 | size_t count) | |
982 | { | |
983 | return -ENOSYS; | |
984 | } | |
985 | ||
986 | SE_DEV_WWN_ATTR(vpd_assoc_logical_unit, S_IRUGO | S_IWUSR); | |
987 | ||
988 | /* | |
989 | * VPD page 0x83 Association: Target Port | |
990 | */ | |
991 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10); | |
992 | ||
993 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_target_port( | |
994 | struct t10_wwn *t10_wwn, | |
995 | const char *page, | |
996 | size_t count) | |
997 | { | |
998 | return -ENOSYS; | |
999 | } | |
1000 | ||
1001 | SE_DEV_WWN_ATTR(vpd_assoc_target_port, S_IRUGO | S_IWUSR); | |
1002 | ||
1003 | /* | |
1004 | * VPD page 0x83 Association: SCSI Target Device | |
1005 | */ | |
1006 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20); | |
1007 | ||
1008 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_scsi_target_device( | |
1009 | struct t10_wwn *t10_wwn, | |
1010 | const char *page, | |
1011 | size_t count) | |
1012 | { | |
1013 | return -ENOSYS; | |
1014 | } | |
1015 | ||
1016 | SE_DEV_WWN_ATTR(vpd_assoc_scsi_target_device, S_IRUGO | S_IWUSR); | |
1017 | ||
1018 | CONFIGFS_EATTR_OPS(target_core_dev_wwn, t10_wwn, t10_wwn_group); | |
1019 | ||
1020 | static struct configfs_attribute *target_core_dev_wwn_attrs[] = { | |
1021 | &target_core_dev_wwn_vpd_unit_serial.attr, | |
1022 | &target_core_dev_wwn_vpd_protocol_identifier.attr, | |
1023 | &target_core_dev_wwn_vpd_assoc_logical_unit.attr, | |
1024 | &target_core_dev_wwn_vpd_assoc_target_port.attr, | |
1025 | &target_core_dev_wwn_vpd_assoc_scsi_target_device.attr, | |
1026 | NULL, | |
1027 | }; | |
1028 | ||
1029 | static struct configfs_item_operations target_core_dev_wwn_ops = { | |
1030 | .show_attribute = target_core_dev_wwn_attr_show, | |
1031 | .store_attribute = target_core_dev_wwn_attr_store, | |
1032 | }; | |
1033 | ||
1034 | static struct config_item_type target_core_dev_wwn_cit = { | |
1035 | .ct_item_ops = &target_core_dev_wwn_ops, | |
1036 | .ct_attrs = target_core_dev_wwn_attrs, | |
1037 | .ct_owner = THIS_MODULE, | |
1038 | }; | |
1039 | ||
1040 | /* End functions for struct config_item_type target_core_dev_wwn_cit */ | |
1041 | ||
1042 | /* Start functions for struct config_item_type target_core_dev_pr_cit */ | |
1043 | ||
1044 | CONFIGFS_EATTR_STRUCT(target_core_dev_pr, se_subsystem_dev); | |
1045 | #define SE_DEV_PR_ATTR(_name, _mode) \ | |
1046 | static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ | |
1047 | __CONFIGFS_EATTR(_name, _mode, \ | |
1048 | target_core_dev_pr_show_attr_##_name, \ | |
1049 | target_core_dev_pr_store_attr_##_name); | |
1050 | ||
1051 | #define SE_DEV_PR_ATTR_RO(_name); \ | |
1052 | static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ | |
1053 | __CONFIGFS_EATTR_RO(_name, \ | |
1054 | target_core_dev_pr_show_attr_##_name); | |
1055 | ||
1056 | /* | |
1057 | * res_holder | |
1058 | */ | |
1059 | static ssize_t target_core_dev_pr_show_spc3_res( | |
1060 | struct se_device *dev, | |
1061 | char *page, | |
1062 | ssize_t *len) | |
1063 | { | |
1064 | struct se_node_acl *se_nacl; | |
1065 | struct t10_pr_registration *pr_reg; | |
1066 | char i_buf[PR_REG_ISID_ID_LEN]; | |
1067 | int prf_isid; | |
1068 | ||
1069 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); | |
1070 | ||
1071 | spin_lock(&dev->dev_reservation_lock); | |
1072 | pr_reg = dev->dev_pr_res_holder; | |
6708bb27 | 1073 | if (!pr_reg) { |
c66ac9db NB |
1074 | *len += sprintf(page + *len, "No SPC-3 Reservation holder\n"); |
1075 | spin_unlock(&dev->dev_reservation_lock); | |
1076 | return *len; | |
1077 | } | |
1078 | se_nacl = pr_reg->pr_reg_nacl; | |
1079 | prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], | |
1080 | PR_REG_ISID_ID_LEN); | |
1081 | ||
1082 | *len += sprintf(page + *len, "SPC-3 Reservation: %s Initiator: %s%s\n", | |
e3d6f909 | 1083 | se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), |
c66ac9db NB |
1084 | se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : ""); |
1085 | spin_unlock(&dev->dev_reservation_lock); | |
1086 | ||
1087 | return *len; | |
1088 | } | |
1089 | ||
1090 | static ssize_t target_core_dev_pr_show_spc2_res( | |
1091 | struct se_device *dev, | |
1092 | char *page, | |
1093 | ssize_t *len) | |
1094 | { | |
1095 | struct se_node_acl *se_nacl; | |
1096 | ||
1097 | spin_lock(&dev->dev_reservation_lock); | |
1098 | se_nacl = dev->dev_reserved_node_acl; | |
6708bb27 | 1099 | if (!se_nacl) { |
c66ac9db NB |
1100 | *len += sprintf(page + *len, "No SPC-2 Reservation holder\n"); |
1101 | spin_unlock(&dev->dev_reservation_lock); | |
1102 | return *len; | |
1103 | } | |
1104 | *len += sprintf(page + *len, "SPC-2 Reservation: %s Initiator: %s\n", | |
e3d6f909 | 1105 | se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), |
c66ac9db NB |
1106 | se_nacl->initiatorname); |
1107 | spin_unlock(&dev->dev_reservation_lock); | |
1108 | ||
1109 | return *len; | |
1110 | } | |
1111 | ||
1112 | static ssize_t target_core_dev_pr_show_attr_res_holder( | |
1113 | struct se_subsystem_dev *su_dev, | |
1114 | char *page) | |
1115 | { | |
1116 | ssize_t len = 0; | |
1117 | ||
6708bb27 | 1118 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1119 | return -ENODEV; |
1120 | ||
e3d6f909 | 1121 | switch (su_dev->t10_pr.res_type) { |
c66ac9db NB |
1122 | case SPC3_PERSISTENT_RESERVATIONS: |
1123 | target_core_dev_pr_show_spc3_res(su_dev->se_dev_ptr, | |
1124 | page, &len); | |
1125 | break; | |
1126 | case SPC2_RESERVATIONS: | |
1127 | target_core_dev_pr_show_spc2_res(su_dev->se_dev_ptr, | |
1128 | page, &len); | |
1129 | break; | |
1130 | case SPC_PASSTHROUGH: | |
1131 | len += sprintf(page+len, "Passthrough\n"); | |
1132 | break; | |
1133 | default: | |
1134 | len += sprintf(page+len, "Unknown\n"); | |
1135 | break; | |
1136 | } | |
1137 | ||
1138 | return len; | |
1139 | } | |
1140 | ||
1141 | SE_DEV_PR_ATTR_RO(res_holder); | |
1142 | ||
1143 | /* | |
1144 | * res_pr_all_tgt_pts | |
1145 | */ | |
1146 | static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts( | |
1147 | struct se_subsystem_dev *su_dev, | |
1148 | char *page) | |
1149 | { | |
1150 | struct se_device *dev; | |
1151 | struct t10_pr_registration *pr_reg; | |
1152 | ssize_t len = 0; | |
1153 | ||
1154 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1155 | if (!dev) |
c66ac9db NB |
1156 | return -ENODEV; |
1157 | ||
e3d6f909 | 1158 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1159 | return len; |
1160 | ||
1161 | spin_lock(&dev->dev_reservation_lock); | |
1162 | pr_reg = dev->dev_pr_res_holder; | |
6708bb27 | 1163 | if (!pr_reg) { |
c66ac9db NB |
1164 | len = sprintf(page, "No SPC-3 Reservation holder\n"); |
1165 | spin_unlock(&dev->dev_reservation_lock); | |
1166 | return len; | |
1167 | } | |
1168 | /* | |
1169 | * See All Target Ports (ALL_TG_PT) bit in spcr17, section 6.14.3 | |
1170 | * Basic PERSISTENT RESERVER OUT parameter list, page 290 | |
1171 | */ | |
1172 | if (pr_reg->pr_reg_all_tg_pt) | |
1173 | len = sprintf(page, "SPC-3 Reservation: All Target" | |
1174 | " Ports registration\n"); | |
1175 | else | |
1176 | len = sprintf(page, "SPC-3 Reservation: Single" | |
1177 | " Target Port registration\n"); | |
1178 | spin_unlock(&dev->dev_reservation_lock); | |
1179 | ||
1180 | return len; | |
1181 | } | |
1182 | ||
1183 | SE_DEV_PR_ATTR_RO(res_pr_all_tgt_pts); | |
1184 | ||
1185 | /* | |
1186 | * res_pr_generation | |
1187 | */ | |
1188 | static ssize_t target_core_dev_pr_show_attr_res_pr_generation( | |
1189 | struct se_subsystem_dev *su_dev, | |
1190 | char *page) | |
1191 | { | |
6708bb27 | 1192 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1193 | return -ENODEV; |
1194 | ||
e3d6f909 | 1195 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1196 | return 0; |
1197 | ||
e3d6f909 | 1198 | return sprintf(page, "0x%08x\n", su_dev->t10_pr.pr_generation); |
c66ac9db NB |
1199 | } |
1200 | ||
1201 | SE_DEV_PR_ATTR_RO(res_pr_generation); | |
1202 | ||
1203 | /* | |
1204 | * res_pr_holder_tg_port | |
1205 | */ | |
1206 | static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( | |
1207 | struct se_subsystem_dev *su_dev, | |
1208 | char *page) | |
1209 | { | |
1210 | struct se_device *dev; | |
1211 | struct se_node_acl *se_nacl; | |
1212 | struct se_lun *lun; | |
1213 | struct se_portal_group *se_tpg; | |
1214 | struct t10_pr_registration *pr_reg; | |
1215 | struct target_core_fabric_ops *tfo; | |
1216 | ssize_t len = 0; | |
1217 | ||
1218 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1219 | if (!dev) |
c66ac9db NB |
1220 | return -ENODEV; |
1221 | ||
e3d6f909 | 1222 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1223 | return len; |
1224 | ||
1225 | spin_lock(&dev->dev_reservation_lock); | |
1226 | pr_reg = dev->dev_pr_res_holder; | |
6708bb27 | 1227 | if (!pr_reg) { |
c66ac9db NB |
1228 | len = sprintf(page, "No SPC-3 Reservation holder\n"); |
1229 | spin_unlock(&dev->dev_reservation_lock); | |
1230 | return len; | |
1231 | } | |
1232 | se_nacl = pr_reg->pr_reg_nacl; | |
1233 | se_tpg = se_nacl->se_tpg; | |
1234 | lun = pr_reg->pr_reg_tg_pt_lun; | |
e3d6f909 | 1235 | tfo = se_tpg->se_tpg_tfo; |
c66ac9db NB |
1236 | |
1237 | len += sprintf(page+len, "SPC-3 Reservation: %s" | |
1238 | " Target Node Endpoint: %s\n", tfo->get_fabric_name(), | |
1239 | tfo->tpg_get_wwn(se_tpg)); | |
1240 | len += sprintf(page+len, "SPC-3 Reservation: Relative Port" | |
1241 | " Identifer Tag: %hu %s Portal Group Tag: %hu" | |
1242 | " %s Logical Unit: %u\n", lun->lun_sep->sep_rtpi, | |
1243 | tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg), | |
1244 | tfo->get_fabric_name(), lun->unpacked_lun); | |
1245 | spin_unlock(&dev->dev_reservation_lock); | |
1246 | ||
1247 | return len; | |
1248 | } | |
1249 | ||
1250 | SE_DEV_PR_ATTR_RO(res_pr_holder_tg_port); | |
1251 | ||
1252 | /* | |
1253 | * res_pr_registered_i_pts | |
1254 | */ | |
1255 | static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( | |
1256 | struct se_subsystem_dev *su_dev, | |
1257 | char *page) | |
1258 | { | |
1259 | struct target_core_fabric_ops *tfo; | |
1260 | struct t10_pr_registration *pr_reg; | |
1261 | unsigned char buf[384]; | |
1262 | char i_buf[PR_REG_ISID_ID_LEN]; | |
1263 | ssize_t len = 0; | |
1264 | int reg_count = 0, prf_isid; | |
1265 | ||
6708bb27 | 1266 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1267 | return -ENODEV; |
1268 | ||
e3d6f909 | 1269 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1270 | return len; |
1271 | ||
1272 | len += sprintf(page+len, "SPC-3 PR Registrations:\n"); | |
1273 | ||
e3d6f909 AG |
1274 | spin_lock(&su_dev->t10_pr.registration_lock); |
1275 | list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list, | |
c66ac9db NB |
1276 | pr_reg_list) { |
1277 | ||
1278 | memset(buf, 0, 384); | |
1279 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); | |
1280 | tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; | |
1281 | prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], | |
1282 | PR_REG_ISID_ID_LEN); | |
1283 | sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n", | |
1284 | tfo->get_fabric_name(), | |
1285 | pr_reg->pr_reg_nacl->initiatorname, (prf_isid) ? | |
1286 | &i_buf[0] : "", pr_reg->pr_res_key, | |
1287 | pr_reg->pr_res_generation); | |
1288 | ||
6708bb27 | 1289 | if (len + strlen(buf) >= PAGE_SIZE) |
c66ac9db NB |
1290 | break; |
1291 | ||
1292 | len += sprintf(page+len, "%s", buf); | |
1293 | reg_count++; | |
1294 | } | |
e3d6f909 | 1295 | spin_unlock(&su_dev->t10_pr.registration_lock); |
c66ac9db | 1296 | |
6708bb27 | 1297 | if (!reg_count) |
c66ac9db NB |
1298 | len += sprintf(page+len, "None\n"); |
1299 | ||
1300 | return len; | |
1301 | } | |
1302 | ||
1303 | SE_DEV_PR_ATTR_RO(res_pr_registered_i_pts); | |
1304 | ||
1305 | /* | |
1306 | * res_pr_type | |
1307 | */ | |
1308 | static ssize_t target_core_dev_pr_show_attr_res_pr_type( | |
1309 | struct se_subsystem_dev *su_dev, | |
1310 | char *page) | |
1311 | { | |
1312 | struct se_device *dev; | |
1313 | struct t10_pr_registration *pr_reg; | |
1314 | ssize_t len = 0; | |
1315 | ||
1316 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1317 | if (!dev) |
c66ac9db NB |
1318 | return -ENODEV; |
1319 | ||
e3d6f909 | 1320 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1321 | return len; |
1322 | ||
1323 | spin_lock(&dev->dev_reservation_lock); | |
1324 | pr_reg = dev->dev_pr_res_holder; | |
6708bb27 | 1325 | if (!pr_reg) { |
c66ac9db NB |
1326 | len = sprintf(page, "No SPC-3 Reservation holder\n"); |
1327 | spin_unlock(&dev->dev_reservation_lock); | |
1328 | return len; | |
1329 | } | |
1330 | len = sprintf(page, "SPC-3 Reservation Type: %s\n", | |
1331 | core_scsi3_pr_dump_type(pr_reg->pr_res_type)); | |
1332 | spin_unlock(&dev->dev_reservation_lock); | |
1333 | ||
1334 | return len; | |
1335 | } | |
1336 | ||
1337 | SE_DEV_PR_ATTR_RO(res_pr_type); | |
1338 | ||
1339 | /* | |
1340 | * res_type | |
1341 | */ | |
1342 | static ssize_t target_core_dev_pr_show_attr_res_type( | |
1343 | struct se_subsystem_dev *su_dev, | |
1344 | char *page) | |
1345 | { | |
1346 | ssize_t len = 0; | |
1347 | ||
6708bb27 | 1348 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1349 | return -ENODEV; |
1350 | ||
e3d6f909 | 1351 | switch (su_dev->t10_pr.res_type) { |
c66ac9db NB |
1352 | case SPC3_PERSISTENT_RESERVATIONS: |
1353 | len = sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n"); | |
1354 | break; | |
1355 | case SPC2_RESERVATIONS: | |
1356 | len = sprintf(page, "SPC2_RESERVATIONS\n"); | |
1357 | break; | |
1358 | case SPC_PASSTHROUGH: | |
1359 | len = sprintf(page, "SPC_PASSTHROUGH\n"); | |
1360 | break; | |
1361 | default: | |
1362 | len = sprintf(page, "UNKNOWN\n"); | |
1363 | break; | |
1364 | } | |
1365 | ||
1366 | return len; | |
1367 | } | |
1368 | ||
1369 | SE_DEV_PR_ATTR_RO(res_type); | |
1370 | ||
1371 | /* | |
1372 | * res_aptpl_active | |
1373 | */ | |
1374 | ||
1375 | static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( | |
1376 | struct se_subsystem_dev *su_dev, | |
1377 | char *page) | |
1378 | { | |
6708bb27 | 1379 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1380 | return -ENODEV; |
1381 | ||
e3d6f909 | 1382 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1383 | return 0; |
1384 | ||
1385 | return sprintf(page, "APTPL Bit Status: %s\n", | |
e3d6f909 | 1386 | (su_dev->t10_pr.pr_aptpl_active) ? "Activated" : "Disabled"); |
c66ac9db NB |
1387 | } |
1388 | ||
1389 | SE_DEV_PR_ATTR_RO(res_aptpl_active); | |
1390 | ||
1391 | /* | |
1392 | * res_aptpl_metadata | |
1393 | */ | |
1394 | static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( | |
1395 | struct se_subsystem_dev *su_dev, | |
1396 | char *page) | |
1397 | { | |
6708bb27 | 1398 | if (!su_dev->se_dev_ptr) |
c66ac9db NB |
1399 | return -ENODEV; |
1400 | ||
e3d6f909 | 1401 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1402 | return 0; |
1403 | ||
1404 | return sprintf(page, "Ready to process PR APTPL metadata..\n"); | |
1405 | } | |
1406 | ||
1407 | enum { | |
1408 | Opt_initiator_fabric, Opt_initiator_node, Opt_initiator_sid, | |
1409 | Opt_sa_res_key, Opt_res_holder, Opt_res_type, Opt_res_scope, | |
1410 | Opt_res_all_tg_pt, Opt_mapped_lun, Opt_target_fabric, | |
1411 | Opt_target_node, Opt_tpgt, Opt_port_rtpi, Opt_target_lun, Opt_err | |
1412 | }; | |
1413 | ||
1414 | static match_table_t tokens = { | |
1415 | {Opt_initiator_fabric, "initiator_fabric=%s"}, | |
1416 | {Opt_initiator_node, "initiator_node=%s"}, | |
1417 | {Opt_initiator_sid, "initiator_sid=%s"}, | |
1418 | {Opt_sa_res_key, "sa_res_key=%s"}, | |
1419 | {Opt_res_holder, "res_holder=%d"}, | |
1420 | {Opt_res_type, "res_type=%d"}, | |
1421 | {Opt_res_scope, "res_scope=%d"}, | |
1422 | {Opt_res_all_tg_pt, "res_all_tg_pt=%d"}, | |
1423 | {Opt_mapped_lun, "mapped_lun=%d"}, | |
1424 | {Opt_target_fabric, "target_fabric=%s"}, | |
1425 | {Opt_target_node, "target_node=%s"}, | |
1426 | {Opt_tpgt, "tpgt=%d"}, | |
1427 | {Opt_port_rtpi, "port_rtpi=%d"}, | |
1428 | {Opt_target_lun, "target_lun=%d"}, | |
1429 | {Opt_err, NULL} | |
1430 | }; | |
1431 | ||
1432 | static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( | |
1433 | struct se_subsystem_dev *su_dev, | |
1434 | const char *page, | |
1435 | size_t count) | |
1436 | { | |
1437 | struct se_device *dev; | |
6d180253 JJ |
1438 | unsigned char *i_fabric = NULL, *i_port = NULL, *isid = NULL; |
1439 | unsigned char *t_fabric = NULL, *t_port = NULL; | |
c66ac9db NB |
1440 | char *orig, *ptr, *arg_p, *opts; |
1441 | substring_t args[MAX_OPT_ARGS]; | |
1442 | unsigned long long tmp_ll; | |
1443 | u64 sa_res_key = 0; | |
1444 | u32 mapped_lun = 0, target_lun = 0; | |
1445 | int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token; | |
1446 | u16 port_rpti = 0, tpgt = 0; | |
1447 | u8 type = 0, scope; | |
1448 | ||
1449 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1450 | if (!dev) |
c66ac9db NB |
1451 | return -ENODEV; |
1452 | ||
e3d6f909 | 1453 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
c66ac9db NB |
1454 | return 0; |
1455 | ||
1456 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { | |
6708bb27 | 1457 | pr_debug("Unable to process APTPL metadata while" |
c66ac9db NB |
1458 | " active fabric exports exist\n"); |
1459 | return -EINVAL; | |
1460 | } | |
1461 | ||
1462 | opts = kstrdup(page, GFP_KERNEL); | |
1463 | if (!opts) | |
1464 | return -ENOMEM; | |
1465 | ||
1466 | orig = opts; | |
1467 | while ((ptr = strsep(&opts, ",")) != NULL) { | |
1468 | if (!*ptr) | |
1469 | continue; | |
1470 | ||
1471 | token = match_token(ptr, tokens, args); | |
1472 | switch (token) { | |
1473 | case Opt_initiator_fabric: | |
1474 | i_fabric = match_strdup(&args[0]); | |
6d180253 JJ |
1475 | if (!i_fabric) { |
1476 | ret = -ENOMEM; | |
1477 | goto out; | |
1478 | } | |
c66ac9db NB |
1479 | break; |
1480 | case Opt_initiator_node: | |
1481 | i_port = match_strdup(&args[0]); | |
6d180253 JJ |
1482 | if (!i_port) { |
1483 | ret = -ENOMEM; | |
1484 | goto out; | |
1485 | } | |
60d645a4 | 1486 | if (strlen(i_port) >= PR_APTPL_MAX_IPORT_LEN) { |
6708bb27 | 1487 | pr_err("APTPL metadata initiator_node=" |
c66ac9db NB |
1488 | " exceeds PR_APTPL_MAX_IPORT_LEN: %d\n", |
1489 | PR_APTPL_MAX_IPORT_LEN); | |
1490 | ret = -EINVAL; | |
1491 | break; | |
1492 | } | |
1493 | break; | |
1494 | case Opt_initiator_sid: | |
1495 | isid = match_strdup(&args[0]); | |
6d180253 JJ |
1496 | if (!isid) { |
1497 | ret = -ENOMEM; | |
1498 | goto out; | |
1499 | } | |
60d645a4 | 1500 | if (strlen(isid) >= PR_REG_ISID_LEN) { |
6708bb27 | 1501 | pr_err("APTPL metadata initiator_isid" |
c66ac9db NB |
1502 | "= exceeds PR_REG_ISID_LEN: %d\n", |
1503 | PR_REG_ISID_LEN); | |
1504 | ret = -EINVAL; | |
1505 | break; | |
1506 | } | |
1507 | break; | |
1508 | case Opt_sa_res_key: | |
1509 | arg_p = match_strdup(&args[0]); | |
6d180253 JJ |
1510 | if (!arg_p) { |
1511 | ret = -ENOMEM; | |
1512 | goto out; | |
1513 | } | |
c66ac9db NB |
1514 | ret = strict_strtoull(arg_p, 0, &tmp_ll); |
1515 | if (ret < 0) { | |
6708bb27 | 1516 | pr_err("strict_strtoull() failed for" |
c66ac9db NB |
1517 | " sa_res_key=\n"); |
1518 | goto out; | |
1519 | } | |
1520 | sa_res_key = (u64)tmp_ll; | |
1521 | break; | |
1522 | /* | |
1523 | * PR APTPL Metadata for Reservation | |
1524 | */ | |
1525 | case Opt_res_holder: | |
1526 | match_int(args, &arg); | |
1527 | res_holder = arg; | |
1528 | break; | |
1529 | case Opt_res_type: | |
1530 | match_int(args, &arg); | |
1531 | type = (u8)arg; | |
1532 | break; | |
1533 | case Opt_res_scope: | |
1534 | match_int(args, &arg); | |
1535 | scope = (u8)arg; | |
1536 | break; | |
1537 | case Opt_res_all_tg_pt: | |
1538 | match_int(args, &arg); | |
1539 | all_tg_pt = (int)arg; | |
1540 | break; | |
1541 | case Opt_mapped_lun: | |
1542 | match_int(args, &arg); | |
1543 | mapped_lun = (u32)arg; | |
1544 | break; | |
1545 | /* | |
1546 | * PR APTPL Metadata for Target Port | |
1547 | */ | |
1548 | case Opt_target_fabric: | |
1549 | t_fabric = match_strdup(&args[0]); | |
6d180253 JJ |
1550 | if (!t_fabric) { |
1551 | ret = -ENOMEM; | |
1552 | goto out; | |
1553 | } | |
c66ac9db NB |
1554 | break; |
1555 | case Opt_target_node: | |
1556 | t_port = match_strdup(&args[0]); | |
6d180253 JJ |
1557 | if (!t_port) { |
1558 | ret = -ENOMEM; | |
1559 | goto out; | |
1560 | } | |
60d645a4 | 1561 | if (strlen(t_port) >= PR_APTPL_MAX_TPORT_LEN) { |
6708bb27 | 1562 | pr_err("APTPL metadata target_node=" |
c66ac9db NB |
1563 | " exceeds PR_APTPL_MAX_TPORT_LEN: %d\n", |
1564 | PR_APTPL_MAX_TPORT_LEN); | |
1565 | ret = -EINVAL; | |
1566 | break; | |
1567 | } | |
1568 | break; | |
1569 | case Opt_tpgt: | |
1570 | match_int(args, &arg); | |
1571 | tpgt = (u16)arg; | |
1572 | break; | |
1573 | case Opt_port_rtpi: | |
1574 | match_int(args, &arg); | |
1575 | port_rpti = (u16)arg; | |
1576 | break; | |
1577 | case Opt_target_lun: | |
1578 | match_int(args, &arg); | |
1579 | target_lun = (u32)arg; | |
1580 | break; | |
1581 | default: | |
1582 | break; | |
1583 | } | |
1584 | } | |
1585 | ||
6708bb27 AG |
1586 | if (!i_port || !t_port || !sa_res_key) { |
1587 | pr_err("Illegal parameters for APTPL registration\n"); | |
c66ac9db NB |
1588 | ret = -EINVAL; |
1589 | goto out; | |
1590 | } | |
1591 | ||
1592 | if (res_holder && !(type)) { | |
6708bb27 | 1593 | pr_err("Illegal PR type: 0x%02x for reservation" |
c66ac9db NB |
1594 | " holder\n", type); |
1595 | ret = -EINVAL; | |
1596 | goto out; | |
1597 | } | |
1598 | ||
e3d6f909 | 1599 | ret = core_scsi3_alloc_aptpl_registration(&su_dev->t10_pr, sa_res_key, |
c66ac9db NB |
1600 | i_port, isid, mapped_lun, t_port, tpgt, target_lun, |
1601 | res_holder, all_tg_pt, type); | |
1602 | out: | |
6d180253 JJ |
1603 | kfree(i_fabric); |
1604 | kfree(i_port); | |
1605 | kfree(isid); | |
1606 | kfree(t_fabric); | |
1607 | kfree(t_port); | |
c66ac9db NB |
1608 | kfree(orig); |
1609 | return (ret == 0) ? count : ret; | |
1610 | } | |
1611 | ||
1612 | SE_DEV_PR_ATTR(res_aptpl_metadata, S_IRUGO | S_IWUSR); | |
1613 | ||
1614 | CONFIGFS_EATTR_OPS(target_core_dev_pr, se_subsystem_dev, se_dev_pr_group); | |
1615 | ||
1616 | static struct configfs_attribute *target_core_dev_pr_attrs[] = { | |
1617 | &target_core_dev_pr_res_holder.attr, | |
1618 | &target_core_dev_pr_res_pr_all_tgt_pts.attr, | |
1619 | &target_core_dev_pr_res_pr_generation.attr, | |
1620 | &target_core_dev_pr_res_pr_holder_tg_port.attr, | |
1621 | &target_core_dev_pr_res_pr_registered_i_pts.attr, | |
1622 | &target_core_dev_pr_res_pr_type.attr, | |
1623 | &target_core_dev_pr_res_type.attr, | |
1624 | &target_core_dev_pr_res_aptpl_active.attr, | |
1625 | &target_core_dev_pr_res_aptpl_metadata.attr, | |
1626 | NULL, | |
1627 | }; | |
1628 | ||
1629 | static struct configfs_item_operations target_core_dev_pr_ops = { | |
1630 | .show_attribute = target_core_dev_pr_attr_show, | |
1631 | .store_attribute = target_core_dev_pr_attr_store, | |
1632 | }; | |
1633 | ||
1634 | static struct config_item_type target_core_dev_pr_cit = { | |
1635 | .ct_item_ops = &target_core_dev_pr_ops, | |
1636 | .ct_attrs = target_core_dev_pr_attrs, | |
1637 | .ct_owner = THIS_MODULE, | |
1638 | }; | |
1639 | ||
1640 | /* End functions for struct config_item_type target_core_dev_pr_cit */ | |
1641 | ||
1642 | /* Start functions for struct config_item_type target_core_dev_cit */ | |
1643 | ||
1644 | static ssize_t target_core_show_dev_info(void *p, char *page) | |
1645 | { | |
1646 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1647 | struct se_hba *hba = se_dev->se_dev_hba; | |
1648 | struct se_subsystem_api *t = hba->transport; | |
1649 | int bl = 0; | |
1650 | ssize_t read_bytes = 0; | |
1651 | ||
6708bb27 | 1652 | if (!se_dev->se_dev_ptr) |
c66ac9db NB |
1653 | return -ENODEV; |
1654 | ||
1655 | transport_dump_dev_state(se_dev->se_dev_ptr, page, &bl); | |
1656 | read_bytes += bl; | |
1657 | read_bytes += t->show_configfs_dev_params(hba, se_dev, page+read_bytes); | |
1658 | return read_bytes; | |
1659 | } | |
1660 | ||
1661 | static struct target_core_configfs_attribute target_core_attr_dev_info = { | |
1662 | .attr = { .ca_owner = THIS_MODULE, | |
1663 | .ca_name = "info", | |
1664 | .ca_mode = S_IRUGO }, | |
1665 | .show = target_core_show_dev_info, | |
1666 | .store = NULL, | |
1667 | }; | |
1668 | ||
1669 | static ssize_t target_core_store_dev_control( | |
1670 | void *p, | |
1671 | const char *page, | |
1672 | size_t count) | |
1673 | { | |
1674 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1675 | struct se_hba *hba = se_dev->se_dev_hba; | |
1676 | struct se_subsystem_api *t = hba->transport; | |
1677 | ||
6708bb27 AG |
1678 | if (!se_dev->se_dev_su_ptr) { |
1679 | pr_err("Unable to locate struct se_subsystem_dev>se" | |
c66ac9db NB |
1680 | "_dev_su_ptr\n"); |
1681 | return -EINVAL; | |
1682 | } | |
1683 | ||
1684 | return t->set_configfs_dev_params(hba, se_dev, page, count); | |
1685 | } | |
1686 | ||
1687 | static struct target_core_configfs_attribute target_core_attr_dev_control = { | |
1688 | .attr = { .ca_owner = THIS_MODULE, | |
1689 | .ca_name = "control", | |
1690 | .ca_mode = S_IWUSR }, | |
1691 | .show = NULL, | |
1692 | .store = target_core_store_dev_control, | |
1693 | }; | |
1694 | ||
1695 | static ssize_t target_core_show_dev_alias(void *p, char *page) | |
1696 | { | |
1697 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1698 | ||
1699 | if (!(se_dev->su_dev_flags & SDF_USING_ALIAS)) | |
1700 | return 0; | |
1701 | ||
1702 | return snprintf(page, PAGE_SIZE, "%s\n", se_dev->se_dev_alias); | |
1703 | } | |
1704 | ||
1705 | static ssize_t target_core_store_dev_alias( | |
1706 | void *p, | |
1707 | const char *page, | |
1708 | size_t count) | |
1709 | { | |
1710 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1711 | struct se_hba *hba = se_dev->se_dev_hba; | |
1712 | ssize_t read_bytes; | |
1713 | ||
1714 | if (count > (SE_DEV_ALIAS_LEN-1)) { | |
6708bb27 | 1715 | pr_err("alias count: %d exceeds" |
c66ac9db NB |
1716 | " SE_DEV_ALIAS_LEN-1: %u\n", (int)count, |
1717 | SE_DEV_ALIAS_LEN-1); | |
1718 | return -EINVAL; | |
1719 | } | |
1720 | ||
1721 | se_dev->su_dev_flags |= SDF_USING_ALIAS; | |
1722 | read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, | |
1723 | "%s", page); | |
1724 | ||
6708bb27 | 1725 | pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", |
c66ac9db NB |
1726 | config_item_name(&hba->hba_group.cg_item), |
1727 | config_item_name(&se_dev->se_dev_group.cg_item), | |
1728 | se_dev->se_dev_alias); | |
1729 | ||
1730 | return read_bytes; | |
1731 | } | |
1732 | ||
1733 | static struct target_core_configfs_attribute target_core_attr_dev_alias = { | |
1734 | .attr = { .ca_owner = THIS_MODULE, | |
1735 | .ca_name = "alias", | |
1736 | .ca_mode = S_IRUGO | S_IWUSR }, | |
1737 | .show = target_core_show_dev_alias, | |
1738 | .store = target_core_store_dev_alias, | |
1739 | }; | |
1740 | ||
1741 | static ssize_t target_core_show_dev_udev_path(void *p, char *page) | |
1742 | { | |
1743 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1744 | ||
1745 | if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) | |
1746 | return 0; | |
1747 | ||
1748 | return snprintf(page, PAGE_SIZE, "%s\n", se_dev->se_dev_udev_path); | |
1749 | } | |
1750 | ||
1751 | static ssize_t target_core_store_dev_udev_path( | |
1752 | void *p, | |
1753 | const char *page, | |
1754 | size_t count) | |
1755 | { | |
1756 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1757 | struct se_hba *hba = se_dev->se_dev_hba; | |
1758 | ssize_t read_bytes; | |
1759 | ||
1760 | if (count > (SE_UDEV_PATH_LEN-1)) { | |
6708bb27 | 1761 | pr_err("udev_path count: %d exceeds" |
c66ac9db NB |
1762 | " SE_UDEV_PATH_LEN-1: %u\n", (int)count, |
1763 | SE_UDEV_PATH_LEN-1); | |
1764 | return -EINVAL; | |
1765 | } | |
1766 | ||
1767 | se_dev->su_dev_flags |= SDF_USING_UDEV_PATH; | |
1768 | read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, | |
1769 | "%s", page); | |
1770 | ||
6708bb27 | 1771 | pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", |
c66ac9db NB |
1772 | config_item_name(&hba->hba_group.cg_item), |
1773 | config_item_name(&se_dev->se_dev_group.cg_item), | |
1774 | se_dev->se_dev_udev_path); | |
1775 | ||
1776 | return read_bytes; | |
1777 | } | |
1778 | ||
1779 | static struct target_core_configfs_attribute target_core_attr_dev_udev_path = { | |
1780 | .attr = { .ca_owner = THIS_MODULE, | |
1781 | .ca_name = "udev_path", | |
1782 | .ca_mode = S_IRUGO | S_IWUSR }, | |
1783 | .show = target_core_show_dev_udev_path, | |
1784 | .store = target_core_store_dev_udev_path, | |
1785 | }; | |
1786 | ||
1787 | static ssize_t target_core_store_dev_enable( | |
1788 | void *p, | |
1789 | const char *page, | |
1790 | size_t count) | |
1791 | { | |
1792 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | |
1793 | struct se_device *dev; | |
1794 | struct se_hba *hba = se_dev->se_dev_hba; | |
1795 | struct se_subsystem_api *t = hba->transport; | |
1796 | char *ptr; | |
1797 | ||
1798 | ptr = strstr(page, "1"); | |
6708bb27 AG |
1799 | if (!ptr) { |
1800 | pr_err("For dev_enable ops, only valid value" | |
c66ac9db NB |
1801 | " is \"1\"\n"); |
1802 | return -EINVAL; | |
1803 | } | |
6708bb27 AG |
1804 | if (se_dev->se_dev_ptr) { |
1805 | pr_err("se_dev->se_dev_ptr already set for storage" | |
c66ac9db NB |
1806 | " object\n"); |
1807 | return -EEXIST; | |
1808 | } | |
1809 | ||
1810 | if (t->check_configfs_dev_params(hba, se_dev) < 0) | |
1811 | return -EINVAL; | |
1812 | ||
1813 | dev = t->create_virtdevice(hba, se_dev, se_dev->se_dev_su_ptr); | |
613640e4 NB |
1814 | if (IS_ERR(dev)) |
1815 | return PTR_ERR(dev); | |
1816 | else if (!dev) | |
c66ac9db NB |
1817 | return -EINVAL; |
1818 | ||
1819 | se_dev->se_dev_ptr = dev; | |
6708bb27 | 1820 | pr_debug("Target_Core_ConfigFS: Registered se_dev->se_dev_ptr:" |
c66ac9db NB |
1821 | " %p\n", se_dev->se_dev_ptr); |
1822 | ||
1823 | return count; | |
1824 | } | |
1825 | ||
1826 | static struct target_core_configfs_attribute target_core_attr_dev_enable = { | |
1827 | .attr = { .ca_owner = THIS_MODULE, | |
1828 | .ca_name = "enable", | |
1829 | .ca_mode = S_IWUSR }, | |
1830 | .show = NULL, | |
1831 | .store = target_core_store_dev_enable, | |
1832 | }; | |
1833 | ||
1834 | static ssize_t target_core_show_alua_lu_gp(void *p, char *page) | |
1835 | { | |
1836 | struct se_device *dev; | |
1837 | struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; | |
1838 | struct config_item *lu_ci; | |
1839 | struct t10_alua_lu_gp *lu_gp; | |
1840 | struct t10_alua_lu_gp_member *lu_gp_mem; | |
1841 | ssize_t len = 0; | |
1842 | ||
1843 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1844 | if (!dev) |
c66ac9db NB |
1845 | return -ENODEV; |
1846 | ||
e3d6f909 | 1847 | if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) |
c66ac9db NB |
1848 | return len; |
1849 | ||
1850 | lu_gp_mem = dev->dev_alua_lu_gp_mem; | |
6708bb27 AG |
1851 | if (!lu_gp_mem) { |
1852 | pr_err("NULL struct se_device->dev_alua_lu_gp_mem" | |
c66ac9db NB |
1853 | " pointer\n"); |
1854 | return -EINVAL; | |
1855 | } | |
1856 | ||
1857 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); | |
1858 | lu_gp = lu_gp_mem->lu_gp; | |
6708bb27 | 1859 | if (lu_gp) { |
c66ac9db NB |
1860 | lu_ci = &lu_gp->lu_gp_group.cg_item; |
1861 | len += sprintf(page, "LU Group Alias: %s\nLU Group ID: %hu\n", | |
1862 | config_item_name(lu_ci), lu_gp->lu_gp_id); | |
1863 | } | |
1864 | spin_unlock(&lu_gp_mem->lu_gp_mem_lock); | |
1865 | ||
1866 | return len; | |
1867 | } | |
1868 | ||
1869 | static ssize_t target_core_store_alua_lu_gp( | |
1870 | void *p, | |
1871 | const char *page, | |
1872 | size_t count) | |
1873 | { | |
1874 | struct se_device *dev; | |
1875 | struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; | |
1876 | struct se_hba *hba = su_dev->se_dev_hba; | |
1877 | struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; | |
1878 | struct t10_alua_lu_gp_member *lu_gp_mem; | |
1879 | unsigned char buf[LU_GROUP_NAME_BUF]; | |
1880 | int move = 0; | |
1881 | ||
1882 | dev = su_dev->se_dev_ptr; | |
6708bb27 | 1883 | if (!dev) |
c66ac9db NB |
1884 | return -ENODEV; |
1885 | ||
e3d6f909 | 1886 | if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) { |
6708bb27 | 1887 | pr_warn("SPC3_ALUA_EMULATED not enabled for %s/%s\n", |
c66ac9db NB |
1888 | config_item_name(&hba->hba_group.cg_item), |
1889 | config_item_name(&su_dev->se_dev_group.cg_item)); | |
1890 | return -EINVAL; | |
1891 | } | |
1892 | if (count > LU_GROUP_NAME_BUF) { | |
6708bb27 | 1893 | pr_err("ALUA LU Group Alias too large!\n"); |
c66ac9db NB |
1894 | return -EINVAL; |
1895 | } | |
1896 | memset(buf, 0, LU_GROUP_NAME_BUF); | |
1897 | memcpy(buf, page, count); | |
1898 | /* | |
1899 | * Any ALUA logical unit alias besides "NULL" means we will be | |
1900 | * making a new group association. | |
1901 | */ | |
1902 | if (strcmp(strstrip(buf), "NULL")) { | |
1903 | /* | |
1904 | * core_alua_get_lu_gp_by_name() will increment reference to | |
1905 | * struct t10_alua_lu_gp. This reference is released with | |
1906 | * core_alua_get_lu_gp_by_name below(). | |
1907 | */ | |
1908 | lu_gp_new = core_alua_get_lu_gp_by_name(strstrip(buf)); | |
6708bb27 | 1909 | if (!lu_gp_new) |
c66ac9db NB |
1910 | return -ENODEV; |
1911 | } | |
1912 | lu_gp_mem = dev->dev_alua_lu_gp_mem; | |
6708bb27 | 1913 | if (!lu_gp_mem) { |
c66ac9db NB |
1914 | if (lu_gp_new) |
1915 | core_alua_put_lu_gp_from_name(lu_gp_new); | |
6708bb27 | 1916 | pr_err("NULL struct se_device->dev_alua_lu_gp_mem" |
c66ac9db NB |
1917 | " pointer\n"); |
1918 | return -EINVAL; | |
1919 | } | |
1920 | ||
1921 | spin_lock(&lu_gp_mem->lu_gp_mem_lock); | |
1922 | lu_gp = lu_gp_mem->lu_gp; | |
6708bb27 | 1923 | if (lu_gp) { |
c66ac9db NB |
1924 | /* |
1925 | * Clearing an existing lu_gp association, and replacing | |
1926 | * with NULL | |
1927 | */ | |
6708bb27 AG |
1928 | if (!lu_gp_new) { |
1929 | pr_debug("Target_Core_ConfigFS: Releasing %s/%s" | |
c66ac9db NB |
1930 | " from ALUA LU Group: core/alua/lu_gps/%s, ID:" |
1931 | " %hu\n", | |
1932 | config_item_name(&hba->hba_group.cg_item), | |
1933 | config_item_name(&su_dev->se_dev_group.cg_item), | |
1934 | config_item_name(&lu_gp->lu_gp_group.cg_item), | |
1935 | lu_gp->lu_gp_id); | |
1936 | ||
1937 | __core_alua_drop_lu_gp_mem(lu_gp_mem, lu_gp); | |
1938 | spin_unlock(&lu_gp_mem->lu_gp_mem_lock); | |
1939 | ||
1940 | return count; | |
1941 | } | |
1942 | /* | |
1943 | * Removing existing association of lu_gp_mem with lu_gp | |
1944 | */ | |
1945 | __core_alua_drop_lu_gp_mem(lu_gp_mem, lu_gp); | |
1946 | move = 1; | |
1947 | } | |
1948 | /* | |
1949 | * Associate lu_gp_mem with lu_gp_new. | |
1950 | */ | |
1951 | __core_alua_attach_lu_gp_mem(lu_gp_mem, lu_gp_new); | |
1952 | spin_unlock(&lu_gp_mem->lu_gp_mem_lock); | |
1953 | ||
6708bb27 | 1954 | pr_debug("Target_Core_ConfigFS: %s %s/%s to ALUA LU Group:" |
c66ac9db NB |
1955 | " core/alua/lu_gps/%s, ID: %hu\n", |
1956 | (move) ? "Moving" : "Adding", | |
1957 | config_item_name(&hba->hba_group.cg_item), | |
1958 | config_item_name(&su_dev->se_dev_group.cg_item), | |
1959 | config_item_name(&lu_gp_new->lu_gp_group.cg_item), | |
1960 | lu_gp_new->lu_gp_id); | |
1961 | ||
1962 | core_alua_put_lu_gp_from_name(lu_gp_new); | |
1963 | return count; | |
1964 | } | |
1965 | ||
1966 | static struct target_core_configfs_attribute target_core_attr_dev_alua_lu_gp = { | |
1967 | .attr = { .ca_owner = THIS_MODULE, | |
1968 | .ca_name = "alua_lu_gp", | |
1969 | .ca_mode = S_IRUGO | S_IWUSR }, | |
1970 | .show = target_core_show_alua_lu_gp, | |
1971 | .store = target_core_store_alua_lu_gp, | |
1972 | }; | |
1973 | ||
1974 | static struct configfs_attribute *lio_core_dev_attrs[] = { | |
1975 | &target_core_attr_dev_info.attr, | |
1976 | &target_core_attr_dev_control.attr, | |
1977 | &target_core_attr_dev_alias.attr, | |
1978 | &target_core_attr_dev_udev_path.attr, | |
1979 | &target_core_attr_dev_enable.attr, | |
1980 | &target_core_attr_dev_alua_lu_gp.attr, | |
1981 | NULL, | |
1982 | }; | |
1983 | ||
1984 | static void target_core_dev_release(struct config_item *item) | |
1985 | { | |
1986 | struct se_subsystem_dev *se_dev = container_of(to_config_group(item), | |
1987 | struct se_subsystem_dev, se_dev_group); | |
1f6fe7cb NB |
1988 | struct se_hba *hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item); |
1989 | struct se_subsystem_api *t = hba->transport; | |
1990 | struct config_group *dev_cg = &se_dev->se_dev_group; | |
c66ac9db | 1991 | |
c66ac9db | 1992 | kfree(dev_cg->default_groups); |
1f6fe7cb NB |
1993 | /* |
1994 | * This pointer will set when the storage is enabled with: | |
1995 | *`echo 1 > $CONFIGFS/core/$HBA/$DEV/dev_enable` | |
1996 | */ | |
1997 | if (se_dev->se_dev_ptr) { | |
6708bb27 | 1998 | pr_debug("Target_Core_ConfigFS: Calling se_free_" |
1f6fe7cb NB |
1999 | "virtual_device() for se_dev_ptr: %p\n", |
2000 | se_dev->se_dev_ptr); | |
2001 | ||
2002 | se_free_virtual_device(se_dev->se_dev_ptr, hba); | |
2003 | } else { | |
2004 | /* | |
2005 | * Release struct se_subsystem_dev->se_dev_su_ptr.. | |
2006 | */ | |
6708bb27 | 2007 | pr_debug("Target_Core_ConfigFS: Calling t->free_" |
1f6fe7cb NB |
2008 | "device() for se_dev_su_ptr: %p\n", |
2009 | se_dev->se_dev_su_ptr); | |
2010 | ||
2011 | t->free_device(se_dev->se_dev_su_ptr); | |
2012 | } | |
2013 | ||
6708bb27 | 2014 | pr_debug("Target_Core_ConfigFS: Deallocating se_subsystem" |
1f6fe7cb NB |
2015 | "_dev_t: %p\n", se_dev); |
2016 | kfree(se_dev); | |
c66ac9db NB |
2017 | } |
2018 | ||
2019 | static ssize_t target_core_dev_show(struct config_item *item, | |
2020 | struct configfs_attribute *attr, | |
2021 | char *page) | |
2022 | { | |
2023 | struct se_subsystem_dev *se_dev = container_of( | |
2024 | to_config_group(item), struct se_subsystem_dev, | |
2025 | se_dev_group); | |
2026 | struct target_core_configfs_attribute *tc_attr = container_of( | |
2027 | attr, struct target_core_configfs_attribute, attr); | |
2028 | ||
6708bb27 | 2029 | if (!tc_attr->show) |
c66ac9db NB |
2030 | return -EINVAL; |
2031 | ||
5951146d | 2032 | return tc_attr->show(se_dev, page); |
c66ac9db NB |
2033 | } |
2034 | ||
2035 | static ssize_t target_core_dev_store(struct config_item *item, | |
2036 | struct configfs_attribute *attr, | |
2037 | const char *page, size_t count) | |
2038 | { | |
2039 | struct se_subsystem_dev *se_dev = container_of( | |
2040 | to_config_group(item), struct se_subsystem_dev, | |
2041 | se_dev_group); | |
2042 | struct target_core_configfs_attribute *tc_attr = container_of( | |
2043 | attr, struct target_core_configfs_attribute, attr); | |
2044 | ||
6708bb27 | 2045 | if (!tc_attr->store) |
c66ac9db NB |
2046 | return -EINVAL; |
2047 | ||
5951146d | 2048 | return tc_attr->store(se_dev, page, count); |
c66ac9db NB |
2049 | } |
2050 | ||
2051 | static struct configfs_item_operations target_core_dev_item_ops = { | |
2052 | .release = target_core_dev_release, | |
2053 | .show_attribute = target_core_dev_show, | |
2054 | .store_attribute = target_core_dev_store, | |
2055 | }; | |
2056 | ||
2057 | static struct config_item_type target_core_dev_cit = { | |
2058 | .ct_item_ops = &target_core_dev_item_ops, | |
2059 | .ct_attrs = lio_core_dev_attrs, | |
2060 | .ct_owner = THIS_MODULE, | |
2061 | }; | |
2062 | ||
2063 | /* End functions for struct config_item_type target_core_dev_cit */ | |
2064 | ||
2065 | /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */ | |
2066 | ||
2067 | CONFIGFS_EATTR_STRUCT(target_core_alua_lu_gp, t10_alua_lu_gp); | |
2068 | #define SE_DEV_ALUA_LU_ATTR(_name, _mode) \ | |
2069 | static struct target_core_alua_lu_gp_attribute \ | |
2070 | target_core_alua_lu_gp_##_name = \ | |
2071 | __CONFIGFS_EATTR(_name, _mode, \ | |
2072 | target_core_alua_lu_gp_show_attr_##_name, \ | |
2073 | target_core_alua_lu_gp_store_attr_##_name); | |
2074 | ||
2075 | #define SE_DEV_ALUA_LU_ATTR_RO(_name) \ | |
2076 | static struct target_core_alua_lu_gp_attribute \ | |
2077 | target_core_alua_lu_gp_##_name = \ | |
2078 | __CONFIGFS_EATTR_RO(_name, \ | |
2079 | target_core_alua_lu_gp_show_attr_##_name); | |
2080 | ||
2081 | /* | |
2082 | * lu_gp_id | |
2083 | */ | |
2084 | static ssize_t target_core_alua_lu_gp_show_attr_lu_gp_id( | |
2085 | struct t10_alua_lu_gp *lu_gp, | |
2086 | char *page) | |
2087 | { | |
6708bb27 | 2088 | if (!lu_gp->lu_gp_valid_id) |
c66ac9db NB |
2089 | return 0; |
2090 | ||
2091 | return sprintf(page, "%hu\n", lu_gp->lu_gp_id); | |
2092 | } | |
2093 | ||
2094 | static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id( | |
2095 | struct t10_alua_lu_gp *lu_gp, | |
2096 | const char *page, | |
2097 | size_t count) | |
2098 | { | |
2099 | struct config_group *alua_lu_gp_cg = &lu_gp->lu_gp_group; | |
2100 | unsigned long lu_gp_id; | |
2101 | int ret; | |
2102 | ||
2103 | ret = strict_strtoul(page, 0, &lu_gp_id); | |
2104 | if (ret < 0) { | |
6708bb27 | 2105 | pr_err("strict_strtoul() returned %d for" |
c66ac9db NB |
2106 | " lu_gp_id\n", ret); |
2107 | return -EINVAL; | |
2108 | } | |
2109 | if (lu_gp_id > 0x0000ffff) { | |
6708bb27 | 2110 | pr_err("ALUA lu_gp_id: %lu exceeds maximum:" |
c66ac9db NB |
2111 | " 0x0000ffff\n", lu_gp_id); |
2112 | return -EINVAL; | |
2113 | } | |
2114 | ||
2115 | ret = core_alua_set_lu_gp_id(lu_gp, (u16)lu_gp_id); | |
2116 | if (ret < 0) | |
2117 | return -EINVAL; | |
2118 | ||
6708bb27 | 2119 | pr_debug("Target_Core_ConfigFS: Set ALUA Logical Unit" |
c66ac9db NB |
2120 | " Group: core/alua/lu_gps/%s to ID: %hu\n", |
2121 | config_item_name(&alua_lu_gp_cg->cg_item), | |
2122 | lu_gp->lu_gp_id); | |
2123 | ||
2124 | return count; | |
2125 | } | |
2126 | ||
2127 | SE_DEV_ALUA_LU_ATTR(lu_gp_id, S_IRUGO | S_IWUSR); | |
2128 | ||
2129 | /* | |
2130 | * members | |
2131 | */ | |
2132 | static ssize_t target_core_alua_lu_gp_show_attr_members( | |
2133 | struct t10_alua_lu_gp *lu_gp, | |
2134 | char *page) | |
2135 | { | |
2136 | struct se_device *dev; | |
2137 | struct se_hba *hba; | |
2138 | struct se_subsystem_dev *su_dev; | |
2139 | struct t10_alua_lu_gp_member *lu_gp_mem; | |
2140 | ssize_t len = 0, cur_len; | |
2141 | unsigned char buf[LU_GROUP_NAME_BUF]; | |
2142 | ||
2143 | memset(buf, 0, LU_GROUP_NAME_BUF); | |
2144 | ||
2145 | spin_lock(&lu_gp->lu_gp_lock); | |
2146 | list_for_each_entry(lu_gp_mem, &lu_gp->lu_gp_mem_list, lu_gp_mem_list) { | |
2147 | dev = lu_gp_mem->lu_gp_mem_dev; | |
2148 | su_dev = dev->se_sub_dev; | |
2149 | hba = su_dev->se_dev_hba; | |
2150 | ||
2151 | cur_len = snprintf(buf, LU_GROUP_NAME_BUF, "%s/%s\n", | |
2152 | config_item_name(&hba->hba_group.cg_item), | |
2153 | config_item_name(&su_dev->se_dev_group.cg_item)); | |
2154 | cur_len++; /* Extra byte for NULL terminator */ | |
2155 | ||
2156 | if ((cur_len + len) > PAGE_SIZE) { | |
6708bb27 | 2157 | pr_warn("Ran out of lu_gp_show_attr" |
c66ac9db NB |
2158 | "_members buffer\n"); |
2159 | break; | |
2160 | } | |
2161 | memcpy(page+len, buf, cur_len); | |
2162 | len += cur_len; | |
2163 | } | |
2164 | spin_unlock(&lu_gp->lu_gp_lock); | |
2165 | ||
2166 | return len; | |
2167 | } | |
2168 | ||
2169 | SE_DEV_ALUA_LU_ATTR_RO(members); | |
2170 | ||
2171 | CONFIGFS_EATTR_OPS(target_core_alua_lu_gp, t10_alua_lu_gp, lu_gp_group); | |
2172 | ||
2173 | static struct configfs_attribute *target_core_alua_lu_gp_attrs[] = { | |
2174 | &target_core_alua_lu_gp_lu_gp_id.attr, | |
2175 | &target_core_alua_lu_gp_members.attr, | |
2176 | NULL, | |
2177 | }; | |
2178 | ||
1f6fe7cb NB |
2179 | static void target_core_alua_lu_gp_release(struct config_item *item) |
2180 | { | |
2181 | struct t10_alua_lu_gp *lu_gp = container_of(to_config_group(item), | |
2182 | struct t10_alua_lu_gp, lu_gp_group); | |
2183 | ||
2184 | core_alua_free_lu_gp(lu_gp); | |
2185 | } | |
2186 | ||
c66ac9db | 2187 | static struct configfs_item_operations target_core_alua_lu_gp_ops = { |
1f6fe7cb | 2188 | .release = target_core_alua_lu_gp_release, |
c66ac9db NB |
2189 | .show_attribute = target_core_alua_lu_gp_attr_show, |
2190 | .store_attribute = target_core_alua_lu_gp_attr_store, | |
2191 | }; | |
2192 | ||
2193 | static struct config_item_type target_core_alua_lu_gp_cit = { | |
2194 | .ct_item_ops = &target_core_alua_lu_gp_ops, | |
2195 | .ct_attrs = target_core_alua_lu_gp_attrs, | |
2196 | .ct_owner = THIS_MODULE, | |
2197 | }; | |
2198 | ||
2199 | /* End functions for struct config_item_type target_core_alua_lu_gp_cit */ | |
2200 | ||
2201 | /* Start functions for struct config_item_type target_core_alua_lu_gps_cit */ | |
2202 | ||
2203 | static struct config_group *target_core_alua_create_lu_gp( | |
2204 | struct config_group *group, | |
2205 | const char *name) | |
2206 | { | |
2207 | struct t10_alua_lu_gp *lu_gp; | |
2208 | struct config_group *alua_lu_gp_cg = NULL; | |
2209 | struct config_item *alua_lu_gp_ci = NULL; | |
2210 | ||
2211 | lu_gp = core_alua_allocate_lu_gp(name, 0); | |
2212 | if (IS_ERR(lu_gp)) | |
2213 | return NULL; | |
2214 | ||
2215 | alua_lu_gp_cg = &lu_gp->lu_gp_group; | |
2216 | alua_lu_gp_ci = &alua_lu_gp_cg->cg_item; | |
2217 | ||
2218 | config_group_init_type_name(alua_lu_gp_cg, name, | |
2219 | &target_core_alua_lu_gp_cit); | |
2220 | ||
6708bb27 | 2221 | pr_debug("Target_Core_ConfigFS: Allocated ALUA Logical Unit" |
c66ac9db NB |
2222 | " Group: core/alua/lu_gps/%s\n", |
2223 | config_item_name(alua_lu_gp_ci)); | |
2224 | ||
2225 | return alua_lu_gp_cg; | |
2226 | ||
2227 | } | |
2228 | ||
2229 | static void target_core_alua_drop_lu_gp( | |
2230 | struct config_group *group, | |
2231 | struct config_item *item) | |
2232 | { | |
2233 | struct t10_alua_lu_gp *lu_gp = container_of(to_config_group(item), | |
2234 | struct t10_alua_lu_gp, lu_gp_group); | |
2235 | ||
6708bb27 | 2236 | pr_debug("Target_Core_ConfigFS: Releasing ALUA Logical Unit" |
c66ac9db NB |
2237 | " Group: core/alua/lu_gps/%s, ID: %hu\n", |
2238 | config_item_name(item), lu_gp->lu_gp_id); | |
1f6fe7cb NB |
2239 | /* |
2240 | * core_alua_free_lu_gp() is called from target_core_alua_lu_gp_ops->release() | |
2241 | * -> target_core_alua_lu_gp_release() | |
2242 | */ | |
c66ac9db | 2243 | config_item_put(item); |
c66ac9db NB |
2244 | } |
2245 | ||
2246 | static struct configfs_group_operations target_core_alua_lu_gps_group_ops = { | |
2247 | .make_group = &target_core_alua_create_lu_gp, | |
2248 | .drop_item = &target_core_alua_drop_lu_gp, | |
2249 | }; | |
2250 | ||
2251 | static struct config_item_type target_core_alua_lu_gps_cit = { | |
2252 | .ct_item_ops = NULL, | |
2253 | .ct_group_ops = &target_core_alua_lu_gps_group_ops, | |
2254 | .ct_owner = THIS_MODULE, | |
2255 | }; | |
2256 | ||
2257 | /* End functions for struct config_item_type target_core_alua_lu_gps_cit */ | |
2258 | ||
2259 | /* Start functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ | |
2260 | ||
2261 | CONFIGFS_EATTR_STRUCT(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp); | |
2262 | #define SE_DEV_ALUA_TG_PT_ATTR(_name, _mode) \ | |
2263 | static struct target_core_alua_tg_pt_gp_attribute \ | |
2264 | target_core_alua_tg_pt_gp_##_name = \ | |
2265 | __CONFIGFS_EATTR(_name, _mode, \ | |
2266 | target_core_alua_tg_pt_gp_show_attr_##_name, \ | |
2267 | target_core_alua_tg_pt_gp_store_attr_##_name); | |
2268 | ||
2269 | #define SE_DEV_ALUA_TG_PT_ATTR_RO(_name) \ | |
2270 | static struct target_core_alua_tg_pt_gp_attribute \ | |
2271 | target_core_alua_tg_pt_gp_##_name = \ | |
2272 | __CONFIGFS_EATTR_RO(_name, \ | |
2273 | target_core_alua_tg_pt_gp_show_attr_##_name); | |
2274 | ||
2275 | /* | |
2276 | * alua_access_state | |
2277 | */ | |
2278 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_state( | |
2279 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2280 | char *page) | |
2281 | { | |
2282 | return sprintf(page, "%d\n", | |
2283 | atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state)); | |
2284 | } | |
2285 | ||
2286 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state( | |
2287 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2288 | const char *page, | |
2289 | size_t count) | |
2290 | { | |
2291 | struct se_subsystem_dev *su_dev = tg_pt_gp->tg_pt_gp_su_dev; | |
2292 | unsigned long tmp; | |
2293 | int new_state, ret; | |
2294 | ||
6708bb27 AG |
2295 | if (!tg_pt_gp->tg_pt_gp_valid_id) { |
2296 | pr_err("Unable to do implict ALUA on non valid" | |
c66ac9db NB |
2297 | " tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id); |
2298 | return -EINVAL; | |
2299 | } | |
2300 | ||
2301 | ret = strict_strtoul(page, 0, &tmp); | |
2302 | if (ret < 0) { | |
6708bb27 | 2303 | pr_err("Unable to extract new ALUA access state from" |
c66ac9db NB |
2304 | " %s\n", page); |
2305 | return -EINVAL; | |
2306 | } | |
2307 | new_state = (int)tmp; | |
2308 | ||
2309 | if (!(tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICT_ALUA)) { | |
6708bb27 | 2310 | pr_err("Unable to process implict configfs ALUA" |
c66ac9db NB |
2311 | " transition while TPGS_IMPLICT_ALUA is diabled\n"); |
2312 | return -EINVAL; | |
2313 | } | |
2314 | ||
2315 | ret = core_alua_do_port_transition(tg_pt_gp, su_dev->se_dev_ptr, | |
2316 | NULL, NULL, new_state, 0); | |
2317 | return (!ret) ? count : -EINVAL; | |
2318 | } | |
2319 | ||
2320 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_state, S_IRUGO | S_IWUSR); | |
2321 | ||
2322 | /* | |
2323 | * alua_access_status | |
2324 | */ | |
2325 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_status( | |
2326 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2327 | char *page) | |
2328 | { | |
2329 | return sprintf(page, "%s\n", | |
2330 | core_alua_dump_status(tg_pt_gp->tg_pt_gp_alua_access_status)); | |
2331 | } | |
2332 | ||
2333 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status( | |
2334 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2335 | const char *page, | |
2336 | size_t count) | |
2337 | { | |
2338 | unsigned long tmp; | |
2339 | int new_status, ret; | |
2340 | ||
6708bb27 AG |
2341 | if (!tg_pt_gp->tg_pt_gp_valid_id) { |
2342 | pr_err("Unable to do set ALUA access status on non" | |
c66ac9db NB |
2343 | " valid tg_pt_gp ID: %hu\n", |
2344 | tg_pt_gp->tg_pt_gp_valid_id); | |
2345 | return -EINVAL; | |
2346 | } | |
2347 | ||
2348 | ret = strict_strtoul(page, 0, &tmp); | |
2349 | if (ret < 0) { | |
6708bb27 | 2350 | pr_err("Unable to extract new ALUA access status" |
c66ac9db NB |
2351 | " from %s\n", page); |
2352 | return -EINVAL; | |
2353 | } | |
2354 | new_status = (int)tmp; | |
2355 | ||
2356 | if ((new_status != ALUA_STATUS_NONE) && | |
2357 | (new_status != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) && | |
2358 | (new_status != ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA)) { | |
6708bb27 | 2359 | pr_err("Illegal ALUA access status: 0x%02x\n", |
c66ac9db NB |
2360 | new_status); |
2361 | return -EINVAL; | |
2362 | } | |
2363 | ||
2364 | tg_pt_gp->tg_pt_gp_alua_access_status = new_status; | |
2365 | return count; | |
2366 | } | |
2367 | ||
2368 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_status, S_IRUGO | S_IWUSR); | |
2369 | ||
2370 | /* | |
2371 | * alua_access_type | |
2372 | */ | |
2373 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_type( | |
2374 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2375 | char *page) | |
2376 | { | |
2377 | return core_alua_show_access_type(tg_pt_gp, page); | |
2378 | } | |
2379 | ||
2380 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_type( | |
2381 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2382 | const char *page, | |
2383 | size_t count) | |
2384 | { | |
2385 | return core_alua_store_access_type(tg_pt_gp, page, count); | |
2386 | } | |
2387 | ||
2388 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_type, S_IRUGO | S_IWUSR); | |
2389 | ||
2390 | /* | |
2391 | * alua_write_metadata | |
2392 | */ | |
2393 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_write_metadata( | |
2394 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2395 | char *page) | |
2396 | { | |
2397 | return sprintf(page, "%d\n", tg_pt_gp->tg_pt_gp_write_metadata); | |
2398 | } | |
2399 | ||
2400 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata( | |
2401 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2402 | const char *page, | |
2403 | size_t count) | |
2404 | { | |
2405 | unsigned long tmp; | |
2406 | int ret; | |
2407 | ||
2408 | ret = strict_strtoul(page, 0, &tmp); | |
2409 | if (ret < 0) { | |
6708bb27 | 2410 | pr_err("Unable to extract alua_write_metadata\n"); |
c66ac9db NB |
2411 | return -EINVAL; |
2412 | } | |
2413 | ||
2414 | if ((tmp != 0) && (tmp != 1)) { | |
6708bb27 | 2415 | pr_err("Illegal value for alua_write_metadata:" |
c66ac9db NB |
2416 | " %lu\n", tmp); |
2417 | return -EINVAL; | |
2418 | } | |
2419 | tg_pt_gp->tg_pt_gp_write_metadata = (int)tmp; | |
2420 | ||
2421 | return count; | |
2422 | } | |
2423 | ||
2424 | SE_DEV_ALUA_TG_PT_ATTR(alua_write_metadata, S_IRUGO | S_IWUSR); | |
2425 | ||
2426 | ||
2427 | ||
2428 | /* | |
2429 | * nonop_delay_msecs | |
2430 | */ | |
2431 | static ssize_t target_core_alua_tg_pt_gp_show_attr_nonop_delay_msecs( | |
2432 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2433 | char *page) | |
2434 | { | |
2435 | return core_alua_show_nonop_delay_msecs(tg_pt_gp, page); | |
2436 | ||
2437 | } | |
2438 | ||
2439 | static ssize_t target_core_alua_tg_pt_gp_store_attr_nonop_delay_msecs( | |
2440 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2441 | const char *page, | |
2442 | size_t count) | |
2443 | { | |
2444 | return core_alua_store_nonop_delay_msecs(tg_pt_gp, page, count); | |
2445 | } | |
2446 | ||
2447 | SE_DEV_ALUA_TG_PT_ATTR(nonop_delay_msecs, S_IRUGO | S_IWUSR); | |
2448 | ||
2449 | /* | |
2450 | * trans_delay_msecs | |
2451 | */ | |
2452 | static ssize_t target_core_alua_tg_pt_gp_show_attr_trans_delay_msecs( | |
2453 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2454 | char *page) | |
2455 | { | |
2456 | return core_alua_show_trans_delay_msecs(tg_pt_gp, page); | |
2457 | } | |
2458 | ||
2459 | static ssize_t target_core_alua_tg_pt_gp_store_attr_trans_delay_msecs( | |
2460 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2461 | const char *page, | |
2462 | size_t count) | |
2463 | { | |
2464 | return core_alua_store_trans_delay_msecs(tg_pt_gp, page, count); | |
2465 | } | |
2466 | ||
2467 | SE_DEV_ALUA_TG_PT_ATTR(trans_delay_msecs, S_IRUGO | S_IWUSR); | |
2468 | ||
2469 | /* | |
2470 | * preferred | |
2471 | */ | |
2472 | ||
2473 | static ssize_t target_core_alua_tg_pt_gp_show_attr_preferred( | |
2474 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2475 | char *page) | |
2476 | { | |
2477 | return core_alua_show_preferred_bit(tg_pt_gp, page); | |
2478 | } | |
2479 | ||
2480 | static ssize_t target_core_alua_tg_pt_gp_store_attr_preferred( | |
2481 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2482 | const char *page, | |
2483 | size_t count) | |
2484 | { | |
2485 | return core_alua_store_preferred_bit(tg_pt_gp, page, count); | |
2486 | } | |
2487 | ||
2488 | SE_DEV_ALUA_TG_PT_ATTR(preferred, S_IRUGO | S_IWUSR); | |
2489 | ||
2490 | /* | |
2491 | * tg_pt_gp_id | |
2492 | */ | |
2493 | static ssize_t target_core_alua_tg_pt_gp_show_attr_tg_pt_gp_id( | |
2494 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2495 | char *page) | |
2496 | { | |
6708bb27 | 2497 | if (!tg_pt_gp->tg_pt_gp_valid_id) |
c66ac9db NB |
2498 | return 0; |
2499 | ||
2500 | return sprintf(page, "%hu\n", tg_pt_gp->tg_pt_gp_id); | |
2501 | } | |
2502 | ||
2503 | static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id( | |
2504 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2505 | const char *page, | |
2506 | size_t count) | |
2507 | { | |
2508 | struct config_group *alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group; | |
2509 | unsigned long tg_pt_gp_id; | |
2510 | int ret; | |
2511 | ||
2512 | ret = strict_strtoul(page, 0, &tg_pt_gp_id); | |
2513 | if (ret < 0) { | |
6708bb27 | 2514 | pr_err("strict_strtoul() returned %d for" |
c66ac9db NB |
2515 | " tg_pt_gp_id\n", ret); |
2516 | return -EINVAL; | |
2517 | } | |
2518 | if (tg_pt_gp_id > 0x0000ffff) { | |
6708bb27 | 2519 | pr_err("ALUA tg_pt_gp_id: %lu exceeds maximum:" |
c66ac9db NB |
2520 | " 0x0000ffff\n", tg_pt_gp_id); |
2521 | return -EINVAL; | |
2522 | } | |
2523 | ||
2524 | ret = core_alua_set_tg_pt_gp_id(tg_pt_gp, (u16)tg_pt_gp_id); | |
2525 | if (ret < 0) | |
2526 | return -EINVAL; | |
2527 | ||
6708bb27 | 2528 | pr_debug("Target_Core_ConfigFS: Set ALUA Target Port Group: " |
c66ac9db NB |
2529 | "core/alua/tg_pt_gps/%s to ID: %hu\n", |
2530 | config_item_name(&alua_tg_pt_gp_cg->cg_item), | |
2531 | tg_pt_gp->tg_pt_gp_id); | |
2532 | ||
2533 | return count; | |
2534 | } | |
2535 | ||
2536 | SE_DEV_ALUA_TG_PT_ATTR(tg_pt_gp_id, S_IRUGO | S_IWUSR); | |
2537 | ||
2538 | /* | |
2539 | * members | |
2540 | */ | |
2541 | static ssize_t target_core_alua_tg_pt_gp_show_attr_members( | |
2542 | struct t10_alua_tg_pt_gp *tg_pt_gp, | |
2543 | char *page) | |
2544 | { | |
2545 | struct se_port *port; | |
2546 | struct se_portal_group *tpg; | |
2547 | struct se_lun *lun; | |
2548 | struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; | |
2549 | ssize_t len = 0, cur_len; | |
2550 | unsigned char buf[TG_PT_GROUP_NAME_BUF]; | |
2551 | ||
2552 | memset(buf, 0, TG_PT_GROUP_NAME_BUF); | |
2553 | ||
2554 | spin_lock(&tg_pt_gp->tg_pt_gp_lock); | |
2555 | list_for_each_entry(tg_pt_gp_mem, &tg_pt_gp->tg_pt_gp_mem_list, | |
2556 | tg_pt_gp_mem_list) { | |
2557 | port = tg_pt_gp_mem->tg_pt; | |
2558 | tpg = port->sep_tpg; | |
2559 | lun = port->sep_lun; | |
2560 | ||
2561 | cur_len = snprintf(buf, TG_PT_GROUP_NAME_BUF, "%s/%s/tpgt_%hu" | |
e3d6f909 AG |
2562 | "/%s\n", tpg->se_tpg_tfo->get_fabric_name(), |
2563 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), | |
2564 | tpg->se_tpg_tfo->tpg_get_tag(tpg), | |
c66ac9db NB |
2565 | config_item_name(&lun->lun_group.cg_item)); |
2566 | cur_len++; /* Extra byte for NULL terminator */ | |
2567 | ||
2568 | if ((cur_len + len) > PAGE_SIZE) { | |
6708bb27 | 2569 | pr_warn("Ran out of lu_gp_show_attr" |
c66ac9db NB |
2570 | "_members buffer\n"); |
2571 | break; | |
2572 | } | |
2573 | memcpy(page+len, buf, cur_len); | |
2574 | len += cur_len; | |
2575 | } | |
2576 | spin_unlock(&tg_pt_gp->tg_pt_gp_lock); | |
2577 | ||
2578 | return len; | |
2579 | } | |
2580 | ||
2581 | SE_DEV_ALUA_TG_PT_ATTR_RO(members); | |
2582 | ||
2583 | CONFIGFS_EATTR_OPS(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp, | |
2584 | tg_pt_gp_group); | |
2585 | ||
2586 | static struct configfs_attribute *target_core_alua_tg_pt_gp_attrs[] = { | |
2587 | &target_core_alua_tg_pt_gp_alua_access_state.attr, | |
2588 | &target_core_alua_tg_pt_gp_alua_access_status.attr, | |
2589 | &target_core_alua_tg_pt_gp_alua_access_type.attr, | |
2590 | &target_core_alua_tg_pt_gp_alua_write_metadata.attr, | |
2591 | &target_core_alua_tg_pt_gp_nonop_delay_msecs.attr, | |
2592 | &target_core_alua_tg_pt_gp_trans_delay_msecs.attr, | |
2593 | &target_core_alua_tg_pt_gp_preferred.attr, | |
2594 | &target_core_alua_tg_pt_gp_tg_pt_gp_id.attr, | |
2595 | &target_core_alua_tg_pt_gp_members.attr, | |
2596 | NULL, | |
2597 | }; | |
2598 | ||
1f6fe7cb NB |
2599 | static void target_core_alua_tg_pt_gp_release(struct config_item *item) |
2600 | { | |
2601 | struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(to_config_group(item), | |
2602 | struct t10_alua_tg_pt_gp, tg_pt_gp_group); | |
2603 | ||
2604 | core_alua_free_tg_pt_gp(tg_pt_gp); | |
2605 | } | |
2606 | ||
c66ac9db | 2607 | static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { |
1f6fe7cb | 2608 | .release = target_core_alua_tg_pt_gp_release, |
c66ac9db NB |
2609 | .show_attribute = target_core_alua_tg_pt_gp_attr_show, |
2610 | .store_attribute = target_core_alua_tg_pt_gp_attr_store, | |
2611 | }; | |
2612 | ||
2613 | static struct config_item_type target_core_alua_tg_pt_gp_cit = { | |
2614 | .ct_item_ops = &target_core_alua_tg_pt_gp_ops, | |
2615 | .ct_attrs = target_core_alua_tg_pt_gp_attrs, | |
2616 | .ct_owner = THIS_MODULE, | |
2617 | }; | |
2618 | ||
2619 | /* End functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ | |
2620 | ||
2621 | /* Start functions for struct config_item_type target_core_alua_tg_pt_gps_cit */ | |
2622 | ||
2623 | static struct config_group *target_core_alua_create_tg_pt_gp( | |
2624 | struct config_group *group, | |
2625 | const char *name) | |
2626 | { | |
2627 | struct t10_alua *alua = container_of(group, struct t10_alua, | |
2628 | alua_tg_pt_gps_group); | |
2629 | struct t10_alua_tg_pt_gp *tg_pt_gp; | |
2630 | struct se_subsystem_dev *su_dev = alua->t10_sub_dev; | |
2631 | struct config_group *alua_tg_pt_gp_cg = NULL; | |
2632 | struct config_item *alua_tg_pt_gp_ci = NULL; | |
2633 | ||
2634 | tg_pt_gp = core_alua_allocate_tg_pt_gp(su_dev, name, 0); | |
6708bb27 | 2635 | if (!tg_pt_gp) |
c66ac9db NB |
2636 | return NULL; |
2637 | ||
2638 | alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group; | |
2639 | alua_tg_pt_gp_ci = &alua_tg_pt_gp_cg->cg_item; | |
2640 | ||
2641 | config_group_init_type_name(alua_tg_pt_gp_cg, name, | |
2642 | &target_core_alua_tg_pt_gp_cit); | |
2643 | ||
6708bb27 | 2644 | pr_debug("Target_Core_ConfigFS: Allocated ALUA Target Port" |
c66ac9db NB |
2645 | " Group: alua/tg_pt_gps/%s\n", |
2646 | config_item_name(alua_tg_pt_gp_ci)); | |
2647 | ||
2648 | return alua_tg_pt_gp_cg; | |
2649 | } | |
2650 | ||
2651 | static void target_core_alua_drop_tg_pt_gp( | |
2652 | struct config_group *group, | |
2653 | struct config_item *item) | |
2654 | { | |
2655 | struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(to_config_group(item), | |
2656 | struct t10_alua_tg_pt_gp, tg_pt_gp_group); | |
2657 | ||
6708bb27 | 2658 | pr_debug("Target_Core_ConfigFS: Releasing ALUA Target Port" |
c66ac9db NB |
2659 | " Group: alua/tg_pt_gps/%s, ID: %hu\n", |
2660 | config_item_name(item), tg_pt_gp->tg_pt_gp_id); | |
1f6fe7cb NB |
2661 | /* |
2662 | * core_alua_free_tg_pt_gp() is called from target_core_alua_tg_pt_gp_ops->release() | |
2663 | * -> target_core_alua_tg_pt_gp_release(). | |
2664 | */ | |
c66ac9db | 2665 | config_item_put(item); |
c66ac9db NB |
2666 | } |
2667 | ||
2668 | static struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = { | |
2669 | .make_group = &target_core_alua_create_tg_pt_gp, | |
2670 | .drop_item = &target_core_alua_drop_tg_pt_gp, | |
2671 | }; | |
2672 | ||
2673 | static struct config_item_type target_core_alua_tg_pt_gps_cit = { | |
2674 | .ct_group_ops = &target_core_alua_tg_pt_gps_group_ops, | |
2675 | .ct_owner = THIS_MODULE, | |
2676 | }; | |
2677 | ||
2678 | /* End functions for struct config_item_type target_core_alua_tg_pt_gps_cit */ | |
2679 | ||
2680 | /* Start functions for struct config_item_type target_core_alua_cit */ | |
2681 | ||
2682 | /* | |
2683 | * target_core_alua_cit is a ConfigFS group that lives under | |
2684 | * /sys/kernel/config/target/core/alua. There are default groups | |
2685 | * core/alua/lu_gps and core/alua/tg_pt_gps that are attached to | |
2686 | * target_core_alua_cit in target_core_init_configfs() below. | |
2687 | */ | |
2688 | static struct config_item_type target_core_alua_cit = { | |
2689 | .ct_item_ops = NULL, | |
2690 | .ct_attrs = NULL, | |
2691 | .ct_owner = THIS_MODULE, | |
2692 | }; | |
2693 | ||
2694 | /* End functions for struct config_item_type target_core_alua_cit */ | |
2695 | ||
12d23384 NB |
2696 | /* Start functions for struct config_item_type target_core_stat_cit */ |
2697 | ||
2698 | static struct config_group *target_core_stat_mkdir( | |
2699 | struct config_group *group, | |
2700 | const char *name) | |
2701 | { | |
2702 | return ERR_PTR(-ENOSYS); | |
2703 | } | |
2704 | ||
2705 | static void target_core_stat_rmdir( | |
2706 | struct config_group *group, | |
2707 | struct config_item *item) | |
2708 | { | |
2709 | return; | |
2710 | } | |
2711 | ||
2712 | static struct configfs_group_operations target_core_stat_group_ops = { | |
2713 | .make_group = &target_core_stat_mkdir, | |
2714 | .drop_item = &target_core_stat_rmdir, | |
2715 | }; | |
2716 | ||
2717 | static struct config_item_type target_core_stat_cit = { | |
2718 | .ct_group_ops = &target_core_stat_group_ops, | |
2719 | .ct_owner = THIS_MODULE, | |
2720 | }; | |
2721 | ||
2722 | /* End functions for struct config_item_type target_core_stat_cit */ | |
2723 | ||
c66ac9db NB |
2724 | /* Start functions for struct config_item_type target_core_hba_cit */ |
2725 | ||
2726 | static struct config_group *target_core_make_subdev( | |
2727 | struct config_group *group, | |
2728 | const char *name) | |
2729 | { | |
2730 | struct t10_alua_tg_pt_gp *tg_pt_gp; | |
2731 | struct se_subsystem_dev *se_dev; | |
2732 | struct se_subsystem_api *t; | |
2733 | struct config_item *hba_ci = &group->cg_item; | |
2734 | struct se_hba *hba = item_to_hba(hba_ci); | |
2735 | struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL; | |
12d23384 NB |
2736 | struct config_group *dev_stat_grp = NULL; |
2737 | int errno = -ENOMEM, ret; | |
c66ac9db | 2738 | |
12d23384 NB |
2739 | ret = mutex_lock_interruptible(&hba->hba_access_mutex); |
2740 | if (ret) | |
2741 | return ERR_PTR(ret); | |
c66ac9db NB |
2742 | /* |
2743 | * Locate the struct se_subsystem_api from parent's struct se_hba. | |
2744 | */ | |
2745 | t = hba->transport; | |
2746 | ||
2747 | se_dev = kzalloc(sizeof(struct se_subsystem_dev), GFP_KERNEL); | |
2748 | if (!se_dev) { | |
6708bb27 | 2749 | pr_err("Unable to allocate memory for" |
c66ac9db NB |
2750 | " struct se_subsystem_dev\n"); |
2751 | goto unlock; | |
2752 | } | |
e3d6f909 | 2753 | INIT_LIST_HEAD(&se_dev->se_dev_node); |
c66ac9db NB |
2754 | INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); |
2755 | spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); | |
e3d6f909 AG |
2756 | INIT_LIST_HEAD(&se_dev->t10_pr.registration_list); |
2757 | INIT_LIST_HEAD(&se_dev->t10_pr.aptpl_reg_list); | |
2758 | spin_lock_init(&se_dev->t10_pr.registration_lock); | |
2759 | spin_lock_init(&se_dev->t10_pr.aptpl_reg_lock); | |
c66ac9db NB |
2760 | INIT_LIST_HEAD(&se_dev->t10_alua.tg_pt_gps_list); |
2761 | spin_lock_init(&se_dev->t10_alua.tg_pt_gps_lock); | |
2762 | spin_lock_init(&se_dev->se_dev_lock); | |
e3d6f909 | 2763 | se_dev->t10_pr.pr_aptpl_buf_len = PR_APTPL_BUF_LEN; |
c66ac9db NB |
2764 | se_dev->t10_wwn.t10_sub_dev = se_dev; |
2765 | se_dev->t10_alua.t10_sub_dev = se_dev; | |
2766 | se_dev->se_dev_attrib.da_sub_dev = se_dev; | |
2767 | ||
2768 | se_dev->se_dev_hba = hba; | |
2769 | dev_cg = &se_dev->se_dev_group; | |
2770 | ||
12d23384 | 2771 | dev_cg->default_groups = kzalloc(sizeof(struct config_group) * 7, |
c66ac9db | 2772 | GFP_KERNEL); |
6708bb27 | 2773 | if (!dev_cg->default_groups) |
c66ac9db NB |
2774 | goto out; |
2775 | /* | |
2776 | * Set se_dev_su_ptr from struct se_subsystem_api returned void ptr | |
2777 | * for ->allocate_virtdevice() | |
2778 | * | |
2779 | * se_dev->se_dev_ptr will be set after ->create_virtdev() | |
2780 | * has been called successfully in the next level up in the | |
2781 | * configfs tree for device object's struct config_group. | |
2782 | */ | |
2783 | se_dev->se_dev_su_ptr = t->allocate_virtdevice(hba, name); | |
6708bb27 AG |
2784 | if (!se_dev->se_dev_su_ptr) { |
2785 | pr_err("Unable to locate subsystem dependent pointer" | |
c66ac9db NB |
2786 | " from allocate_virtdevice()\n"); |
2787 | goto out; | |
2788 | } | |
e3d6f909 AG |
2789 | spin_lock(&se_device_lock); |
2790 | list_add_tail(&se_dev->se_dev_node, &se_dev_list); | |
2791 | spin_unlock(&se_device_lock); | |
c66ac9db NB |
2792 | |
2793 | config_group_init_type_name(&se_dev->se_dev_group, name, | |
2794 | &target_core_dev_cit); | |
2795 | config_group_init_type_name(&se_dev->se_dev_attrib.da_group, "attrib", | |
2796 | &target_core_dev_attrib_cit); | |
2797 | config_group_init_type_name(&se_dev->se_dev_pr_group, "pr", | |
2798 | &target_core_dev_pr_cit); | |
2799 | config_group_init_type_name(&se_dev->t10_wwn.t10_wwn_group, "wwn", | |
2800 | &target_core_dev_wwn_cit); | |
2801 | config_group_init_type_name(&se_dev->t10_alua.alua_tg_pt_gps_group, | |
2802 | "alua", &target_core_alua_tg_pt_gps_cit); | |
12d23384 NB |
2803 | config_group_init_type_name(&se_dev->dev_stat_grps.stat_group, |
2804 | "statistics", &target_core_stat_cit); | |
2805 | ||
c66ac9db NB |
2806 | dev_cg->default_groups[0] = &se_dev->se_dev_attrib.da_group; |
2807 | dev_cg->default_groups[1] = &se_dev->se_dev_pr_group; | |
2808 | dev_cg->default_groups[2] = &se_dev->t10_wwn.t10_wwn_group; | |
2809 | dev_cg->default_groups[3] = &se_dev->t10_alua.alua_tg_pt_gps_group; | |
12d23384 NB |
2810 | dev_cg->default_groups[4] = &se_dev->dev_stat_grps.stat_group; |
2811 | dev_cg->default_groups[5] = NULL; | |
c66ac9db | 2812 | /* |
12d23384 | 2813 | * Add core/$HBA/$DEV/alua/default_tg_pt_gp |
c66ac9db NB |
2814 | */ |
2815 | tg_pt_gp = core_alua_allocate_tg_pt_gp(se_dev, "default_tg_pt_gp", 1); | |
6708bb27 | 2816 | if (!tg_pt_gp) |
c66ac9db NB |
2817 | goto out; |
2818 | ||
e3d6f909 | 2819 | tg_pt_gp_cg = &se_dev->t10_alua.alua_tg_pt_gps_group; |
c66ac9db NB |
2820 | tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, |
2821 | GFP_KERNEL); | |
6708bb27 AG |
2822 | if (!tg_pt_gp_cg->default_groups) { |
2823 | pr_err("Unable to allocate tg_pt_gp_cg->" | |
c66ac9db NB |
2824 | "default_groups\n"); |
2825 | goto out; | |
2826 | } | |
2827 | ||
2828 | config_group_init_type_name(&tg_pt_gp->tg_pt_gp_group, | |
2829 | "default_tg_pt_gp", &target_core_alua_tg_pt_gp_cit); | |
2830 | tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group; | |
2831 | tg_pt_gp_cg->default_groups[1] = NULL; | |
e3d6f909 | 2832 | se_dev->t10_alua.default_tg_pt_gp = tg_pt_gp; |
12d23384 NB |
2833 | /* |
2834 | * Add core/$HBA/$DEV/statistics/ default groups | |
2835 | */ | |
e3d6f909 | 2836 | dev_stat_grp = &se_dev->dev_stat_grps.stat_group; |
12d23384 NB |
2837 | dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 4, |
2838 | GFP_KERNEL); | |
2839 | if (!dev_stat_grp->default_groups) { | |
6708bb27 | 2840 | pr_err("Unable to allocate dev_stat_grp->default_groups\n"); |
12d23384 NB |
2841 | goto out; |
2842 | } | |
2843 | target_stat_setup_dev_default_groups(se_dev); | |
c66ac9db | 2844 | |
6708bb27 | 2845 | pr_debug("Target_Core_ConfigFS: Allocated struct se_subsystem_dev:" |
c66ac9db NB |
2846 | " %p se_dev_su_ptr: %p\n", se_dev, se_dev->se_dev_su_ptr); |
2847 | ||
2848 | mutex_unlock(&hba->hba_access_mutex); | |
2849 | return &se_dev->se_dev_group; | |
2850 | out: | |
e3d6f909 AG |
2851 | if (se_dev->t10_alua.default_tg_pt_gp) { |
2852 | core_alua_free_tg_pt_gp(se_dev->t10_alua.default_tg_pt_gp); | |
2853 | se_dev->t10_alua.default_tg_pt_gp = NULL; | |
c66ac9db | 2854 | } |
12d23384 NB |
2855 | if (dev_stat_grp) |
2856 | kfree(dev_stat_grp->default_groups); | |
c66ac9db NB |
2857 | if (tg_pt_gp_cg) |
2858 | kfree(tg_pt_gp_cg->default_groups); | |
2859 | if (dev_cg) | |
2860 | kfree(dev_cg->default_groups); | |
2861 | if (se_dev->se_dev_su_ptr) | |
2862 | t->free_device(se_dev->se_dev_su_ptr); | |
2863 | kfree(se_dev); | |
2864 | unlock: | |
2865 | mutex_unlock(&hba->hba_access_mutex); | |
12d23384 | 2866 | return ERR_PTR(errno); |
c66ac9db NB |
2867 | } |
2868 | ||
2869 | static void target_core_drop_subdev( | |
2870 | struct config_group *group, | |
2871 | struct config_item *item) | |
2872 | { | |
2873 | struct se_subsystem_dev *se_dev = container_of(to_config_group(item), | |
2874 | struct se_subsystem_dev, se_dev_group); | |
2875 | struct se_hba *hba; | |
2876 | struct se_subsystem_api *t; | |
2877 | struct config_item *df_item; | |
12d23384 | 2878 | struct config_group *dev_cg, *tg_pt_gp_cg, *dev_stat_grp; |
1f6fe7cb | 2879 | int i; |
c66ac9db NB |
2880 | |
2881 | hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item); | |
2882 | ||
1f6fe7cb | 2883 | mutex_lock(&hba->hba_access_mutex); |
c66ac9db NB |
2884 | t = hba->transport; |
2885 | ||
e3d6f909 AG |
2886 | spin_lock(&se_device_lock); |
2887 | list_del(&se_dev->se_dev_node); | |
2888 | spin_unlock(&se_device_lock); | |
c66ac9db | 2889 | |
e3d6f909 | 2890 | dev_stat_grp = &se_dev->dev_stat_grps.stat_group; |
12d23384 NB |
2891 | for (i = 0; dev_stat_grp->default_groups[i]; i++) { |
2892 | df_item = &dev_stat_grp->default_groups[i]->cg_item; | |
2893 | dev_stat_grp->default_groups[i] = NULL; | |
2894 | config_item_put(df_item); | |
2895 | } | |
2896 | kfree(dev_stat_grp->default_groups); | |
2897 | ||
e3d6f909 | 2898 | tg_pt_gp_cg = &se_dev->t10_alua.alua_tg_pt_gps_group; |
c66ac9db NB |
2899 | for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) { |
2900 | df_item = &tg_pt_gp_cg->default_groups[i]->cg_item; | |
2901 | tg_pt_gp_cg->default_groups[i] = NULL; | |
2902 | config_item_put(df_item); | |
2903 | } | |
2904 | kfree(tg_pt_gp_cg->default_groups); | |
1f6fe7cb NB |
2905 | /* |
2906 | * core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp | |
2907 | * directly from target_core_alua_tg_pt_gp_release(). | |
2908 | */ | |
e3d6f909 | 2909 | se_dev->t10_alua.default_tg_pt_gp = NULL; |
c66ac9db NB |
2910 | |
2911 | dev_cg = &se_dev->se_dev_group; | |
2912 | for (i = 0; dev_cg->default_groups[i]; i++) { | |
2913 | df_item = &dev_cg->default_groups[i]->cg_item; | |
2914 | dev_cg->default_groups[i] = NULL; | |
2915 | config_item_put(df_item); | |
2916 | } | |
c66ac9db | 2917 | /* |
1f6fe7cb NB |
2918 | * The releasing of se_dev and associated se_dev->se_dev_ptr is done |
2919 | * from target_core_dev_item_ops->release() ->target_core_dev_release(). | |
c66ac9db | 2920 | */ |
1f6fe7cb | 2921 | config_item_put(item); |
c66ac9db | 2922 | mutex_unlock(&hba->hba_access_mutex); |
c66ac9db NB |
2923 | } |
2924 | ||
2925 | static struct configfs_group_operations target_core_hba_group_ops = { | |
2926 | .make_group = target_core_make_subdev, | |
2927 | .drop_item = target_core_drop_subdev, | |
2928 | }; | |
2929 | ||
2930 | CONFIGFS_EATTR_STRUCT(target_core_hba, se_hba); | |
2931 | #define SE_HBA_ATTR(_name, _mode) \ | |
2932 | static struct target_core_hba_attribute \ | |
2933 | target_core_hba_##_name = \ | |
2934 | __CONFIGFS_EATTR(_name, _mode, \ | |
2935 | target_core_hba_show_attr_##_name, \ | |
2936 | target_core_hba_store_attr_##_name); | |
2937 | ||
2938 | #define SE_HBA_ATTR_RO(_name) \ | |
2939 | static struct target_core_hba_attribute \ | |
2940 | target_core_hba_##_name = \ | |
2941 | __CONFIGFS_EATTR_RO(_name, \ | |
2942 | target_core_hba_show_attr_##_name); | |
2943 | ||
2944 | static ssize_t target_core_hba_show_attr_hba_info( | |
2945 | struct se_hba *hba, | |
2946 | char *page) | |
2947 | { | |
2948 | return sprintf(page, "HBA Index: %d plugin: %s version: %s\n", | |
2949 | hba->hba_id, hba->transport->name, | |
2950 | TARGET_CORE_CONFIGFS_VERSION); | |
2951 | } | |
2952 | ||
2953 | SE_HBA_ATTR_RO(hba_info); | |
2954 | ||
2955 | static ssize_t target_core_hba_show_attr_hba_mode(struct se_hba *hba, | |
2956 | char *page) | |
2957 | { | |
2958 | int hba_mode = 0; | |
2959 | ||
2960 | if (hba->hba_flags & HBA_FLAGS_PSCSI_MODE) | |
2961 | hba_mode = 1; | |
2962 | ||
2963 | return sprintf(page, "%d\n", hba_mode); | |
2964 | } | |
2965 | ||
2966 | static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba, | |
2967 | const char *page, size_t count) | |
2968 | { | |
2969 | struct se_subsystem_api *transport = hba->transport; | |
2970 | unsigned long mode_flag; | |
2971 | int ret; | |
2972 | ||
2973 | if (transport->pmode_enable_hba == NULL) | |
2974 | return -EINVAL; | |
2975 | ||
2976 | ret = strict_strtoul(page, 0, &mode_flag); | |
2977 | if (ret < 0) { | |
6708bb27 | 2978 | pr_err("Unable to extract hba mode flag: %d\n", ret); |
c66ac9db NB |
2979 | return -EINVAL; |
2980 | } | |
2981 | ||
2982 | spin_lock(&hba->device_lock); | |
6708bb27 AG |
2983 | if (!list_empty(&hba->hba_dev_list)) { |
2984 | pr_err("Unable to set hba_mode with active devices\n"); | |
c66ac9db NB |
2985 | spin_unlock(&hba->device_lock); |
2986 | return -EINVAL; | |
2987 | } | |
2988 | spin_unlock(&hba->device_lock); | |
2989 | ||
2990 | ret = transport->pmode_enable_hba(hba, mode_flag); | |
2991 | if (ret < 0) | |
2992 | return -EINVAL; | |
2993 | if (ret > 0) | |
2994 | hba->hba_flags |= HBA_FLAGS_PSCSI_MODE; | |
2995 | else if (ret == 0) | |
2996 | hba->hba_flags &= ~HBA_FLAGS_PSCSI_MODE; | |
2997 | ||
2998 | return count; | |
2999 | } | |
3000 | ||
3001 | SE_HBA_ATTR(hba_mode, S_IRUGO | S_IWUSR); | |
3002 | ||
3003 | CONFIGFS_EATTR_OPS(target_core_hba, se_hba, hba_group); | |
3004 | ||
1f6fe7cb NB |
3005 | static void target_core_hba_release(struct config_item *item) |
3006 | { | |
3007 | struct se_hba *hba = container_of(to_config_group(item), | |
3008 | struct se_hba, hba_group); | |
3009 | core_delete_hba(hba); | |
3010 | } | |
3011 | ||
c66ac9db NB |
3012 | static struct configfs_attribute *target_core_hba_attrs[] = { |
3013 | &target_core_hba_hba_info.attr, | |
3014 | &target_core_hba_hba_mode.attr, | |
3015 | NULL, | |
3016 | }; | |
3017 | ||
3018 | static struct configfs_item_operations target_core_hba_item_ops = { | |
1f6fe7cb | 3019 | .release = target_core_hba_release, |
c66ac9db NB |
3020 | .show_attribute = target_core_hba_attr_show, |
3021 | .store_attribute = target_core_hba_attr_store, | |
3022 | }; | |
3023 | ||
3024 | static struct config_item_type target_core_hba_cit = { | |
3025 | .ct_item_ops = &target_core_hba_item_ops, | |
3026 | .ct_group_ops = &target_core_hba_group_ops, | |
3027 | .ct_attrs = target_core_hba_attrs, | |
3028 | .ct_owner = THIS_MODULE, | |
3029 | }; | |
3030 | ||
3031 | static struct config_group *target_core_call_addhbatotarget( | |
3032 | struct config_group *group, | |
3033 | const char *name) | |
3034 | { | |
3035 | char *se_plugin_str, *str, *str2; | |
3036 | struct se_hba *hba; | |
3037 | char buf[TARGET_CORE_NAME_MAX_LEN]; | |
3038 | unsigned long plugin_dep_id = 0; | |
3039 | int ret; | |
3040 | ||
3041 | memset(buf, 0, TARGET_CORE_NAME_MAX_LEN); | |
60d645a4 | 3042 | if (strlen(name) >= TARGET_CORE_NAME_MAX_LEN) { |
6708bb27 | 3043 | pr_err("Passed *name strlen(): %d exceeds" |
c66ac9db NB |
3044 | " TARGET_CORE_NAME_MAX_LEN: %d\n", (int)strlen(name), |
3045 | TARGET_CORE_NAME_MAX_LEN); | |
3046 | return ERR_PTR(-ENAMETOOLONG); | |
3047 | } | |
3048 | snprintf(buf, TARGET_CORE_NAME_MAX_LEN, "%s", name); | |
3049 | ||
3050 | str = strstr(buf, "_"); | |
6708bb27 AG |
3051 | if (!str) { |
3052 | pr_err("Unable to locate \"_\" for $SUBSYSTEM_PLUGIN_$HOST_ID\n"); | |
c66ac9db NB |
3053 | return ERR_PTR(-EINVAL); |
3054 | } | |
3055 | se_plugin_str = buf; | |
3056 | /* | |
3057 | * Special case for subsystem plugins that have "_" in their names. | |
3058 | * Namely rd_direct and rd_mcp.. | |
3059 | */ | |
3060 | str2 = strstr(str+1, "_"); | |
6708bb27 | 3061 | if (str2) { |
c66ac9db NB |
3062 | *str2 = '\0'; /* Terminate for *se_plugin_str */ |
3063 | str2++; /* Skip to start of plugin dependent ID */ | |
3064 | str = str2; | |
3065 | } else { | |
3066 | *str = '\0'; /* Terminate for *se_plugin_str */ | |
3067 | str++; /* Skip to start of plugin dependent ID */ | |
3068 | } | |
3069 | ||
3070 | ret = strict_strtoul(str, 0, &plugin_dep_id); | |
3071 | if (ret < 0) { | |
6708bb27 | 3072 | pr_err("strict_strtoul() returned %d for" |
c66ac9db NB |
3073 | " plugin_dep_id\n", ret); |
3074 | return ERR_PTR(-EINVAL); | |
3075 | } | |
3076 | /* | |
3077 | * Load up TCM subsystem plugins if they have not already been loaded. | |
3078 | */ | |
3079 | if (transport_subsystem_check_init() < 0) | |
3080 | return ERR_PTR(-EINVAL); | |
3081 | ||
3082 | hba = core_alloc_hba(se_plugin_str, plugin_dep_id, 0); | |
3083 | if (IS_ERR(hba)) | |
3084 | return ERR_CAST(hba); | |
3085 | ||
3086 | config_group_init_type_name(&hba->hba_group, name, | |
3087 | &target_core_hba_cit); | |
3088 | ||
3089 | return &hba->hba_group; | |
3090 | } | |
3091 | ||
3092 | static void target_core_call_delhbafromtarget( | |
3093 | struct config_group *group, | |
3094 | struct config_item *item) | |
3095 | { | |
1f6fe7cb NB |
3096 | /* |
3097 | * core_delete_hba() is called from target_core_hba_item_ops->release() | |
3098 | * -> target_core_hba_release() | |
3099 | */ | |
c66ac9db | 3100 | config_item_put(item); |
c66ac9db NB |
3101 | } |
3102 | ||
3103 | static struct configfs_group_operations target_core_group_ops = { | |
3104 | .make_group = target_core_call_addhbatotarget, | |
3105 | .drop_item = target_core_call_delhbafromtarget, | |
3106 | }; | |
3107 | ||
3108 | static struct config_item_type target_core_cit = { | |
3109 | .ct_item_ops = NULL, | |
3110 | .ct_group_ops = &target_core_group_ops, | |
3111 | .ct_attrs = NULL, | |
3112 | .ct_owner = THIS_MODULE, | |
3113 | }; | |
3114 | ||
3115 | /* Stop functions for struct config_item_type target_core_hba_cit */ | |
3116 | ||
54550fab | 3117 | static int __init target_core_init_configfs(void) |
c66ac9db NB |
3118 | { |
3119 | struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL; | |
3120 | struct config_group *lu_gp_cg = NULL; | |
3121 | struct configfs_subsystem *subsys; | |
c66ac9db NB |
3122 | struct t10_alua_lu_gp *lu_gp; |
3123 | int ret; | |
3124 | ||
6708bb27 | 3125 | pr_debug("TARGET_CORE[0]: Loading Generic Kernel Storage" |
c66ac9db NB |
3126 | " Engine: %s on %s/%s on "UTS_RELEASE"\n", |
3127 | TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine); | |
3128 | ||
3129 | subsys = target_core_subsystem[0]; | |
3130 | config_group_init(&subsys->su_group); | |
3131 | mutex_init(&subsys->su_mutex); | |
3132 | ||
3133 | INIT_LIST_HEAD(&g_tf_list); | |
3134 | mutex_init(&g_tf_lock); | |
e3d6f909 | 3135 | ret = init_se_kmem_caches(); |
c66ac9db | 3136 | if (ret < 0) |
e3d6f909 | 3137 | return ret; |
c66ac9db NB |
3138 | /* |
3139 | * Create $CONFIGFS/target/core default group for HBA <-> Storage Object | |
3140 | * and ALUA Logical Unit Group and Target Port Group infrastructure. | |
3141 | */ | |
3142 | target_cg = &subsys->su_group; | |
3143 | target_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, | |
3144 | GFP_KERNEL); | |
6708bb27 AG |
3145 | if (!target_cg->default_groups) { |
3146 | pr_err("Unable to allocate target_cg->default_groups\n"); | |
c66ac9db NB |
3147 | goto out_global; |
3148 | } | |
3149 | ||
e3d6f909 | 3150 | config_group_init_type_name(&target_core_hbagroup, |
c66ac9db | 3151 | "core", &target_core_cit); |
e3d6f909 | 3152 | target_cg->default_groups[0] = &target_core_hbagroup; |
c66ac9db NB |
3153 | target_cg->default_groups[1] = NULL; |
3154 | /* | |
3155 | * Create ALUA infrastructure under /sys/kernel/config/target/core/alua/ | |
3156 | */ | |
e3d6f909 | 3157 | hba_cg = &target_core_hbagroup; |
c66ac9db NB |
3158 | hba_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, |
3159 | GFP_KERNEL); | |
6708bb27 AG |
3160 | if (!hba_cg->default_groups) { |
3161 | pr_err("Unable to allocate hba_cg->default_groups\n"); | |
c66ac9db NB |
3162 | goto out_global; |
3163 | } | |
e3d6f909 | 3164 | config_group_init_type_name(&alua_group, |
c66ac9db | 3165 | "alua", &target_core_alua_cit); |
e3d6f909 | 3166 | hba_cg->default_groups[0] = &alua_group; |
c66ac9db NB |
3167 | hba_cg->default_groups[1] = NULL; |
3168 | /* | |
3169 | * Add ALUA Logical Unit Group and Target Port Group ConfigFS | |
3170 | * groups under /sys/kernel/config/target/core/alua/ | |
3171 | */ | |
e3d6f909 | 3172 | alua_cg = &alua_group; |
c66ac9db NB |
3173 | alua_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, |
3174 | GFP_KERNEL); | |
6708bb27 AG |
3175 | if (!alua_cg->default_groups) { |
3176 | pr_err("Unable to allocate alua_cg->default_groups\n"); | |
c66ac9db NB |
3177 | goto out_global; |
3178 | } | |
3179 | ||
e3d6f909 | 3180 | config_group_init_type_name(&alua_lu_gps_group, |
c66ac9db | 3181 | "lu_gps", &target_core_alua_lu_gps_cit); |
e3d6f909 | 3182 | alua_cg->default_groups[0] = &alua_lu_gps_group; |
c66ac9db NB |
3183 | alua_cg->default_groups[1] = NULL; |
3184 | /* | |
3185 | * Add core/alua/lu_gps/default_lu_gp | |
3186 | */ | |
3187 | lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1); | |
3188 | if (IS_ERR(lu_gp)) | |
3189 | goto out_global; | |
3190 | ||
e3d6f909 | 3191 | lu_gp_cg = &alua_lu_gps_group; |
c66ac9db NB |
3192 | lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, |
3193 | GFP_KERNEL); | |
6708bb27 AG |
3194 | if (!lu_gp_cg->default_groups) { |
3195 | pr_err("Unable to allocate lu_gp_cg->default_groups\n"); | |
c66ac9db NB |
3196 | goto out_global; |
3197 | } | |
3198 | ||
3199 | config_group_init_type_name(&lu_gp->lu_gp_group, "default_lu_gp", | |
3200 | &target_core_alua_lu_gp_cit); | |
3201 | lu_gp_cg->default_groups[0] = &lu_gp->lu_gp_group; | |
3202 | lu_gp_cg->default_groups[1] = NULL; | |
e3d6f909 | 3203 | default_lu_gp = lu_gp; |
c66ac9db NB |
3204 | /* |
3205 | * Register the target_core_mod subsystem with configfs. | |
3206 | */ | |
3207 | ret = configfs_register_subsystem(subsys); | |
3208 | if (ret < 0) { | |
6708bb27 | 3209 | pr_err("Error %d while registering subsystem %s\n", |
c66ac9db NB |
3210 | ret, subsys->su_group.cg_item.ci_namebuf); |
3211 | goto out_global; | |
3212 | } | |
6708bb27 | 3213 | pr_debug("TARGET_CORE[0]: Initialized ConfigFS Fabric" |
c66ac9db NB |
3214 | " Infrastructure: "TARGET_CORE_CONFIGFS_VERSION" on %s/%s" |
3215 | " on "UTS_RELEASE"\n", utsname()->sysname, utsname()->machine); | |
3216 | /* | |
3217 | * Register built-in RAMDISK subsystem logic for virtual LUN 0 | |
3218 | */ | |
3219 | ret = rd_module_init(); | |
3220 | if (ret < 0) | |
3221 | goto out; | |
3222 | ||
3223 | if (core_dev_setup_virtual_lun0() < 0) | |
3224 | goto out; | |
3225 | ||
c66ac9db NB |
3226 | return 0; |
3227 | ||
3228 | out: | |
3229 | configfs_unregister_subsystem(subsys); | |
c66ac9db NB |
3230 | core_dev_release_virtual_lun0(); |
3231 | rd_module_exit(); | |
3232 | out_global: | |
e3d6f909 AG |
3233 | if (default_lu_gp) { |
3234 | core_alua_free_lu_gp(default_lu_gp); | |
3235 | default_lu_gp = NULL; | |
c66ac9db NB |
3236 | } |
3237 | if (lu_gp_cg) | |
3238 | kfree(lu_gp_cg->default_groups); | |
3239 | if (alua_cg) | |
3240 | kfree(alua_cg->default_groups); | |
3241 | if (hba_cg) | |
3242 | kfree(hba_cg->default_groups); | |
3243 | kfree(target_cg->default_groups); | |
e3d6f909 AG |
3244 | release_se_kmem_caches(); |
3245 | return ret; | |
c66ac9db NB |
3246 | } |
3247 | ||
54550fab | 3248 | static void __exit target_core_exit_configfs(void) |
c66ac9db NB |
3249 | { |
3250 | struct configfs_subsystem *subsys; | |
3251 | struct config_group *hba_cg, *alua_cg, *lu_gp_cg; | |
3252 | struct config_item *item; | |
3253 | int i; | |
3254 | ||
c66ac9db NB |
3255 | subsys = target_core_subsystem[0]; |
3256 | ||
e3d6f909 | 3257 | lu_gp_cg = &alua_lu_gps_group; |
c66ac9db NB |
3258 | for (i = 0; lu_gp_cg->default_groups[i]; i++) { |
3259 | item = &lu_gp_cg->default_groups[i]->cg_item; | |
3260 | lu_gp_cg->default_groups[i] = NULL; | |
3261 | config_item_put(item); | |
3262 | } | |
3263 | kfree(lu_gp_cg->default_groups); | |
7c2bf6e9 | 3264 | lu_gp_cg->default_groups = NULL; |
c66ac9db | 3265 | |
e3d6f909 | 3266 | alua_cg = &alua_group; |
c66ac9db NB |
3267 | for (i = 0; alua_cg->default_groups[i]; i++) { |
3268 | item = &alua_cg->default_groups[i]->cg_item; | |
3269 | alua_cg->default_groups[i] = NULL; | |
3270 | config_item_put(item); | |
3271 | } | |
3272 | kfree(alua_cg->default_groups); | |
7c2bf6e9 | 3273 | alua_cg->default_groups = NULL; |
c66ac9db | 3274 | |
e3d6f909 | 3275 | hba_cg = &target_core_hbagroup; |
c66ac9db NB |
3276 | for (i = 0; hba_cg->default_groups[i]; i++) { |
3277 | item = &hba_cg->default_groups[i]->cg_item; | |
3278 | hba_cg->default_groups[i] = NULL; | |
3279 | config_item_put(item); | |
3280 | } | |
3281 | kfree(hba_cg->default_groups); | |
7c2bf6e9 NB |
3282 | hba_cg->default_groups = NULL; |
3283 | /* | |
3284 | * We expect subsys->su_group.default_groups to be released | |
3285 | * by configfs subsystem provider logic.. | |
3286 | */ | |
3287 | configfs_unregister_subsystem(subsys); | |
c66ac9db NB |
3288 | kfree(subsys->su_group.default_groups); |
3289 | ||
e3d6f909 AG |
3290 | core_alua_free_lu_gp(default_lu_gp); |
3291 | default_lu_gp = NULL; | |
7c2bf6e9 | 3292 | |
6708bb27 | 3293 | pr_debug("TARGET_CORE[0]: Released ConfigFS Fabric" |
c66ac9db NB |
3294 | " Infrastructure\n"); |
3295 | ||
c66ac9db NB |
3296 | core_dev_release_virtual_lun0(); |
3297 | rd_module_exit(); | |
e3d6f909 | 3298 | release_se_kmem_caches(); |
c66ac9db NB |
3299 | } |
3300 | ||
3301 | MODULE_DESCRIPTION("Target_Core_Mod/ConfigFS"); | |
3302 | MODULE_AUTHOR("nab@Linux-iSCSI.org"); | |
3303 | MODULE_LICENSE("GPL"); | |
3304 | ||
3305 | module_init(target_core_init_configfs); | |
3306 | module_exit(target_core_exit_configfs); |