Module Name: src Committed By: mlelstv Date: Sun Aug 12 13:26:18 UTC 2012
Modified Files: src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c iscsi_main.c iscsi_send.c iscsi_text.c Log Message: Don't use common variables, also prefix global variables to avoid namespace pollution. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/iscsi/iscsi_globals.h \ src/sys/dev/iscsi/iscsi_ioctl.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/iscsi/iscsi_main.c \ src/sys/dev/iscsi/iscsi_send.c src/sys/dev/iscsi/iscsi_text.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/iscsi/iscsi_globals.h diff -u src/sys/dev/iscsi/iscsi_globals.h:1.4 src/sys/dev/iscsi/iscsi_globals.h:1.5 --- src/sys/dev/iscsi/iscsi_globals.h:1.4 Sat Jun 9 06:19:58 2012 +++ src/sys/dev/iscsi/iscsi_globals.h Sun Aug 12 13:26:18 2012 @@ -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 @@ typedef struct event_handler_list_s even /* 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 @@ login_isid_t InitiatorISID; #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 @@ int iscsi_perf_level; /* How much inf #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 ;} Index: src/sys/dev/iscsi/iscsi_ioctl.c diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.4 src/sys/dev/iscsi/iscsi_ioctl.c:1.5 --- src/sys/dev/iscsi/iscsi_ioctl.c:1.4 Sun Jun 24 17:01:35 2012 +++ src/sys/dev/iscsi/iscsi_ioctl.c Sun Aug 12 13:26:18 2012 @@ -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 @@ register_event(iscsi_register_event_para TAILQ_INSERT_TAIL(&event_handlers, handler, link); if (was_empty) { - wakeup(&cleanup_list); + wakeup(&iscsi_cleanup_list); } CS_END; @@ -368,7 +368,7 @@ find_session(uint32_t id) { session_t *curr; - TAILQ_FOREACH(curr, &sessions, sessions) + TAILQ_FOREACH(curr, &iscsi_sessions, sessions) if (curr->id == id) { break; } @@ -543,7 +543,7 @@ kill_session(session_t *session, uint32_ } /* 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 @@ login(iscsi_login_parameters_t *par, PTH 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 @@ login(iscsi_login_parameters_t *par, PTH } 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 @@ set_node_name(iscsi_set_node_name_parame 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 @@ kill_all_sessions(void) { 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 @@ iscsi_cleanup_thread(void *par) 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 @@ iscsi_cleanup_thread(void *par) /* 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 @@ iscsi_cleanup_thread(void *par) /* 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 @@ iscsi_cleanup_thread(void *par) 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); } Index: src/sys/dev/iscsi/iscsi_main.c diff -u src/sys/dev/iscsi/iscsi_main.c:1.5 src/sys/dev/iscsi/iscsi_main.c:1.6 --- src/sys/dev/iscsi/iscsi_main.c:1.5 Sat Jun 9 06:19:58 2012 +++ src/sys/dev/iscsi/iscsi_main.c Sun Aug 12 13:26:18 2012 @@ -52,20 +52,20 @@ int iscsi_perf_level = 0; 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 @@ login_isid_t InitiatorISID; */ 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 @@ iscsiclose(dev_t dev, int flag, int mode * 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 @@ iscsiattach(int n) * 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 @@ iscsi_attach(device_t parent, device_t s 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_attach(device_t parent, device_t s * 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; } Index: src/sys/dev/iscsi/iscsi_send.c diff -u src/sys/dev/iscsi/iscsi_send.c:1.5 src/sys/dev/iscsi/iscsi_send.c:1.6 --- src/sys/dev/iscsi/iscsi_send.c:1.5 Sun Jun 24 17:01:35 2012 +++ src/sys/dev/iscsi/iscsi_send.c Sun Aug 12 13:26:18 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_send.c,v 1.5 2012/06/24 17:01:35 mlelstv Exp $ */ +/* $NetBSD: iscsi_send.c,v 1.6 2012/08/12 13:26:18 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -272,7 +272,7 @@ iscsi_send_thread(void *par) sess = conn->session; /* so cleanup thread knows there's someone left */ - num_send_threads++; + iscsi_num_send_threads++; do { while (!conn->terminating) { @@ -411,14 +411,14 @@ iscsi_send_thread(void *par) sess->mru_connection = TAILQ_FIRST(&sess->conn_list); } - TAILQ_INSERT_TAIL(&cleanup_list, conn, connections); + TAILQ_INSERT_TAIL(&iscsi_cleanup_list, conn, connections); splx(s); - wakeup(&cleanup_list); + wakeup(&iscsi_cleanup_list); conn->sendproc = NULL; DEBC(conn, 5, ("Send thread exits\n")); - num_send_threads--; + iscsi_num_send_threads--; kthread_exit(0); } @@ -624,7 +624,7 @@ init_login_pdu(connection_t *conn, pdu_t NEXT_PHASE(c_phase); } - memcpy(isid, &InitiatorISID, 6); + memcpy(isid, &iscsi_InitiatorISID, 6); isid->TSIH = conn->session->TSIH; pdu->p.login_req.CID = htons(conn->id); Index: src/sys/dev/iscsi/iscsi_text.c diff -u src/sys/dev/iscsi/iscsi_text.c:1.5 src/sys/dev/iscsi/iscsi_text.c:1.6 --- src/sys/dev/iscsi/iscsi_text.c:1.5 Sun Jun 24 17:01:35 2012 +++ src/sys/dev/iscsi/iscsi_text.c Sun Aug 12 13:26:18 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_text.c,v 1.5 2012/06/24 17:01:35 mlelstv Exp $ */ +/* $NetBSD: iscsi_text.c,v 1.6 2012/08/12 13:26:18 mlelstv Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -1276,14 +1276,14 @@ assemble_login_parameters(connection_t * } ccb->temp_data = state; - if (!InitiatorName[0]) { + if (!iscsi_InitiatorName[0]) { DEBOUT(("No InitiatorName\n")); return ISCSI_STATUS_PARAMETER_MISSING; } - set_key_s(state, K_InitiatorName, InitiatorName); + set_key_s(state, K_InitiatorName, iscsi_InitiatorName); - if (InitiatorAlias[0]) - set_key_s(state, K_InitiatorAlias, InitiatorAlias); + if (iscsi_InitiatorAlias[0]) + set_key_s(state, K_InitiatorAlias, iscsi_InitiatorAlias); conn->Our_MaxRecvDataSegmentLength = (par->is_present.MaxRecvDataSegmentLength) @@ -1298,7 +1298,7 @@ assemble_login_parameters(connection_t * if (par->is_present.user_name) copyinstr(par->user_name, state->user_name, MAX_STRING, &sz); else - strlcpy(state->user_name, InitiatorName, + strlcpy(state->user_name, iscsi_InitiatorName, sizeof(state->user_name)); next = TRUE;