Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/iscsi Don't use common variables, also prefix global...



details:   https://anonhg.NetBSD.org/src/rev/f3d42b36d663
branches:  trunk
changeset: 780935:f3d42b36d663
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Aug 12 13:26:18 2012 +0000

description:
Don't use common variables, also prefix global variables to avoid
namespace pollution.

diffstat:

 sys/dev/iscsi/iscsi_globals.h |  26 ++++++++++------------
 sys/dev/iscsi/iscsi_ioctl.c   |  50 +++++++++++++++++++++---------------------
 sys/dev/iscsi/iscsi_main.c    |  43 ++++++++++++++++++------------------
 sys/dev/iscsi/iscsi_send.c    |  12 +++++-----
 sys/dev/iscsi/iscsi_text.c    |  12 +++++-----
 5 files changed, 71 insertions(+), 72 deletions(-)

diffs (truncated from 382 to 300 lines):

diff -r a57c70929095 -r f3d42b36d663 sys/dev/iscsi/iscsi_globals.h
--- a/sys/dev/iscsi/iscsi_globals.h     Sun Aug 12 12:43:49 2012 +0000
+++ b/sys/dev/iscsi/iscsi_globals.h     Sun Aug 12 13:26:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_globals.h,v 1.4 2012/06/09 06:19:58 mlelstv Exp $        */
+/*     $NetBSD: iscsi_globals.h,v 1.5 2012/08/12 13:26:18 mlelstv Exp $        */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -539,21 +539,19 @@
 
 /* In iscsi_main.c */
 
-struct cfattach iscsi_ca;              /* the device attach structure */
-struct cdevsw iscsi_cdevsw;            /* the character device descriptor */
+extern struct cfattach iscsi_ca;               /* the device attach structure */
 
-iscsi_softc_t *sc;                     /* our device pointer */
-session_list_t sessions;               /* the list of sessions */
+extern session_list_t iscsi_sessions;          /* the list of sessions */
 
-connection_list_t cleanup_list;                /* connections to clean up */
-bool detaching;                        /* signal to cleanup thread it should exit */
-struct lwp *cleanproc;                 /* pointer to cleanup proc */
+extern connection_list_t iscsi_cleanup_list;   /* connections to clean up */
+extern bool iscsi_detaching;                   /* signal to cleanup thread it should exit */
+extern struct lwp *iscsi_cleanproc;            /* pointer to cleanup proc */
 
-uint32_t num_send_threads;             /* the number of active send threads */
+extern uint32_t iscsi_num_send_threads;                /* the number of active send threads */
 
-uint8_t InitiatorName[ISCSI_STRING_LENGTH];
-uint8_t InitiatorAlias[ISCSI_STRING_LENGTH];
-login_isid_t InitiatorISID;
+extern uint8_t iscsi_InitiatorName[ISCSI_STRING_LENGTH];
+extern uint8_t iscsi_InitiatorAlias[ISCSI_STRING_LENGTH];
+extern login_isid_t iscsi_InitiatorISID;
 
 /* Debugging and profiling stuff */
 
@@ -565,7 +563,7 @@
 
 #if defined(ISCSI_PERFTEST)
 
-int iscsi_perf_level;                          /* How much info to display */
+extern int iscsi_perf_level;                           /* How much info to display */
 
 #define PDEBOUT(x) printf x
 #define PDEB(lev,x) { if (iscsi_perf_level >= lev) printf x ;}
@@ -580,7 +578,7 @@
 
 #ifdef ISCSI_DEBUG
 
-int iscsi_debug_level; /* How much debug info to display */
+extern int iscsi_debug_level;  /* How much debug info to display */
 
 #define DEBOUT(x) printf x
 #define DEB(lev,x) { if (iscsi_debug_level >= lev) printf x ;}
diff -r a57c70929095 -r f3d42b36d663 sys/dev/iscsi/iscsi_ioctl.c
--- a/sys/dev/iscsi/iscsi_ioctl.c       Sun Aug 12 12:43:49 2012 +0000
+++ b/sys/dev/iscsi/iscsi_ioctl.c       Sun Aug 12 13:26:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_ioctl.c,v 1.4 2012/06/24 17:01:35 mlelstv Exp $  */
+/*     $NetBSD: iscsi_ioctl.c,v 1.5 2012/08/12 13:26:18 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -112,7 +112,7 @@
        TAILQ_INSERT_TAIL(&event_handlers, handler, link);
 
        if (was_empty) {
-               wakeup(&cleanup_list);
+               wakeup(&iscsi_cleanup_list);
        }
        CS_END;
 
@@ -368,7 +368,7 @@
 {
        session_t *curr;
 
-       TAILQ_FOREACH(curr, &sessions, sessions)
+       TAILQ_FOREACH(curr, &iscsi_sessions, sessions)
                if (curr->id == id) {
                        break;
                }
@@ -543,7 +543,7 @@
        }
 
        /* remove from session list */
-       TAILQ_REMOVE(&sessions, session, sessions);
+       TAILQ_REMOVE(&iscsi_sessions, session, sessions);
        session->sessions.tqe_next = NULL;
        session->sessions.tqe_prev = NULL;
 
@@ -930,7 +930,7 @@
 
        DEB(99, ("ISCSI: login\n"));
 
-       if (!InitiatorName[0]) {
+       if (!iscsi_InitiatorName[0]) {
                DEB(1, ("No Initiator Name\n"));
                par->status = ISCSI_STATUS_NO_INITIATOR_NAME;
                return;
@@ -968,7 +968,7 @@
        }
 
        CS_BEGIN;
-       TAILQ_INSERT_HEAD(&sessions, session, sessions);
+       TAILQ_INSERT_HEAD(&iscsi_sessions, session, sessions);
        CS_END;
 
        /* Session established, map LUNs? */
@@ -1345,19 +1345,19 @@
                par->status = ISCSI_STATUS_PARAMETER_INVALID;
                return;
        }
-       strlcpy(InitiatorName, par->InitiatorName, sizeof(InitiatorName));
-       strlcpy(InitiatorAlias, par->InitiatorAlias, sizeof(InitiatorAlias));
-       memcpy(&InitiatorISID, par->ISID, 6);
+       strlcpy(iscsi_InitiatorName, par->InitiatorName, sizeof(iscsi_InitiatorName));
+       strlcpy(iscsi_InitiatorAlias, par->InitiatorAlias, sizeof(iscsi_InitiatorAlias));
+       memcpy(&iscsi_InitiatorISID, par->ISID, 6);
        DEB(5, ("ISCSI: set_node_name, ISID A=%x, B=%x, C=%x, D=%x\n",
-                       InitiatorISID.ISID_A, InitiatorISID.ISID_B,
-                       InitiatorISID.ISID_C, InitiatorISID.ISID_D));
+                       iscsi_InitiatorISID.ISID_A, iscsi_InitiatorISID.ISID_B,
+                       iscsi_InitiatorISID.ISID_C, iscsi_InitiatorISID.ISID_D));
 
-       if (!InitiatorISID.ISID_A && !InitiatorISID.ISID_B &&
-               !InitiatorISID.ISID_C && !InitiatorISID.ISID_D) {
-               InitiatorISID.ISID_A = T_FORMAT_EN;
-               InitiatorISID.ISID_B = htons(0x1);
-               InitiatorISID.ISID_C = 0x37;
-               InitiatorISID.ISID_D = 0;
+       if (!iscsi_InitiatorISID.ISID_A && !iscsi_InitiatorISID.ISID_B &&
+               !iscsi_InitiatorISID.ISID_C && !iscsi_InitiatorISID.ISID_D) {
+               iscsi_InitiatorISID.ISID_A = T_FORMAT_EN;
+               iscsi_InitiatorISID.ISID_B = htons(0x1);
+               iscsi_InitiatorISID.ISID_C = 0x37;
+               iscsi_InitiatorISID.ISID_D = 0;
        }
 
        par->status = ISCSI_STATUS_SUCCESS;
@@ -1427,7 +1427,7 @@
 {
        session_t *sess;
 
-       while ((sess = TAILQ_FIRST(&sessions)) != NULL) {
+       while ((sess = TAILQ_FIRST(&iscsi_sessions)) != NULL) {
                kill_session(sess, ISCSI_STATUS_DRIVER_UNLOAD, LOGOUT_SESSION,
                                FALSE);
        }
@@ -1474,11 +1474,11 @@
        uint32_t status;
 
        s = splbio();
-       while ((conn = TAILQ_FIRST(&cleanup_list)) != NULL ||
-               num_send_threads ||
-               !detaching) {
+       while ((conn = TAILQ_FIRST(&iscsi_cleanup_list)) != NULL ||
+               iscsi_num_send_threads ||
+               !iscsi_detaching) {
                if (conn != NULL) {
-                       TAILQ_REMOVE(&cleanup_list, conn, connections);
+                       TAILQ_REMOVE(&iscsi_cleanup_list, conn, connections);
                        splx(s);
 
                        sess = conn->session;
@@ -1502,7 +1502,7 @@
                                /* unlink and free the session */
                                if (sess->sessions.tqe_next != NULL ||
                                        sess->sessions.tqe_prev != NULL)
-                                       TAILQ_REMOVE(&sessions, sess, sessions);
+                                       TAILQ_REMOVE(&iscsi_sessions, sess, sessions);
 
                                if (sess->target_list != NULL)
                                        free(sess->target_list, M_TEMP);
@@ -1520,7 +1520,7 @@
                        /* Go to sleep, but wake up every 30 seconds to check for */
                        /* dead event handlers */
                        splx(s);
-                       rc = tsleep(&cleanup_list, PWAIT, "cleanup",
+                       rc = tsleep(&iscsi_cleanup_list, PWAIT, "cleanup",
                                (TAILQ_FIRST(&event_handlers)) ? 30 * hz : 0);
                        s = splbio();
                        /* if timed out, not woken up */
@@ -1539,7 +1539,7 @@
        for (s = 0; TAILQ_FIRST(&event_handlers) != NULL && s < 60; s++)
                tsleep(&s, PWAIT, "waiteventclr", hz);
 
-       cleanproc = NULL;
+       iscsi_cleanproc = NULL;
        DEB(5, ("Cleanup thread exits\n"));
        kthread_exit(0);
 }
diff -r a57c70929095 -r f3d42b36d663 sys/dev/iscsi/iscsi_main.c
--- a/sys/dev/iscsi/iscsi_main.c        Sun Aug 12 12:43:49 2012 +0000
+++ b/sys/dev/iscsi/iscsi_main.c        Sun Aug 12 13:26:18 2012 +0000
@@ -52,20 +52,20 @@
 iscsi_softc_t *sc = NULL;
 
 /* the list of sessions */
-session_list_t sessions = TAILQ_HEAD_INITIALIZER(sessions);
+session_list_t iscsi_sessions = TAILQ_HEAD_INITIALIZER(iscsi_sessions);
 
 /* connections to clean up */
-connection_list_t cleanup_list = TAILQ_HEAD_INITIALIZER(cleanup_list);
-bool detaching = FALSE;
-struct lwp *cleanproc = NULL;
+connection_list_t iscsi_cleanup_list = TAILQ_HEAD_INITIALIZER(iscsi_cleanup_list);
+bool iscsi_detaching = FALSE;
+struct lwp *iscsi_cleanproc = NULL;
 
 /* the number of active send threads (for cleanup thread) */
-uint32_t num_send_threads = 0;
+uint32_t iscsi_num_send_threads = 0;
 
 /* Our node name, alias, and ISID */
-uint8_t InitiatorName[ISCSI_STRING_LENGTH] = "";
-uint8_t InitiatorAlias[ISCSI_STRING_LENGTH] = "";
-login_isid_t InitiatorISID;
+uint8_t iscsi_InitiatorName[ISCSI_STRING_LENGTH] = "";
+uint8_t iscsi_InitiatorAlias[ISCSI_STRING_LENGTH] = "";
+login_isid_t iscsi_InitiatorISID;
 
 /******************************************************************************/
 
@@ -74,17 +74,18 @@
 */
 
 void iscsiattach(int);
-void iscsi_attach(device_t parent, device_t self, void *aux);
-int iscsi_match(device_t, cfdata_t, void *);
-int iscsi_detach(device_t, int);
+
+static void iscsi_attach(device_t parent, device_t self, void *aux);
+static int iscsi_match(device_t, cfdata_t, void *);
+static int iscsi_detach(device_t, int);
 
 
 CFATTACH_DECL_NEW(iscsi, sizeof(struct iscsi_softc), iscsi_match, iscsi_attach,
                          iscsi_detach, NULL);
 
 
-int iscsiopen(dev_t, int, int, PTHREADOBJ);
-int iscsiclose(dev_t, int, int, PTHREADOBJ);
+static dev_type_open(iscsiopen);
+static dev_type_close(iscsiclose);
 
 struct cdevsw iscsi_cdevsw = {
        iscsiopen, iscsiclose,
@@ -131,7 +132,7 @@
  *    Not much to do here, either - this is a pseudo-device.
  */
 
-int
+static int
 iscsi_match(device_t self, cfdata_t cfdata, void *arg)
 {
        return 1;
@@ -178,7 +179,7 @@
  * iscsi_attach:
  *    One-time inits go here. Not much for now, probably even less later.
  */
-void
+static void
 iscsi_attach(device_t parent, device_t self, void *aux)
 {
 
@@ -187,7 +188,7 @@
        sc = (iscsi_softc_t *) device_private(self);
        sc->sc_dev = self;
        if (kthread_create(PRI_NONE, 0, NULL, iscsi_cleanup_thread,
-           NULL, &cleanproc, "Cleanup") != 0) {
+           NULL, &iscsi_cleanproc, "Cleanup") != 0) {
                panic("Can't create cleanup thread!");
        }
        aprint_normal("%s: attached.  major = %d\n", iscsi_cd.cd_name,
@@ -198,16 +199,16 @@
  * iscsi_detach:
  *    Cleanup.
  */
-int
+static int
 iscsi_detach(device_t self, int flags)
 {
 
        DEBOUT(("ISCSI: detach\n"));
        kill_all_sessions();
-       detaching = TRUE;
-       while (cleanproc != NULL) {
-               wakeup(&cleanup_list);
-               tsleep(&cleanup_list, PWAIT, "detach_wait", 20);
+       iscsi_detaching = TRUE;
+       while (iscsi_cleanproc != NULL) {
+               wakeup(&iscsi_cleanup_list);
+               tsleep(&iscsi_cleanup_list, PWAIT, "detach_wait", 20);
        }
        return 0;
 }



Home | Main Index | Thread Index | Old Index