You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

82 lines
2.4 KiB

From 006270c0f9a1fa1e78574a7eaa04bb9ae1ef62b6 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Thu, 12 Feb 2015 16:38:00 -0800
Subject: [PATCH] iscsid: don't re-read config file for every session logout
Follow up to the safe_logout feature patch.
Cache the safe_logout setting when iscsid is started.
Signed-off-by: Chris Leech <cleech@redhat.com>
---
usr/initiator.c | 6 +-----
usr/iscsid.c | 6 ++++++
usr/iscsid.h | 1 +
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/usr/initiator.c b/usr/initiator.c
index 2f17882..b25ded8 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -2333,7 +2333,6 @@ int session_logout_task(int sid, queue_task_t *qtask)
iscsi_session_t *session;
iscsi_conn_t *conn;
int rc = ISCSI_SUCCESS;
- char *safe;
session = session_find_by_sid(sid);
if (!session) {
@@ -2356,14 +2355,11 @@ invalid_state:
return ISCSI_ERR_INTERNAL;
}
- safe = cfg_get_string_param(dconfig->config_file, "iscsid.safe_logout");
- if (safe && !strcmp(safe, "Yes") && session_in_use(sid)) {
+ if (dconfig->safe_logout && session_in_use(sid)) {
log_error("Session is actively in use for mounted storage, "
"and iscsid.safe_logout is configured.\n");
- free(safe);
return ISCSI_ERR_BUSY;
}
- free(safe);
/* FIXME: logout all active connections */
conn = &session->conn[0];
diff --git a/usr/iscsid.c b/usr/iscsid.c
index f4f4f38..033a71f 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -341,6 +341,7 @@ int main(int argc, char *argv[])
char *config_file = CONFIG_FILE;
char *initiatorname_file = INITIATOR_NAME_FILE;
char *pid_file = PID_FILE;
+ char *safe_logout;
int ch, longindex;
uid_t uid = 0;
struct sigaction sa_old;
@@ -520,6 +521,11 @@ int main(int argc, char *argv[])
daemon_config.initiator_name : "NOT SET");
log_debug(1, "InitiatorAlias=%s", daemon_config.initiator_alias);
+ safe_logout = cfg_get_string_param(config_file, "iscsid.safe_logout");
+ if (safe_logout && !strcmp(safe_logout, "Yes"))
+ daemon_config.safe_logout = 1;
+ free(safe_logout);
+
pid = fork();
if (pid == 0) {
int nr_found = 0;
diff --git a/usr/iscsid.h b/usr/iscsid.h
index 15f264f..b9f3d54 100644
--- a/usr/iscsid.h
+++ b/usr/iscsid.h
@@ -29,6 +29,7 @@ struct iscsi_daemon_config {
char *pid_file;
char *initiator_name;
char *initiator_alias;
+ int safe_logout;
};
extern struct iscsi_daemon_config *dconfig;
--
2.1.0