aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_fabric_configfs.c
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-06-08 13:36:43 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:48 -0400
commit6708bb27bb2703da238f21f516034263348af5be (patch)
treea23e1f9eab22933d773d6b6ad6263d6751379a00 /drivers/target/target_core_fabric_configfs.c
parentec98f7825c6eaa4a9afb0eb518826efc8a2ed4a2 (diff)
target: Follow up core updates from AGrover and HCH (round 4)
This patch contains the squashed version of forth round series cleanups from Andy and Christoph following the post heavy lifting in the preceeding: 'Eliminate usage of struct se_mem' and 'Make all control CDBs scatter-gather' changes. This also includes a conversion of target core and the v3.0 mainline fabric modules (loopback and tcm_fc) to use pr_debug and the CONFIG_DYNAMIC_DEBUG infrastructure! These have been squashed into this third and final round for v3.1. target: Remove ifdeffed code in t_g_process_write target: Remove direct ramdisk code target: Rename task_sg_num to task_sg_nents target: Remove custom debug macros for pr_debug. Use pr_err(). target: Remove custom debug macros in mainline fabrics target: Set WSNZ=1 in block limits VPD. Abort if WRITE_SAME sectors = 0 target: Remove transport do_se_mem_map callback target: Further simplify transport_free_pages target: Redo task allocation return value handling target: Remove extra parentheses target: change alloc_task call to take *cdb, not *cmd (nab: Fix bogus struct file assignments in fd_do_readv and fd_do_writev) Signed-off-by: Andy Grover <agrover@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_fabric_configfs.c')
-rw-r--r--drivers/target/target_core_fabric_configfs.c110
1 files changed, 43 insertions, 67 deletions
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 0b1659d0fef..f1654694f4e 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -60,7 +60,7 @@ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf)
60 cit->ct_group_ops = _group_ops; \ 60 cit->ct_group_ops = _group_ops; \
61 cit->ct_attrs = _attrs; \ 61 cit->ct_attrs = _attrs; \
62 cit->ct_owner = tf->tf_module; \ 62 cit->ct_owner = tf->tf_module; \
63 printk("Setup generic %s\n", __stringify(_name)); \ 63 pr_debug("Setup generic %s\n", __stringify(_name)); \
64} 64}
65 65
66/* Start of tfc_tpg_mappedlun_cit */ 66/* Start of tfc_tpg_mappedlun_cit */
@@ -80,8 +80,8 @@ static int target_fabric_mappedlun_link(
80 /* 80 /*
81 * Ensure that the source port exists 81 * Ensure that the source port exists
82 */ 82 */
83 if (!(lun->lun_sep) || !(lun->lun_sep->sep_tpg)) { 83 if (!lun->lun_sep || !lun->lun_sep->sep_tpg) {
84 printk(KERN_ERR "Source se_lun->lun_sep or lun->lun_sep->sep" 84 pr_err("Source se_lun->lun_sep or lun->lun_sep->sep"
85 "_tpg does not exist\n"); 85 "_tpg does not exist\n");
86 return -EINVAL; 86 return -EINVAL;
87 } 87 }
@@ -96,12 +96,12 @@ static int target_fabric_mappedlun_link(
96 * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT 96 * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT
97 */ 97 */
98 if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) { 98 if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) {
99 printk(KERN_ERR "Illegal Initiator ACL SymLink outside of %s\n", 99 pr_err("Illegal Initiator ACL SymLink outside of %s\n",
100 config_item_name(wwn_ci)); 100 config_item_name(wwn_ci));
101 return -EINVAL; 101 return -EINVAL;
102 } 102 }
103 if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) { 103 if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) {
104 printk(KERN_ERR "Illegal Initiator ACL Symlink outside of %s" 104 pr_err("Illegal Initiator ACL Symlink outside of %s"
105 " TPGT: %s\n", config_item_name(wwn_ci), 105 " TPGT: %s\n", config_item_name(wwn_ci),
106 config_item_name(tpg_ci)); 106 config_item_name(tpg_ci));
107 return -EINVAL; 107 return -EINVAL;
@@ -147,7 +147,7 @@ static int target_fabric_mappedlun_unlink(
147 /* 147 /*
148 * Determine if the underlying MappedLUN has already been released.. 148 * Determine if the underlying MappedLUN has already been released..
149 */ 149 */
150 if (!(deve->se_lun)) 150 if (!deve->se_lun)
151 return 0; 151 return 0;
152 152
153 lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group); 153 lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group);
@@ -202,7 +202,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
202 TRANSPORT_LUNFLAGS_READ_WRITE, 202 TRANSPORT_LUNFLAGS_READ_WRITE,
203 lacl->se_lun_nacl); 203 lacl->se_lun_nacl);
204 204
205 printk(KERN_INFO "%s_ConfigFS: Changed Initiator ACL: %s" 205 pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
206 " Mapped LUN: %u Write Protect bit to %s\n", 206 " Mapped LUN: %u Write Protect bit to %s\n",
207 se_tpg->se_tpg_tfo->get_fabric_name(), 207 se_tpg->se_tpg_tfo->get_fabric_name(),
208 lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF"); 208 lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
@@ -327,14 +327,14 @@ static struct config_group *target_fabric_make_mappedlun(
327 int ret = 0; 327 int ret = 0;
328 328
329 acl_ci = &group->cg_item; 329 acl_ci = &group->cg_item;
330 if (!(acl_ci)) { 330 if (!acl_ci) {
331 printk(KERN_ERR "Unable to locatel acl_ci\n"); 331 pr_err("Unable to locatel acl_ci\n");
332 return NULL; 332 return NULL;
333 } 333 }
334 334
335 buf = kzalloc(strlen(name) + 1, GFP_KERNEL); 335 buf = kzalloc(strlen(name) + 1, GFP_KERNEL);
336 if (!(buf)) { 336 if (!buf) {
337 printk(KERN_ERR "Unable to allocate memory for name buf\n"); 337 pr_err("Unable to allocate memory for name buf\n");
338 return ERR_PTR(-ENOMEM); 338 return ERR_PTR(-ENOMEM);
339 } 339 }
340 snprintf(buf, strlen(name) + 1, "%s", name); 340 snprintf(buf, strlen(name) + 1, "%s", name);
@@ -342,7 +342,7 @@ static struct config_group *target_fabric_make_mappedlun(
342 * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID. 342 * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID.
343 */ 343 */
344 if (strstr(buf, "lun_") != buf) { 344 if (strstr(buf, "lun_") != buf) {
345 printk(KERN_ERR "Unable to locate \"lun_\" from buf: %s" 345 pr_err("Unable to locate \"lun_\" from buf: %s"
346 " name: %s\n", buf, name); 346 " name: %s\n", buf, name);
347 ret = -EINVAL; 347 ret = -EINVAL;
348 goto out; 348 goto out;
@@ -358,7 +358,7 @@ static struct config_group *target_fabric_make_mappedlun(
358 358
359 lacl = core_dev_init_initiator_node_lun_acl(se_tpg, mapped_lun, 359 lacl = core_dev_init_initiator_node_lun_acl(se_tpg, mapped_lun,
360 config_item_name(acl_ci), &ret); 360 config_item_name(acl_ci), &ret);
361 if (!(lacl)) { 361 if (!lacl) {
362 ret = -EINVAL; 362 ret = -EINVAL;
363 goto out; 363 goto out;
364 } 364 }
@@ -367,7 +367,7 @@ static struct config_group *target_fabric_make_mappedlun(
367 lacl_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, 367 lacl_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
368 GFP_KERNEL); 368 GFP_KERNEL);
369 if (!lacl_cg->default_groups) { 369 if (!lacl_cg->default_groups) {
370 printk(KERN_ERR "Unable to allocate lacl_cg->default_groups\n"); 370 pr_err("Unable to allocate lacl_cg->default_groups\n");
371 ret = -ENOMEM; 371 ret = -ENOMEM;
372 goto out; 372 goto out;
373 } 373 }
@@ -383,7 +383,7 @@ static struct config_group *target_fabric_make_mappedlun(
383 ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3, 383 ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
384 GFP_KERNEL); 384 GFP_KERNEL);
385 if (!ml_stat_grp->default_groups) { 385 if (!ml_stat_grp->default_groups) {
386 printk(KERN_ERR "Unable to allocate ml_stat_grp->default_groups\n"); 386 pr_err("Unable to allocate ml_stat_grp->default_groups\n");
387 ret = -ENOMEM; 387 ret = -ENOMEM;
388 goto out; 388 goto out;
389 } 389 }
@@ -474,8 +474,8 @@ static struct config_group *target_fabric_make_nodeacl(
474 struct se_node_acl *se_nacl; 474 struct se_node_acl *se_nacl;
475 struct config_group *nacl_cg; 475 struct config_group *nacl_cg;
476 476
477 if (!(tf->tf_ops.fabric_make_nodeacl)) { 477 if (!tf->tf_ops.fabric_make_nodeacl) {
478 printk(KERN_ERR "tf->tf_ops.fabric_make_nodeacl is NULL\n"); 478 pr_err("tf->tf_ops.fabric_make_nodeacl is NULL\n");
479 return ERR_PTR(-ENOSYS); 479 return ERR_PTR(-ENOSYS);
480 } 480 }
481 481
@@ -572,13 +572,13 @@ static struct config_group *target_fabric_make_np(
572 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 572 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
573 struct se_tpg_np *se_tpg_np; 573 struct se_tpg_np *se_tpg_np;
574 574
575 if (!(tf->tf_ops.fabric_make_np)) { 575 if (!tf->tf_ops.fabric_make_np) {
576 printk(KERN_ERR "tf->tf_ops.fabric_make_np is NULL\n"); 576 pr_err("tf->tf_ops.fabric_make_np is NULL\n");
577 return ERR_PTR(-ENOSYS); 577 return ERR_PTR(-ENOSYS);
578 } 578 }
579 579
580 se_tpg_np = tf->tf_ops.fabric_make_np(se_tpg, group, name); 580 se_tpg_np = tf->tf_ops.fabric_make_np(se_tpg, group, name);
581 if (!(se_tpg_np) || IS_ERR(se_tpg_np)) 581 if (!se_tpg_np || IS_ERR(se_tpg_np))
582 return ERR_PTR(-EINVAL); 582 return ERR_PTR(-EINVAL);
583 583
584 se_tpg_np->tpg_np_parent = se_tpg; 584 se_tpg_np->tpg_np_parent = se_tpg;
@@ -627,10 +627,7 @@ static ssize_t target_fabric_port_show_attr_alua_tg_pt_gp(
627 struct se_lun *lun, 627 struct se_lun *lun,
628 char *page) 628 char *page)
629{ 629{
630 if (!(lun)) 630 if (!lun || !lun->lun_sep)
631 return -ENODEV;
632
633 if (!(lun->lun_sep))
634 return -ENODEV; 631 return -ENODEV;
635 632
636 return core_alua_show_tg_pt_gp_info(lun->lun_sep, page); 633 return core_alua_show_tg_pt_gp_info(lun->lun_sep, page);
@@ -641,10 +638,7 @@ static ssize_t target_fabric_port_store_attr_alua_tg_pt_gp(
641 const char *page, 638 const char *page,
642 size_t count) 639 size_t count)
643{ 640{
644 if (!(lun)) 641 if (!lun || !lun->lun_sep)
645 return -ENODEV;
646
647 if (!(lun->lun_sep))
648 return -ENODEV; 642 return -ENODEV;
649 643
650 return core_alua_store_tg_pt_gp_info(lun->lun_sep, page, count); 644 return core_alua_store_tg_pt_gp_info(lun->lun_sep, page, count);
@@ -659,10 +653,7 @@ static ssize_t target_fabric_port_show_attr_alua_tg_pt_offline(
659 struct se_lun *lun, 653 struct se_lun *lun,
660 char *page) 654 char *page)
661{ 655{
662 if (!(lun)) 656 if (!lun || !lun->lun_sep)
663 return -ENODEV;
664
665 if (!(lun->lun_sep))
666 return -ENODEV; 657 return -ENODEV;
667 658
668 return core_alua_show_offline_bit(lun, page); 659 return core_alua_show_offline_bit(lun, page);
@@ -673,10 +664,7 @@ static ssize_t target_fabric_port_store_attr_alua_tg_pt_offline(
673 const char *page, 664 const char *page,
674 size_t count) 665 size_t count)
675{ 666{
676 if (!(lun)) 667 if (!lun || !lun->lun_sep)
677 return -ENODEV;
678
679 if (!(lun->lun_sep))
680 return -ENODEV; 668 return -ENODEV;
681 669
682 return core_alua_store_offline_bit(lun, page, count); 670 return core_alua_store_offline_bit(lun, page, count);
@@ -691,10 +679,7 @@ static ssize_t target_fabric_port_show_attr_alua_tg_pt_status(
691 struct se_lun *lun, 679 struct se_lun *lun,
692 char *page) 680 char *page)
693{ 681{
694 if (!(lun)) 682 if (!lun || !lun->lun_sep)
695 return -ENODEV;
696
697 if (!(lun->lun_sep))
698 return -ENODEV; 683 return -ENODEV;
699 684
700 return core_alua_show_secondary_status(lun, page); 685 return core_alua_show_secondary_status(lun, page);
@@ -705,10 +690,7 @@ static ssize_t target_fabric_port_store_attr_alua_tg_pt_status(
705 const char *page, 690 const char *page,
706 size_t count) 691 size_t count)
707{ 692{
708 if (!(lun)) 693 if (!lun || !lun->lun_sep)
709 return -ENODEV;
710
711 if (!(lun->lun_sep))
712 return -ENODEV; 694 return -ENODEV;
713 695
714 return core_alua_store_secondary_status(lun, page, count); 696 return core_alua_store_secondary_status(lun, page, count);
@@ -723,10 +705,7 @@ static ssize_t target_fabric_port_show_attr_alua_tg_pt_write_md(
723 struct se_lun *lun, 705 struct se_lun *lun,
724 char *page) 706 char *page)
725{ 707{
726 if (!(lun)) 708 if (!lun || !lun->lun_sep)
727 return -ENODEV;
728
729 if (!(lun->lun_sep))
730 return -ENODEV; 709 return -ENODEV;
731 710
732 return core_alua_show_secondary_write_metadata(lun, page); 711 return core_alua_show_secondary_write_metadata(lun, page);
@@ -737,10 +716,7 @@ static ssize_t target_fabric_port_store_attr_alua_tg_pt_write_md(
737 const char *page, 716 const char *page,
738 size_t count) 717 size_t count)
739{ 718{
740 if (!(lun)) 719 if (!lun || !lun->lun_sep)
741 return -ENODEV;
742
743 if (!(lun->lun_sep))
744 return -ENODEV; 720 return -ENODEV;
745 721
746 return core_alua_store_secondary_write_metadata(lun, page, count); 722 return core_alua_store_secondary_write_metadata(lun, page, count);
@@ -781,13 +757,13 @@ static int target_fabric_port_link(
781 tf = se_tpg->se_tpg_wwn->wwn_tf; 757 tf = se_tpg->se_tpg_wwn->wwn_tf;
782 758
783 if (lun->lun_se_dev != NULL) { 759 if (lun->lun_se_dev != NULL) {
784 printk(KERN_ERR "Port Symlink already exists\n"); 760 pr_err("Port Symlink already exists\n");
785 return -EEXIST; 761 return -EEXIST;
786 } 762 }
787 763
788 dev = se_dev->se_dev_ptr; 764 dev = se_dev->se_dev_ptr;
789 if (!(dev)) { 765 if (!dev) {
790 printk(KERN_ERR "Unable to locate struct se_device pointer from" 766 pr_err("Unable to locate struct se_device pointer from"
791 " %s\n", config_item_name(se_dev_ci)); 767 " %s\n", config_item_name(se_dev_ci));
792 ret = -ENODEV; 768 ret = -ENODEV;
793 goto out; 769 goto out;
@@ -795,8 +771,8 @@ static int target_fabric_port_link(
795 771
796 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev, 772 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev,
797 lun->unpacked_lun); 773 lun->unpacked_lun);
798 if ((IS_ERR(lun_p)) || !(lun_p)) { 774 if (IS_ERR(lun_p) || !lun_p) {
799 printk(KERN_ERR "core_dev_add_lun() failed\n"); 775 pr_err("core_dev_add_lun() failed\n");
800 ret = -EINVAL; 776 ret = -EINVAL;
801 goto out; 777 goto out;
802 } 778 }
@@ -888,7 +864,7 @@ static struct config_group *target_fabric_make_lun(
888 int errno; 864 int errno;
889 865
890 if (strstr(name, "lun_") != name) { 866 if (strstr(name, "lun_") != name) {
891 printk(KERN_ERR "Unable to locate \'_\" in" 867 pr_err("Unable to locate \'_\" in"
892 " \"lun_$LUN_NUMBER\"\n"); 868 " \"lun_$LUN_NUMBER\"\n");
893 return ERR_PTR(-EINVAL); 869 return ERR_PTR(-EINVAL);
894 } 870 }
@@ -896,14 +872,14 @@ static struct config_group *target_fabric_make_lun(
896 return ERR_PTR(-EINVAL); 872 return ERR_PTR(-EINVAL);
897 873
898 lun = core_get_lun_from_tpg(se_tpg, unpacked_lun); 874 lun = core_get_lun_from_tpg(se_tpg, unpacked_lun);
899 if (!(lun)) 875 if (!lun)
900 return ERR_PTR(-EINVAL); 876 return ERR_PTR(-EINVAL);
901 877
902 lun_cg = &lun->lun_group; 878 lun_cg = &lun->lun_group;
903 lun_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, 879 lun_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
904 GFP_KERNEL); 880 GFP_KERNEL);
905 if (!lun_cg->default_groups) { 881 if (!lun_cg->default_groups) {
906 printk(KERN_ERR "Unable to allocate lun_cg->default_groups\n"); 882 pr_err("Unable to allocate lun_cg->default_groups\n");
907 return ERR_PTR(-ENOMEM); 883 return ERR_PTR(-ENOMEM);
908 } 884 }
909 885
@@ -918,7 +894,7 @@ static struct config_group *target_fabric_make_lun(
918 port_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3, 894 port_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
919 GFP_KERNEL); 895 GFP_KERNEL);
920 if (!port_stat_grp->default_groups) { 896 if (!port_stat_grp->default_groups) {
921 printk(KERN_ERR "Unable to allocate port_stat_grp->default_groups\n"); 897 pr_err("Unable to allocate port_stat_grp->default_groups\n");
922 errno = -ENOMEM; 898 errno = -ENOMEM;
923 goto out; 899 goto out;
924 } 900 }
@@ -1031,13 +1007,13 @@ static struct config_group *target_fabric_make_tpg(
1031 struct target_fabric_configfs *tf = wwn->wwn_tf; 1007 struct target_fabric_configfs *tf = wwn->wwn_tf;
1032 struct se_portal_group *se_tpg; 1008 struct se_portal_group *se_tpg;
1033 1009
1034 if (!(tf->tf_ops.fabric_make_tpg)) { 1010 if (!tf->tf_ops.fabric_make_tpg) {
1035 printk(KERN_ERR "tf->tf_ops.fabric_make_tpg is NULL\n"); 1011 pr_err("tf->tf_ops.fabric_make_tpg is NULL\n");
1036 return ERR_PTR(-ENOSYS); 1012 return ERR_PTR(-ENOSYS);
1037 } 1013 }
1038 1014
1039 se_tpg = tf->tf_ops.fabric_make_tpg(wwn, group, name); 1015 se_tpg = tf->tf_ops.fabric_make_tpg(wwn, group, name);
1040 if (!(se_tpg) || IS_ERR(se_tpg)) 1016 if (!se_tpg || IS_ERR(se_tpg))
1041 return ERR_PTR(-EINVAL); 1017 return ERR_PTR(-EINVAL);
1042 /* 1018 /*
1043 * Setup default groups from pre-allocated se_tpg->tpg_default_groups 1019 * Setup default groups from pre-allocated se_tpg->tpg_default_groups
@@ -1130,13 +1106,13 @@ static struct config_group *target_fabric_make_wwn(
1130 struct target_fabric_configfs, tf_group); 1106 struct target_fabric_configfs, tf_group);
1131 struct se_wwn *wwn; 1107 struct se_wwn *wwn;
1132 1108
1133 if (!(tf->tf_ops.fabric_make_wwn)) { 1109 if (!tf->tf_ops.fabric_make_wwn) {
1134 printk(KERN_ERR "tf->tf_ops.fabric_make_wwn is NULL\n"); 1110 pr_err("tf->tf_ops.fabric_make_wwn is NULL\n");
1135 return ERR_PTR(-ENOSYS); 1111 return ERR_PTR(-ENOSYS);
1136 } 1112 }
1137 1113
1138 wwn = tf->tf_ops.fabric_make_wwn(tf, group, name); 1114 wwn = tf->tf_ops.fabric_make_wwn(tf, group, name);
1139 if (!(wwn) || IS_ERR(wwn)) 1115 if (!wwn || IS_ERR(wwn))
1140 return ERR_PTR(-EINVAL); 1116 return ERR_PTR(-EINVAL);
1141 1117
1142 wwn->wwn_tf = tf; 1118 wwn->wwn_tf = tf;