summaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 13:22:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 13:22:09 -0400
commitc6668726d2c2c581e6c417448c472c994d026f5f (patch)
treeccbc5a73b9dfe09a065cb5d8627aa2297e730ec0 /drivers/vhost
parent06b45f2aa703837163496f5db6a53575665cc6b4 (diff)
parent68d4cef3bab3fb9bb0dbac690ba35a96cb5a16d9 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "Lots of activity in target land the last months. The highlights include: - Convert fabric drivers tree-wide to target_register_template() (hch + bart) - iser-target hardening fixes + v1.0 improvements (sagi) - Convert iscsi_thread_set usage to kthread.h + kill iscsi_target_tq.c (sagi + nab) - Add support for T10-PI WRITE_STRIP + READ_INSERT operation (mkp + sagi + nab) - DIF fixes for CONFIG_DEBUG_SG=y + UNMAP file emulation (akinobu + sagi + mkp) - Extended TCMU ABI v2 for future BIDI + DIF support (andy + ilias) - Fix COMPARE_AND_WRITE handling for NO_ALLLOC drivers (hch + nab) Thanks to everyone who contributed this round with new features, bug-reports, fixes, cleanups and improvements. Looking forward, it's currently shaping up to be a busy v4.2 as well" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (69 commits) target: Put TCMU under a new config option target: Version 2 of TCMU ABI target: fix tcm_mod_builder.py target/file: Fix UNMAP with DIF protection support target/file: Fix SG table for prot_buf initialization target/file: Fix BUG() when CONFIG_DEBUG_SG=y and DIF protection enabled target: Make core_tmr_abort_task() skip TMFs target/sbc: Update sbc_dif_generate pr_debug output target/sbc: Make internal DIF emulation honor ->prot_checks target/sbc: Return INVALID_CDB_FIELD if DIF + sess_prot_type disabled target: Ensure sess_prot_type is saved across session restart target/rd: Don't pass incomplete scatterlist entries to sbc_dif_verify_* target: Remove the unused flag SCF_ACK_KREF target: Fix two sparse warnings target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling target: simplify the target template registration API target: simplify target_xcopy_init_pt_lun target: remove the unused SCF_CMD_XCOPY_PASSTHROUGH flag target/rd: reduce code duplication in rd_execute_rw() tcm_loop: fixup tpgt string to integer conversion ...
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/scsi.c126
1 files changed, 63 insertions, 63 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 71df240a467a..5e19bb53b3a9 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -131,6 +131,8 @@ struct vhost_scsi_tpg {
131 int tv_tpg_port_count; 131 int tv_tpg_port_count;
132 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */ 132 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
133 int tv_tpg_vhost_count; 133 int tv_tpg_vhost_count;
134 /* Used for enabling T10-PI with legacy devices */
135 int tv_fabric_prot_type;
134 /* list for vhost_scsi_list */ 136 /* list for vhost_scsi_list */
135 struct list_head tv_tpg_list; 137 struct list_head tv_tpg_list;
136 /* Used to protect access for tpg_nexus */ 138 /* Used to protect access for tpg_nexus */
@@ -214,9 +216,7 @@ struct vhost_scsi {
214 int vs_events_nr; /* num of pending events, protected by vq->mutex */ 216 int vs_events_nr; /* num of pending events, protected by vq->mutex */
215}; 217};
216 218
217/* Local pointer to allocated TCM configfs fabric module */ 219static struct target_core_fabric_ops vhost_scsi_ops;
218static struct target_fabric_configfs *vhost_scsi_fabric_configfs;
219
220static struct workqueue_struct *vhost_scsi_workqueue; 220static struct workqueue_struct *vhost_scsi_workqueue;
221 221
222/* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */ 222/* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */
@@ -431,6 +431,14 @@ vhost_scsi_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
431 port_nexus_ptr); 431 port_nexus_ptr);
432} 432}
433 433
434static int vhost_scsi_check_prot_fabric_only(struct se_portal_group *se_tpg)
435{
436 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
437 struct vhost_scsi_tpg, se_tpg);
438
439 return tpg->tv_fabric_prot_type;
440}
441
434static struct se_node_acl * 442static struct se_node_acl *
435vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg) 443vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg)
436{ 444{
@@ -1878,6 +1886,45 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus,
1878 } 1886 }
1879} 1887}
1880 1888
1889static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type(
1890 struct se_portal_group *se_tpg,
1891 const char *page,
1892 size_t count)
1893{
1894 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
1895 struct vhost_scsi_tpg, se_tpg);
1896 unsigned long val;
1897 int ret = kstrtoul(page, 0, &val);
1898
1899 if (ret) {
1900 pr_err("kstrtoul() returned %d for fabric_prot_type\n", ret);
1901 return ret;
1902 }
1903 if (val != 0 && val != 1 && val != 3) {
1904 pr_err("Invalid vhost_scsi fabric_prot_type: %lu\n", val);
1905 return -EINVAL;
1906 }
1907 tpg->tv_fabric_prot_type = val;
1908
1909 return count;
1910}
1911
1912static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type(
1913 struct se_portal_group *se_tpg,
1914 char *page)
1915{
1916 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
1917 struct vhost_scsi_tpg, se_tpg);
1918
1919 return sprintf(page, "%d\n", tpg->tv_fabric_prot_type);
1920}
1921TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR);
1922
1923static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = {
1924 &vhost_scsi_tpg_attrib_fabric_prot_type.attr,
1925 NULL,
1926};
1927
1881static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, 1928static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
1882 const char *name) 1929 const char *name)
1883{ 1930{
@@ -2155,7 +2202,7 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
2155 tpg->tport = tport; 2202 tpg->tport = tport;
2156 tpg->tport_tpgt = tpgt; 2203 tpg->tport_tpgt = tpgt;
2157 2204
2158 ret = core_tpg_register(&vhost_scsi_fabric_configfs->tf_ops, wwn, 2205 ret = core_tpg_register(&vhost_scsi_ops, wwn,
2159 &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL); 2206 &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
2160 if (ret < 0) { 2207 if (ret < 0) {
2161 kfree(tpg); 2208 kfree(tpg);
@@ -2277,6 +2324,8 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
2277}; 2324};
2278 2325
2279static struct target_core_fabric_ops vhost_scsi_ops = { 2326static struct target_core_fabric_ops vhost_scsi_ops = {
2327 .module = THIS_MODULE,
2328 .name = "vhost",
2280 .get_fabric_name = vhost_scsi_get_fabric_name, 2329 .get_fabric_name = vhost_scsi_get_fabric_name,
2281 .get_fabric_proto_ident = vhost_scsi_get_fabric_proto_ident, 2330 .get_fabric_proto_ident = vhost_scsi_get_fabric_proto_ident,
2282 .tpg_get_wwn = vhost_scsi_get_fabric_wwn, 2331 .tpg_get_wwn = vhost_scsi_get_fabric_wwn,
@@ -2289,6 +2338,7 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
2289 .tpg_check_demo_mode_cache = vhost_scsi_check_true, 2338 .tpg_check_demo_mode_cache = vhost_scsi_check_true,
2290 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false, 2339 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
2291 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false, 2340 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
2341 .tpg_check_prot_fabric_only = vhost_scsi_check_prot_fabric_only,
2292 .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl, 2342 .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl,
2293 .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl, 2343 .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl,
2294 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index, 2344 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index,
@@ -2320,70 +2370,20 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
2320 .fabric_drop_np = NULL, 2370 .fabric_drop_np = NULL,
2321 .fabric_make_nodeacl = vhost_scsi_make_nodeacl, 2371 .fabric_make_nodeacl = vhost_scsi_make_nodeacl,
2322 .fabric_drop_nodeacl = vhost_scsi_drop_nodeacl, 2372 .fabric_drop_nodeacl = vhost_scsi_drop_nodeacl,
2373
2374 .tfc_wwn_attrs = vhost_scsi_wwn_attrs,
2375 .tfc_tpg_base_attrs = vhost_scsi_tpg_attrs,
2376 .tfc_tpg_attrib_attrs = vhost_scsi_tpg_attrib_attrs,
2323}; 2377};
2324 2378
2325static int vhost_scsi_register_configfs(void) 2379static int __init vhost_scsi_init(void)
2326{ 2380{
2327 struct target_fabric_configfs *fabric; 2381 int ret = -ENOMEM;
2328 int ret;
2329 2382
2330 pr_debug("vhost-scsi fabric module %s on %s/%s" 2383 pr_debug("TCM_VHOST fabric module %s on %s/%s"
2331 " on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname, 2384 " on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
2332 utsname()->machine); 2385 utsname()->machine);
2333 /*
2334 * Register the top level struct config_item_type with TCM core
2335 */
2336 fabric = target_fabric_configfs_init(THIS_MODULE, "vhost");
2337 if (IS_ERR(fabric)) {
2338 pr_err("target_fabric_configfs_init() failed\n");
2339 return PTR_ERR(fabric);
2340 }
2341 /*
2342 * Setup fabric->tf_ops from our local vhost_scsi_ops
2343 */
2344 fabric->tf_ops = vhost_scsi_ops;
2345 /*
2346 * Setup default attribute lists for various fabric->tf_cit_tmpl
2347 */
2348 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = vhost_scsi_wwn_attrs;
2349 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = vhost_scsi_tpg_attrs;
2350 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
2351 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
2352 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
2353 fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;
2354 fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;
2355 fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;
2356 fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;
2357 /*
2358 * Register the fabric for use within TCM
2359 */
2360 ret = target_fabric_configfs_register(fabric);
2361 if (ret < 0) {
2362 pr_err("target_fabric_configfs_register() failed"
2363 " for TCM_VHOST\n");
2364 return ret;
2365 }
2366 /*
2367 * Setup our local pointer to *fabric
2368 */
2369 vhost_scsi_fabric_configfs = fabric;
2370 pr_debug("TCM_VHOST[0] - Set fabric -> vhost_scsi_fabric_configfs\n");
2371 return 0;
2372};
2373
2374static void vhost_scsi_deregister_configfs(void)
2375{
2376 if (!vhost_scsi_fabric_configfs)
2377 return;
2378
2379 target_fabric_configfs_deregister(vhost_scsi_fabric_configfs);
2380 vhost_scsi_fabric_configfs = NULL;
2381 pr_debug("TCM_VHOST[0] - Cleared vhost_scsi_fabric_configfs\n");
2382};
2383 2386
2384static int __init vhost_scsi_init(void)
2385{
2386 int ret = -ENOMEM;
2387 /* 2387 /*
2388 * Use our own dedicated workqueue for submitting I/O into 2388 * Use our own dedicated workqueue for submitting I/O into
2389 * target core to avoid contention within system_wq. 2389 * target core to avoid contention within system_wq.
@@ -2396,7 +2396,7 @@ static int __init vhost_scsi_init(void)
2396 if (ret < 0) 2396 if (ret < 0)
2397 goto out_destroy_workqueue; 2397 goto out_destroy_workqueue;
2398 2398
2399 ret = vhost_scsi_register_configfs(); 2399 ret = target_register_template(&vhost_scsi_ops);
2400 if (ret < 0) 2400 if (ret < 0)
2401 goto out_vhost_scsi_deregister; 2401 goto out_vhost_scsi_deregister;
2402 2402
@@ -2412,7 +2412,7 @@ out:
2412 2412
2413static void vhost_scsi_exit(void) 2413static void vhost_scsi_exit(void)
2414{ 2414{
2415 vhost_scsi_deregister_configfs(); 2415 target_unregister_template(&vhost_scsi_ops);
2416 vhost_scsi_deregister(); 2416 vhost_scsi_deregister();
2417 destroy_workqueue(vhost_scsi_workqueue); 2417 destroy_workqueue(vhost_scsi_workqueue);
2418}; 2418};