Search
j0ke.net Open Build Service
>
Projects
>
ha
:
rebuilds
>
iscsi-initiator-utils
> iscsi-initiator-utils-Fix-connection-cleanup-when-iscsid-is-restarted.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File iscsi-initiator-utils-Fix-connection-cleanup-when-iscsid-is-restarted.patch of Package iscsi-initiator-utils
diff -aurp open-iscsi-2.0-868-test1/usr/initiator.c open-iscsi-2.0-868-test1.work/usr/initiator.c --- open-iscsi-2.0-868-test1/usr/initiator.c 2008-03-03 09:36:11.000000000 -0600 +++ open-iscsi-2.0-868-test1.work/usr/initiator.c 2008-03-03 09:39:17.000000000 -0600 @@ -602,7 +602,10 @@ session_conn_shutdown(iscsi_conn_t *conn { iscsi_session_t *session = conn->session; - if (!conn->ksetup) + if (session->id == -1) + goto disconnect_conn; + + if (!sysfs_session_has_leadconn(session->id)) goto disconnect_conn; if (conn->state == STATE_IN_LOGIN || @@ -623,7 +626,6 @@ session_conn_shutdown(iscsi_conn_t *conn log_error("can not safely destroy connection %d", conn->id); return MGMT_IPC_ERR_INTERNAL; } - conn->ksetup = 0; disconnect_conn: log_debug(2, "disconnect conn"); @@ -1720,7 +1722,6 @@ static void session_conn_poll(void *data err = MGMT_IPC_ERR_INTERNAL; goto cleanup; } - conn->ksetup = 1; log_debug(3, "created new iSCSI connection " "%d:%d", session->id, conn->id); } diff -aurp open-iscsi-2.0-868-test1/usr/initiator.h open-iscsi-2.0-868-test1.work/usr/initiator.h --- open-iscsi-2.0-868-test1/usr/initiator.h 2008-03-03 09:36:11.000000000 -0600 +++ open-iscsi-2.0-868-test1.work/usr/initiator.h 2008-03-03 09:39:17.000000000 -0600 @@ -116,7 +116,6 @@ struct iscsi_conn_context; /* daemon's connection structure */ typedef struct iscsi_conn { uint32_t id; - int ksetup; struct iscsi_session *session; iscsi_login_context_t login_context; struct iscsi_conn_context *recv_context; diff -aurp open-iscsi-2.0-868-test1/usr/iscsi_sysfs.c open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.c --- open-iscsi-2.0-868-test1/usr/iscsi_sysfs.c 2008-03-03 09:36:11.000000000 -0600 +++ open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.c 2008-03-03 09:39:17.000000000 -0600 @@ -38,6 +38,12 @@ #define ISCSI_MAX_SYSFS_BUFFER NI_MAXHOST +/* + * TODO: make this into a real API and check inputs better and add doc. + * We should also use a common lib and search sysfs according to the sysfs + * doc in the kernel documetnation. + */ + /* tmp buffer used by sysfs functions */ static char sysfs_file[PATH_MAX]; int num_transports = 0; @@ -439,6 +445,24 @@ free_info: return rc; } +/** + * sysfs_session_has_leadconn - checks if session has lead conn in kernel + * @sid: session id + * + * return 1 if session has lead conn and 0 if not. + */ +int sysfs_session_has_leadconn(uint32_t sid) +{ + struct stat statb; + + memset(sysfs_file, 0, PATH_MAX); + sprintf(sysfs_file, ISCSI_CONN_DIR"/connection%u:0", sid); + if (!stat(sysfs_file, &statb)) + return 1; + else + return 0; +} + int get_sessioninfo_by_sysfs_id(struct session_info *info, char *session) { int ret, pers_failed = 0; diff -aurp open-iscsi-2.0-868-test1/usr/iscsi_sysfs.h open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.h --- open-iscsi-2.0-868-test1/usr/iscsi_sysfs.h 2008-03-03 09:36:11.000000000 -0600 +++ open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.h 2008-03-03 09:39:17.000000000 -0600 @@ -53,6 +53,7 @@ extern int get_iscsi_kernel_version(char extern int check_class_version(void); extern int get_sessioninfo_by_sysfs_id(struct session_info *info, char *sys_session); +extern int sysfs_session_has_leadconn(uint32_t sid); typedef int (sysfs_session_op_fn)(void *, struct session_info *); typedef int (sysfs_host_op_fn)(void *, struct host_info *);