- Fixes 2 shutdown problems
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 2 Oct 2007 15:04:04 +0000 (15:04 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 2 Oct 2007 15:04:04 +0000 (15:04 +0000)
 - Cosmetics

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@204 d57e44dd-8a1f-0410-8b47-8ef2f437770f

iscsi-scst/kernel/iscsi.c
iscsi-scst/kernel/nthread.c
iscsi-scst/kernel/param.c
iscsi-scst/kernel/target.c
iscsi-scst/usr/iscsi_scstd.c
iscsi-scst/usr/iscsid.h
iscsi-scst/usr/log.c
scst/README
scst/src/scst_main.c
scst/src/scst_targ.c

index 3a94d2d..5908d9d 100644 (file)
@@ -2541,7 +2541,6 @@ static void __exit iscsi_exit(void)
 #endif
 }
 
-
 module_init(iscsi_init);
 module_exit(iscsi_exit);
 
index 74def7c..a0211ca 100644 (file)
@@ -172,15 +172,15 @@ static void close_conn(struct iscsi_conn *conn)
                msleep(50);
        }
 
+       TRACE_CONN_CLOSE("Notifying user space about closing conn %p", conn);
+       event_send(target->tid, session->sid, conn->cid, E_CONN_CLOSE, 0);
+
        mutex_lock(&target->target_mutex);
        conn_free(conn);
        if (list_empty(&session->conn_list))
                session_del(target, session->sid);
        mutex_unlock(&target->target_mutex);
 
-       TRACE_CONN_CLOSE("Notifying user space about closing conn %p", conn);
-       event_send(target->tid, session->sid, conn->cid, E_CONN_CLOSE, 0);
-
        TRACE_EXIT();
        return;
 }
index aeef10a..15cb47a 100644 (file)
@@ -186,8 +186,13 @@ static void trgt_param_get(struct iscsi_trgt_param *param, struct iscsi_param_in
 static int trgt_param(struct iscsi_target *target, struct iscsi_param_info *info, int set)
 {
        if (set) {
+               struct iscsi_trgt_param *prm;
                trgt_param_check(info);
                trgt_param_set(target, info);
+
+               prm = &target->trgt_param;
+               PRINT_INFO_PR("Target parameter changed: queued_cmnds %d",
+                       prm->queued_cmnds);
        } else
                trgt_param_get(&target->trgt_param, info);
 
index 7117c05..c0ac29a 100644 (file)
@@ -229,26 +229,28 @@ void target_del_all(void)
                        struct iscsi_session *session, *ts;
                        mutex_lock(&target->target_mutex);
                        if (!list_empty(&target->session_list)) {
-                               TRACE_DBG("target %p", target);
+                               TRACE_MGMT_DBG("Cleaning up target %p", target);
                                list_for_each_entry_safe(session, ts, &target->session_list,
                                                session_list_entry) {
-                                       TRACE_DBG("session %p", session);
+                                       TRACE_MGMT_DBG("Cleaning up session %p", session);
                                        if (!list_empty(&session->conn_list)) {
                                                struct iscsi_conn *conn, *tc;
                                                list_for_each_entry_safe(conn, tc,
                                                                &session->conn_list,
                                                                conn_list_entry) {
-                                                       TRACE_DBG("conn %p", conn);
+                                                       TRACE_MGMT_DBG("Mark conn %p "
+                                                               "closing", conn);
                                                        mark_conn_closed(conn);
                                                }
                                        } else {
-                                               TRACE_DBG("session %p with empty "
-                                                       "connection list", session);
+                                               TRACE_MGMT_DBG("Freeing session %p "
+                                                       "without connections", session);
+                                               session_del(target, session->sid);
                                        }
                                }
                                mutex_unlock(&target->target_mutex);
                        } else {
-                               TRACE_DBG("deleting target %p", target);
+                               TRACE_MGMT_DBG("Deleting target %p", target);
                                list_del(&target->target_list_entry);
                                nr_targets--;
                                mutex_unlock(&target->target_mutex);
index 2ad5851..555c5d5 100644 (file)
@@ -209,6 +209,20 @@ static void accept_connection(int listen)
                return;
        }
 
+       if (from.ss_family == AF_INET) {
+               struct sockaddr_in *in = (struct sockaddr_in *)&from;
+               log_info("Connect from %s:%hd", inet_ntoa(in->sin_addr),
+                       ntohs(in->sin_port));
+       } else if (from.ss_family == AF_INET6) {
+               struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&from;
+               log_info("Connect from %x:%x:%x:%x:%x:%x:%x:%x.%hd",
+                       in6->sin6_addr.s6_addr16[7], in6->sin6_addr.s6_addr16[6],
+                       in6->sin6_addr.s6_addr16[5], in6->sin6_addr.s6_addr16[4],
+                       in6->sin6_addr.s6_addr16[3], in6->sin6_addr.s6_addr16[2],
+                       in6->sin6_addr.s6_addr16[1], in6->sin6_addr.s6_addr16[0],
+                        ntohs(in6->sin6_port));
+       }
+
        if (conn_blocked) {
                log_warning("A connection refused\n");
                close(fd);
index 01b63a2..13bcb74 100644 (file)
@@ -181,6 +181,8 @@ extern int log_daemon;
 extern int log_level;
 
 extern void log_init(void);
+extern void log_info(const char *fmt, ...)
+       __attribute__ ((format (printf, 1, 2)));
 extern void log_warning(const char *fmt, ...)
        __attribute__ ((format (printf, 1, 2)));
 extern void log_error(const char *fmt, ...)
index 7b084eb..dd6cefd 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <syslog.h>
 #include <sys/time.h>
+#include <string.h>
 
 #include "iscsid.h"
 
@@ -33,9 +34,15 @@ void log_init(void)
 
 static void dolog(int prio, const char *fmt, va_list ap)
 {
-       if (log_daemon)
-               vsyslog(prio, fmt, ap);
-       else {
+       if (log_daemon) {
+               int len = strlen(fmt);
+               char f[len+1+1];
+               if (fmt[len] != '\n')
+                       sprintf(f, "%s\n", fmt);
+               else
+                       sprintf(f, "%s", fmt);
+               vsyslog(prio, f, ap);
+       } else {
                struct timeval time;
 
                gettimeofday(&time, NULL);
@@ -46,6 +53,14 @@ static void dolog(int prio, const char *fmt, va_list ap)
        }
 }
 
+void log_info(const char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       dolog(LOG_INFO, fmt, ap);
+       va_end(ap);
+}
+
 void log_warning(const char *fmt, ...)
 {
        va_list ap;
index 6c3cbf8..5ca22ca 100644 (file)
@@ -587,7 +587,7 @@ set the above options using debug2perf script file.
  - You may need to increase amount of requests that OS on initiator
    sends to the target device. To do it on Linux initiators, run
 
-   echo “512” > /sys/block/sdX/queue/nr_requests
+   echo “64” > /sys/block/sdX/queue/nr_requests
 
    where X is a device letter like above.
 
index bfcd141..a00877f 100644 (file)
@@ -325,8 +325,8 @@ struct scst_tgt *scst_register(struct scst_tgt_template *vtt,
        mutex_unlock(&scst_mutex);
        scst_resume_activity();
 
-       PRINT_INFO_PR("Target %s for template %s registered successfully",
-               target_name, vtt->name);
+       PRINT_INFO_PR("Target %s (%p) for template %s registered successfully",
+               target_name, tgt, vtt->name);
 
 out:
        TRACE_EXIT();
@@ -344,7 +344,8 @@ out_free_err:
        tgt = NULL;
 
 out_err:
-       PRINT_ERROR_PR("Failed to register target for template %s", vtt->name);
+       PRINT_ERROR_PR("Failed to register target %s for template %s",
+               target_name, vtt->name);
        goto out;
 }
 
@@ -393,10 +394,10 @@ void scst_unregister(struct scst_tgt *tgt)
 
        del_timer_sync(&tgt->retry_timer);
 
-       kfree(tgt);
+       PRINT_INFO_PR("Target %p for template %s unregistered successfully",
+               tgt, vtt->name);
 
-       PRINT_INFO_PR("Target for template %s unregistered successfully",
-               vtt->name);
+       kfree(tgt);
 
        TRACE_EXIT();
        return;
@@ -445,8 +446,8 @@ void scst_resume_activity(void)
 
        mutex_lock(&scst_suspend_mutex);
 
-       TRACE_MGMT_DBG("suspend_count %d", suspend_count);
        suspend_count--;
+       TRACE_MGMT_DBG("suspend_count %d left", suspend_count);
        if (suspend_count > 0)
                goto out_up;
 
index b77d01c..e5d945f 100644 (file)
@@ -4164,7 +4164,7 @@ static int scst_init_session(struct scst_session *sess)
                acg->acg_name, sess->initiator_name);
 
        sess->acg = acg;
-       TRACE_DBG("Assigning session %p to acg %s", sess, acg->acg_name);
+       TRACE_MGMT_DBG("Assigning session %p to acg %s", sess, acg->acg_name);
        list_add_tail(&sess->acg_sess_list_entry, &acg->acg_sess_list);
 
        TRACE_DBG("Adding sess %p to tgt->sess_list", sess);
@@ -4292,6 +4292,8 @@ void scst_unregister_session(struct scst_session *sess, int wait,
 
        TRACE_ENTRY();
 
+       TRACE_MGMT_DBG("Unregistering session %p (wait %d)", sess, wait);
+
 #ifdef CONFIG_LOCKDEP
        pc = sess->shutdown_compl;
 #else