[SCSI] libiscsi: Added new boot entries in the session sysfs
authorEddie Wai <eddie.wai@broadcom.com>
Thu, 20 Jun 2013 17:21:26 +0000 (10:21 -0700)
committerJames Bottomley <JBottomley@Parallels.com>
Thu, 27 Jun 2013 01:04:11 +0000 (18:04 -0700)
This is the kernel part of the modification to extract the net params
from the ibft sysfs to the iface struct used for the connection
request upon sync_session in the open-iscsi util.

Three new session sysfs params are defined:
boot_root - holds the name of the /sys/firmware/ibft or iscsi_rootN
boot_nic  - holds the ethernetN name
boot_target - holds the targetN name

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/libiscsi.c
drivers/scsi/scsi_transport_iscsi.c
include/scsi/iscsi_if.h
include/scsi/libiscsi.h

index 5de946984500692b51705b9f6a42640b3b456e4c..ae69dfcc7834c51b8d0e57bd9c7db17dd5a7d029 100644 (file)
@@ -2808,6 +2808,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
        kfree(session->targetname);
        kfree(session->targetalias);
        kfree(session->initiatorname);
+       kfree(session->boot_root);
+       kfree(session->boot_nic);
+       kfree(session->boot_target);
        kfree(session->ifacename);
 
        iscsi_destroy_session(cls_session);
@@ -3248,6 +3251,12 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
                return iscsi_switch_str_param(&session->ifacename, buf);
        case ISCSI_PARAM_INITIATOR_NAME:
                return iscsi_switch_str_param(&session->initiatorname, buf);
+       case ISCSI_PARAM_BOOT_ROOT:
+               return iscsi_switch_str_param(&session->boot_root, buf);
+       case ISCSI_PARAM_BOOT_NIC:
+               return iscsi_switch_str_param(&session->boot_nic, buf);
+       case ISCSI_PARAM_BOOT_TARGET:
+               return iscsi_switch_str_param(&session->boot_target, buf);
        default:
                return -ENOSYS;
        }
@@ -3326,6 +3335,15 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
        case ISCSI_PARAM_INITIATOR_NAME:
                len = sprintf(buf, "%s\n", session->initiatorname);
                break;
+       case ISCSI_PARAM_BOOT_ROOT:
+               len = sprintf(buf, "%s\n", session->boot_root);
+               break;
+       case ISCSI_PARAM_BOOT_NIC:
+               len = sprintf(buf, "%s\n", session->boot_nic);
+               break;
+       case ISCSI_PARAM_BOOT_TARGET:
+               len = sprintf(buf, "%s\n", session->boot_target);
+               break;
        default:
                return -ENOSYS;
        }
index 133926b1bb78bc39231260b5359dff3ff9a16bcb..abf7c402e1a51c6125e9bfa2d26d92c4f56856ff 100644 (file)
@@ -3473,6 +3473,9 @@ iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0);
 iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0);
 iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0);
 iscsi_session_attr(targetalias, ISCSI_PARAM_TARGET_ALIAS, 0);
+iscsi_session_attr(boot_root, ISCSI_PARAM_BOOT_ROOT, 0);
+iscsi_session_attr(boot_nic, ISCSI_PARAM_BOOT_NIC, 0);
+iscsi_session_attr(boot_target, ISCSI_PARAM_BOOT_TARGET, 0);
 
 static ssize_t
 show_priv_session_state(struct device *dev, struct device_attribute *attr,
@@ -3568,6 +3571,9 @@ static struct attribute *iscsi_session_attrs[] = {
        &dev_attr_sess_ifacename.attr,
        &dev_attr_sess_initiatorname.attr,
        &dev_attr_sess_targetalias.attr,
+       &dev_attr_sess_boot_root.attr,
+       &dev_attr_sess_boot_nic.attr,
+       &dev_attr_sess_boot_target.attr,
        &dev_attr_priv_sess_recovery_tmo.attr,
        &dev_attr_priv_sess_state.attr,
        &dev_attr_priv_sess_creator.attr,
@@ -3631,6 +3637,12 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
                param = ISCSI_PARAM_INITIATOR_NAME;
        else if (attr == &dev_attr_sess_targetalias.attr)
                param = ISCSI_PARAM_TARGET_ALIAS;
+       else if (attr == &dev_attr_sess_boot_root.attr)
+               param = ISCSI_PARAM_BOOT_ROOT;
+       else if (attr == &dev_attr_sess_boot_nic.attr)
+               param = ISCSI_PARAM_BOOT_NIC;
+       else if (attr == &dev_attr_sess_boot_target.attr)
+               param = ISCSI_PARAM_BOOT_TARGET;
        else if (attr == &dev_attr_priv_sess_recovery_tmo.attr)
                return S_IRUGO | S_IWUSR;
        else if (attr == &dev_attr_priv_sess_state.attr)
index fe7f06c86f68367ab07ec64b381568f9ea588332..9d28ded2a3f4e20b92a650cbcf69032b61575122 100644 (file)
@@ -489,6 +489,11 @@ enum iscsi_param {
 
        ISCSI_PARAM_CHAP_IN_IDX,
        ISCSI_PARAM_CHAP_OUT_IDX,
+
+       ISCSI_PARAM_BOOT_ROOT,
+       ISCSI_PARAM_BOOT_NIC,
+       ISCSI_PARAM_BOOT_TARGET,
+
        /* must always be last */
        ISCSI_PARAM_MAX,
 };
index 09c041e6c35f16c1f43111db006c5b1199c33d44..4265a4bb83cd759ea79c50dbb1d36414b307f758 100644 (file)
@@ -287,6 +287,10 @@ struct iscsi_session {
        char                    *targetalias;
        char                    *ifacename;
        char                    *initiatorname;
+       char                    *boot_root;
+       char                    *boot_nic;
+       char                    *boot_target;
+
        /* control data */
        struct iscsi_transport  *tt;
        struct Scsi_Host        *host;