summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Christie <michael.christie@oracle.com>2022-02-27 00:54:02 -0600
committerMike Christie <michael.christie@oracle.com>2022-02-27 00:58:40 -0600
commita7191212659055ac727d51b9131d146e4aa921c5 (patch)
treebb14b839a0acbd8c68488adc68a4eee329a7d446
parented47bdfc4e938573211399fbb9a8b739c371c700 (diff)
downloadopen-iscsi-a7191212659055ac727d51b9131d146e4aa921c5.tar.gz
iscsi sysfs: add helpers to get conn state and cleanup state
Add some helpers to get the conn state and test if the connection has sent a conn error and needs to be cleaned up. Signed-off-by: Mike Christie <michael.christie@oracle.com>
-rw-r--r--usr/iscsi_sysfs.c25
-rw-r--r--usr/iscsi_sysfs.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 9a591be..c8f6df2 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -1582,6 +1582,17 @@ int iscsi_sysfs_get_session_state(char *state, int sid)
return 0;
}
+int iscsi_sysfs_get_conn_state(char *state, int sid)
+{
+ char id[NAME_SIZE];
+
+ snprintf(id, sizeof(id), ISCSI_CONN_ID, sid);
+ if (sysfs_get_str(id, ISCSI_CONN_SUBSYS, "state", state,
+ SCSI_MAX_STATE_VALUE))
+ return ISCSI_ERR_SYSFS_LOOKUP;
+ return 0;
+}
+
int iscsi_sysfs_get_host_state(char *state, int host_no)
{
char id[NAME_SIZE];
@@ -1848,6 +1859,20 @@ int iscsi_sysfs_get_exp_statsn(int sid)
return exp_statsn;
}
+int iscsi_sysfs_conn_needs_cleanup(int sid)
+{
+ char id[NAME_SIZE];
+ int needs_cleanup;
+
+ snprintf(id, sizeof(id), ISCSI_CONN_ID, sid);
+
+ if (sysfs_get_int(id, ISCSI_CONN_SUBSYS, "needs_cleanup",
+ &needs_cleanup))
+ return -1;
+
+ return needs_cleanup;
+}
+
int iscsi_sysfs_session_supports_nop(int sid)
{
char id[NAME_SIZE];
diff --git a/usr/iscsi_sysfs.h b/usr/iscsi_sysfs.h
index 9575c65..f9ae658 100644
--- a/usr/iscsi_sysfs.h
+++ b/usr/iscsi_sysfs.h
@@ -91,9 +91,11 @@ extern void iscsi_sysfs_get_negotiated_conn_conf(int sid,
struct iscsi_conn_operational_config *conf);
extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan);
extern int iscsi_sysfs_get_session_state(char *state, int sid);
+extern int iscsi_sysfs_get_conn_state(char *state, int sid);
extern int iscsi_sysfs_get_host_state(char *state, int host_no);
extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target,
int lun);
+extern int iscsi_sysfs_conn_needs_cleanup(int sid);
extern int iscsi_sysfs_get_exp_statsn(int sid);
extern void iscsi_sysfs_set_queue_depth(void *data, int hostno, int target,
int lun);