diff options
author | Vikas Chaudhary <vikas.chaudhary@qlogic.com> | 2010-07-22 07:27:43 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:06:05 -0400 |
commit | fe4f0bdeea788a8ac049c097895cb2e4044f18b1 (patch) | |
tree | 04e599de27ded09d3f6a57bc8f1d9e8db07a3094 /drivers/scsi | |
parent | caf19d38607108304cd8cc67ed21378017f69e8a (diff) |
[SCSI] iscsi_transport: Modidify recovery_tmo from sysfs
Added support to modify session->recovery_tmo from sysfs
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: Ravi Anand <ravi.anand@qlogic.com>
Acked-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index b9aec304872c..d4b96623aa59 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -1783,14 +1783,42 @@ show_priv_session_##field(struct device *dev, \ | |||
1783 | { \ | 1783 | { \ |
1784 | struct iscsi_cls_session *session = \ | 1784 | struct iscsi_cls_session *session = \ |
1785 | iscsi_dev_to_session(dev->parent); \ | 1785 | iscsi_dev_to_session(dev->parent); \ |
1786 | if (session->field == -1) \ | ||
1787 | return sprintf(buf, "off\n"); \ | ||
1786 | return sprintf(buf, format"\n", session->field); \ | 1788 | return sprintf(buf, format"\n", session->field); \ |
1787 | } | 1789 | } |
1788 | 1790 | ||
1789 | #define iscsi_priv_session_attr(field, format) \ | 1791 | #define iscsi_priv_session_attr_store(field) \ |
1792 | static ssize_t \ | ||
1793 | store_priv_session_##field(struct device *dev, \ | ||
1794 | struct device_attribute *attr, \ | ||
1795 | const char *buf, size_t count) \ | ||
1796 | { \ | ||
1797 | int val; \ | ||
1798 | char *cp; \ | ||
1799 | struct iscsi_cls_session *session = \ | ||
1800 | iscsi_dev_to_session(dev->parent); \ | ||
1801 | if ((session->state == ISCSI_SESSION_FREE) || \ | ||
1802 | (session->state == ISCSI_SESSION_FAILED)) \ | ||
1803 | return -EBUSY; \ | ||
1804 | if (strncmp(buf, "off", 3) == 0) \ | ||
1805 | session->field = -1; \ | ||
1806 | else { \ | ||
1807 | val = simple_strtoul(buf, &cp, 0); \ | ||
1808 | if (*cp != '\0' && *cp != '\n') \ | ||
1809 | return -EINVAL; \ | ||
1810 | session->field = val; \ | ||
1811 | } \ | ||
1812 | return count; \ | ||
1813 | } | ||
1814 | |||
1815 | #define iscsi_priv_session_rw_attr(field, format) \ | ||
1790 | iscsi_priv_session_attr_show(field, format) \ | 1816 | iscsi_priv_session_attr_show(field, format) \ |
1791 | static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO, show_priv_session_##field, \ | 1817 | iscsi_priv_session_attr_store(field) \ |
1792 | NULL) | 1818 | static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUGO, \ |
1793 | iscsi_priv_session_attr(recovery_tmo, "%d"); | 1819 | show_priv_session_##field, \ |
1820 | store_priv_session_##field) | ||
1821 | iscsi_priv_session_rw_attr(recovery_tmo, "%d"); | ||
1794 | 1822 | ||
1795 | /* | 1823 | /* |
1796 | * iSCSI host attrs | 1824 | * iSCSI host attrs |
@@ -1821,6 +1849,11 @@ do { \ | |||
1821 | count++; \ | 1849 | count++; \ |
1822 | } while (0) | 1850 | } while (0) |
1823 | 1851 | ||
1852 | #define SETUP_PRIV_SESSION_RW_ATTR(field) \ | ||
1853 | do { \ | ||
1854 | priv->session_attrs[count] = &dev_attr_priv_sess_##field; \ | ||
1855 | count++; \ | ||
1856 | } while (0) | ||
1824 | 1857 | ||
1825 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ | 1858 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ |
1826 | do { \ | 1859 | do { \ |
@@ -2008,7 +2041,7 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
2008 | SETUP_SESSION_RD_ATTR(ifacename, ISCSI_IFACE_NAME); | 2041 | SETUP_SESSION_RD_ATTR(ifacename, ISCSI_IFACE_NAME); |
2009 | SETUP_SESSION_RD_ATTR(initiatorname, ISCSI_INITIATOR_NAME); | 2042 | SETUP_SESSION_RD_ATTR(initiatorname, ISCSI_INITIATOR_NAME); |
2010 | SETUP_SESSION_RD_ATTR(targetalias, ISCSI_TARGET_ALIAS); | 2043 | SETUP_SESSION_RD_ATTR(targetalias, ISCSI_TARGET_ALIAS); |
2011 | SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo); | 2044 | SETUP_PRIV_SESSION_RW_ATTR(recovery_tmo); |
2012 | SETUP_PRIV_SESSION_RD_ATTR(state); | 2045 | SETUP_PRIV_SESSION_RD_ATTR(state); |
2013 | 2046 | ||
2014 | BUG_ON(count > ISCSI_SESSION_ATTRS); | 2047 | BUG_ON(count > ISCSI_SESSION_ATTRS); |