Remove server logging globals

Remove the global variables used to setup server logging and replace
with an argument to OpenLog.

Keep the LogLevel variable as a global for use by the logging macros,
but provide an inline function for applications which check the log
level to dump more information when the log level is increased.

Provide consistency by adding syslog tags to processes that did not
previously set one (salvageserver, salvager, and volserver).

[kaduk@mit.edu: update commit message, use old-style log rotation for
kalog, minor commenting fixes]

Change-Id: I11cffbdd1418304d33f0be02dd7e600955c4a8bb
Reviewed-on: https://gerrit.openafs.org/12168
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Michael Meffie 2016-01-06 17:06:54 -05:00 committed by Benjamin Kaduk
parent 4bfb874d19
commit ad455347bc
24 changed files with 494 additions and 193 deletions

View File

@ -1602,6 +1602,7 @@ AC_SUBST(INSTALL_KAUTH)
AC_CHECK_FUNCS([ \
arc4random \
closelog \
fcntl \
fseeko64 \
ftello64 \
@ -1613,6 +1614,7 @@ AC_CHECK_FUNCS([ \
getrlimit \
issetugid \
mkstemp \
openlog \
poll \
pread \
preadv \
@ -1630,6 +1632,7 @@ AC_CHECK_FUNCS([ \
strerror \
sysconf \
sysctl \
syslog \
tdestroy \
timegm \
])

View File

@ -371,6 +371,7 @@ main(int argc, char **argv)
afs_int32 numClasses;
extern int rx_stackSize;
struct logOptions logopts;
#ifdef AFS_NT40_ENV
/* initialize winsock */
@ -400,6 +401,12 @@ main(int argc, char **argv)
memset(&cellinfo_s, 0, sizeof(cellinfo_s));
memset(clones, 0, sizeof(clones));
memset(&logopts, 0, sizeof(logopts));
logopts.lopt_dest = logDest_file;
logopts.lopt_filename = AFSDIR_SERVER_BUDBLOG_FILEPATH;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
osi_audit_init();
osi_audit(BUDB_StartEvent, 0, AUD_END);
@ -442,7 +449,7 @@ main(int argc, char **argv)
BUDB_EXIT(0);
/* open the log file */
OpenLog(AFSDIR_SERVER_BUDBLOG_FILEPATH);
OpenLog(&logopts);
/* open the cell's configuration directory */
LogDebug(4, "opening %s\n", globalConfPtr->cellConfigdir);

View File

@ -34,7 +34,14 @@ DBM *kalog_db;
void
kalog_Init(void)
{
OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
struct logOptions logopts;
memset(&logopts, 0, sizeof(logopts));
logopts.lopt_dest = logDest_file;
logopts.lopt_filename = AFSDIR_SERVER_KALOGDB_FILEPATH;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
OpenLog(&logopts);
SetupLogSignals();
kalog_db =
dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,

View File

@ -171,6 +171,7 @@ main(int argc, char *argv[])
char clones[MAXHOSTSPERCELL];
afs_uint32 host = ntohl(INADDR_ANY);
char *auditFileName = NULL;
struct logOptions logopts;
struct rx_service *tservice;
struct rx_securityClass *sca[1];
@ -195,6 +196,8 @@ main(int argc, char *argv[])
#endif
osi_audit_init();
memset(&logopts, 0, sizeof(logopts));
if (argc == 0) {
usage:
printf("Usage: kaserver [-noAuth] [-database <dbpath>] "
@ -321,7 +324,12 @@ main(int argc, char *argv[])
* text logging. So open the AuthLog file for logging and redirect
* stdin and stdout to it
*/
OpenLog(AFSDIR_SERVER_KALOG_FILEPATH);
logopts.lopt_dest = logDest_file;
logopts.lopt_filename = AFSDIR_SERVER_KALOG_FILEPATH;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
OpenLog(&logopts);
SetupLogSignals();
#endif

View File

@ -226,7 +226,9 @@ enum optionsList {
OPT_debug,
OPT_logfile,
OPT_threads,
#ifdef HAVE_SYSLOG
OPT_syslog,
#endif
OPT_peer,
OPT_process,
OPT_rxbind,
@ -252,7 +254,7 @@ main(int argc, char **argv)
char *pr_dbaseName;
char *configDir;
char *logFile;
struct logOptions logopts;
char *whoami = "ptserver";
char *auditFileName = NULL;
@ -288,7 +290,7 @@ main(int argc, char **argv)
pr_dbaseName = strdup(AFSDIR_SERVER_PRDB_FILEPATH);
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
logFile = strdup(AFSDIR_SERVER_PTLOG_FILEPATH);
memset(&logopts, 0, sizeof(logopts));
#if defined(SUPERGROUPS)
/* make sure the structures for database records are the same size */
@ -338,7 +340,7 @@ main(int argc, char **argv)
CMD_OPTIONAL, "location of logfile");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE,
CMD_OPTIONAL, "number of threads");
#if !defined(AFS_NT40_ENV)
#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
@ -397,9 +399,7 @@ main(int argc, char **argv)
free(interface);
}
cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
cmd_OptionAsString(opts, OPT_database, &pr_dbaseName);
cmd_OptionAsString(opts, OPT_logfile, &logFile);
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
if (lwps > 64) { /* maximum of 64 */
@ -413,12 +413,29 @@ main(int argc, char **argv)
}
}
#ifndef AFS_NT40_ENV
#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
serverLogSyslog = 1;
cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
}
if (cmd_OptionPresent(opts, OPT_logfile)) {
fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.");
PT_EXIT(1);
}
logopts.lopt_dest = logDest_syslog;
logopts.lopt_facility = LOG_DAEMON;
logopts.lopt_tag = "ptserver";
cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
} else
#endif
{
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
if (cmd_OptionPresent(opts, OPT_logfile))
cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
else
logopts.lopt_filename = AFSDIR_SERVER_PTLOG_FILEPATH;
}
cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
/* rx options */
if (cmd_OptionPresent(opts, OPT_peer))
@ -441,10 +458,7 @@ main(int argc, char **argv)
osi_audit(PTS_StartEvent, 0, AUD_END);
}
#ifndef AFS_NT40_ENV
serverLogSyslogTag = "ptserver";
#endif
OpenLog(logFile); /* set up logging */
OpenLog(&logopts);
#ifdef AFS_PTHREAD_ENV
opr_softsig_Init();
SetupLogSoftSignals();

View File

@ -33,13 +33,46 @@
#include <stdarg.h>
#include <string.h>
extern int LogLevel;
extern int mrafsStyleLogs;
#ifndef AFS_NT40_ENV
extern int serverLogSyslog;
extern int serverLogSyslogFacility;
extern char *serverLogSyslogTag;
enum logDest {
logDest_file,
#ifdef HAVE_SYSLOG
logDest_syslog,
#endif
};
enum logRotateStyle {
logRotate_none = 0,
logRotate_old, /**< Rename log file by adding .old to the file name. */
logRotate_timestamp, /**< Rename log file to a timestamped file name. */
};
struct logOptions {
int logLevel; /**< The initial log level. */
enum logDest dest; /**< Log destination */
union {
struct fileOptions {
const char *filename; /**< Log filename (may be a named pipe). */
int rotateOnOpen; /**< Rotate the log file during OpenLog. */
int rotateOnReset; /**< Rotate the log file when the SIGHUP is caught. */
enum logRotateStyle rotateStyle; /**< Specifies how logs are renamed. */
} fileOpts;
#ifdef HAVE_SYSLOG
struct syslogOptions {
int facility; /**< The syslog facility. */
char *tag; /**< The syslog identification. */
} syslogOpts;
#endif
} opts;
};
#define lopt_logLevel logLevel
#define lopt_dest dest
#define lopt_filename opts.fileOpts.filename
#define lopt_rotateOnOpen opts.fileOpts.rotateOnOpen
#define lopt_rotateOnReset opts.fileOpts.rotateOnReset
#define lopt_rotateStyle opts.fileOpts.rotateStyle
#define lopt_facility opts.syslogOpts.facility
#define lopt_tag opts.syslogOpts.tag
extern void vFSLog(const char *format, va_list args)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
@ -48,16 +81,22 @@ extern void SetLogThreadNumProgram(int (*func) (void) );
extern void FSLog(const char *format, ...)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
extern int LogLevel; /* For logging macros only. */
#define ViceLog(level, str) do { if ((level) <= LogLevel) (FSLog str); } while (0)
#define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
#define ViceLogThenPanic(level, str) \
do { ViceLog(level, str); osi_Panic str; } while(0);
extern int OpenLog(const char *filename);
extern int OpenLog(struct logOptions *opts);
extern int ReOpenLog(void);
extern void SetupLogSignals(void);
extern void CloseLog(void);
extern void SetupLogSoftSignals(void);
extern int GetLogLevel(void);
extern enum logDest GetLogDest(void);
extern const char *GetLogFilename(void);
#ifdef AFS_NT40_ENV
#ifndef _MFC_VER

View File

@ -125,17 +125,21 @@ extern void afs_pthread_setname_self(const char *threadname);
/* serverLog.c */
struct logOptions;
extern void WriteLogBuffer(char *buf, afs_uint32 len);
extern void SetDebug_Signal(int signo);
extern void ResetDebug_Signal(int signo);
extern void SetupLogSignals(void);
extern int OpenLog(const char *fileName);
extern int OpenLog(struct logOptions *opts);
extern int ReOpenLog(void);
extern int LogThreadNum(void);
extern void LogCommandLine(int argc, char **argv, const char *progname,
const char *version, const char *logstring,
void (*log) (const char *format, ...));
extern void LogDesWarning(void);
extern int GetLogLevel(void);
extern enum logDest GetLogDest(void);
extern const char *GetLogFilename(void);
/* snprintf.c */

View File

@ -35,14 +35,10 @@ hostutil_GetNameByINet
initAFSDirPath
int64_to_flipbase64
ktime_DateToInt32
mrafsStyleLogs
pthread_recursive_mutex_lock
pthread_recursive_mutex_lock
pthread_recursive_mutex_unlock
pthread_recursive_mutex_unlock
serverLogSyslog
serverLogSyslogFacility
serverLogSyslogTag
util_GetHumanInt32
util_GetInt32
util_GetInt64

View File

@ -65,19 +65,14 @@ static int (*threadNumProgram) (void) = dummyThreadNum;
/* After single-threaded startup, accesses to serverlogFD and
* serverLogSyslog* are protected by LOCK_SERVERLOG(). */
static int serverLogFD = -1;
#ifndef AFS_NT40_ENV
int serverLogSyslog = 0;
int serverLogSyslogFacility = LOG_DAEMON;
char *serverLogSyslogTag = 0;
#endif
static struct logOptions serverLogOpts;
int LogLevel;
int mrafsStyleLogs = 0;
static int threadIdLogs = 0;
static int resetSignals = 0;
static char *ourName = NULL;
static int OpenLogFile(const char *fileName);
static void RotateLogFile(void);
/*!
@ -97,6 +92,37 @@ IsFIFO(const char *fileName)
return (lstat(fileName, &statbuf) == 0) && (S_ISFIFO(statbuf.st_mode));
}
/*!
* Return the current logging level.
*/
int
GetLogLevel(void)
{
return LogLevel;
}
/*!
* Return the log destination.
*/
enum logDest
GetLogDest(void)
{
return serverLogOpts.lopt_dest;
}
/*!
* Get the log filename for file based logging.
*
* An empty string is returned if the log destination is not
* file based. The caller must make a copy of the string
* if it is accessed after the CloseLog.
*/
const char *
GetLogFilename(void)
{
return serverLogOpts.lopt_dest == logDest_file ? (const char*)ourName : "";
}
void
SetLogThreadNumProgram(int (*func) (void) )
{
@ -148,8 +174,8 @@ vFSLog(const char *format, va_list args)
len = strlen(tbuffer);
LOCK_SERVERLOG();
#ifndef AFS_NT40_ENV
if (serverLogSyslog) {
#ifdef HAVE_SYSLOG
if (serverLogOpts.dest == logDest_syslog) {
syslog(LOG_INFO, "%s", info);
} else
#endif
@ -160,7 +186,7 @@ vFSLog(const char *format, va_list args)
UNLOCK_SERVERLOG();
#if !defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
if (!serverLogSyslog) {
if (serverLogOpts.dest == logDest_file) {
fflush(stdout);
fflush(stderr); /* in case they're sharing the same FD */
}
@ -239,13 +265,21 @@ RenameLogFile(const char *fileName)
{
int code;
char *nextName = NULL;
int tries;
time_t t;
struct stat buf;
struct tm *timeFields;
if (mrafsStyleLogs) {
int tries;
time_t t;
struct stat buf;
struct tm *timeFields;
switch (serverLogOpts.lopt_rotateStyle) {
case logRotate_none:
break;
case logRotate_old:
code = asprintf(&nextName, "%s.old", fileName);
if (code < 0) {
nextName = NULL;
}
break;
case logRotate_timestamp:
time(&t);
for (tries = 0; nextName == NULL && tries < 100; t++, tries++) {
timeFields = localtime(&t);
@ -264,11 +298,9 @@ RenameLogFile(const char *fileName)
nextName = NULL;
}
}
} else {
code = asprintf(&nextName, "%s.old", fileName);
if (code < 0) {
nextName = NULL;
}
break;
default:
opr_Assert(0);
}
if (nextName != NULL) {
rk_rename(fileName, nextName); /* Don't check the error code. */
@ -343,7 +375,7 @@ ResetDebug_Signal(int signo)
if (threadIdLogs == 1)
threadIdLogs = 0;
#endif
if (mrafsStyleLogs) {
if (serverLogOpts.lopt_rotateOnReset) {
RotateLogFile();
}
} /*ResetDebug_Signal */
@ -415,33 +447,33 @@ RedirectStdStreams(const char *fileName)
}
}
int
OpenLog(const char *fileName)
/*!
* Open the log file.
*
* Open the log file using the options given in OpenLog().
*
* \returns 0 on success
*/
static int
OpenLogFile(const char *fileName)
{
/*
* This function should allow various libraries that inconsistently
* use stdout/stderr to all go to the same place
*/
int tempfd;
int flags = O_WRONLY | O_TRUNC | O_CREAT | O_APPEND;
int flags = O_WRONLY | O_CREAT | O_APPEND;
#if defined(AFS_PTHREAD_ENV)
opr_Verify(pthread_once(&serverLogOnce, InitServerLogMutex) == 0);
#endif /* AFS_PTHREAD_ENV */
#ifndef AFS_NT40_ENV
if (serverLogSyslog) {
openlog(serverLogSyslogTag, LOG_PID, serverLogSyslogFacility);
return (0);
}
#endif
opr_Assert(serverLogOpts.dest == logDest_file);
opr_Assert(fileName != NULL);
if (IsFIFO(fileName)) {
/* Support named pipes as logs by not rotating them. */
flags |= O_NONBLOCK;
} else {
} else if (serverLogOpts.lopt_rotateOnOpen) {
/* Old style logging always started a new log file. */
flags |= O_TRUNC;
RenameLogFile(fileName);
}
@ -460,6 +492,103 @@ OpenLog(const char *fileName)
serverLogFD = tempfd;
return 0;
}
/*!
* Open the log file descriptor or a connection to the system log.
*
* This function should be called once during program initialization and
* must be called before calling FSLog() or WriteLogBuffer(). The
* fields of the given argument specify the logging destination and
* various optional features.
*
* The lopt_logLevel value specifies the initial logging level.
*
* The lopt_dest enum specifies the logging destination; either
* file based (logDest_file) or the system log (logDest_syslog).
*
* File Based Logging
* ------------------
*
* A file will be opened for log messages when the lopt_dest enum is set
* to logDest_file. The file specified by lopt_filename will be opened
* for appending log messages. A new file will be created if the log
* file does not exist.
*
* The lopt_rotateOnOpen flag specifies whether an existing log file is
* to be renamed and a new log file created during the call to OpenLog.
* The lopt_rotateOnOpen flag has no effect if the file given by
* lopt_filename is a named pipe (fifo).
*
* The lopt_rotateOnReset flag specifies whether the log file is renamed
* and then reopened when the reset signal (SIGHUP) is caught.
*
* The lopt_rotateStyle enum specifies how the new log file is renamed when
* lopt_rotateOnOpen or lopt_rotateOnReset are set. The lopt_rotateStyle
* may be the traditional Transarc style (logRotate_old) or the MR-AFS
* style (logRotate_timestamp).
*
* When lopt_rotateStyle is set to logRotate_old, the suffix ".old" is
* appended to the log file name. The existing ".old" log file is
* removed.
*
* When lopt_rotateStyle is set to logRotate_timestamp, a timestamp
* string is appended to the log file name and existing files are not
* removed.
*
* \note Messages written to stdout and stderr are redirected to the log
* file when file-based logging is in effect.
*
* System Logging
* --------------
*
* A connection to the system log (syslog) will be established for log
* messages when the lopt_dest enum is set to logDest_syslog.
*
* The lopt_facility specifies the system log facility to be used when
* writing messages to the system log.
*
* The lopt_tag string specifies the indentification string to be used
* when writing messages to the system log.
*
* \param opts logging options. A copy of the logging
* options will be made before returning to
* the caller.
*
* \returns 0 on success
*/
int
OpenLog(struct logOptions *opts)
{
int code;
#if defined(AFS_PTHREAD_ENV)
opr_Verify(pthread_once(&serverLogOnce, InitServerLogMutex) == 0);
#endif /* AFS_PTHREAD_ENV */
LogLevel = serverLogOpts.logLevel = opts->logLevel;
serverLogOpts.dest = opts->dest;
switch (serverLogOpts.dest) {
case logDest_file:
serverLogOpts.lopt_rotateOnOpen = opts->lopt_rotateOnOpen;
serverLogOpts.lopt_rotateOnReset = opts->lopt_rotateOnReset;
serverLogOpts.lopt_rotateStyle = opts->lopt_rotateStyle;
/* OpenLogFile() sets ourName; don't cache filename here. */
code = OpenLogFile(opts->lopt_filename);
break;
#ifdef HAVE_SYSLOG
case logDest_syslog:
serverLogOpts.lopt_rotateOnOpen = 0;
serverLogOpts.lopt_rotateOnReset = 0;
serverLogOpts.lopt_rotateStyle = logRotate_none;
openlog(opts->lopt_tag, LOG_PID, opts->lopt_facility);
code = 0;
break;
#endif
default:
opr_Assert(0);
}
return code;
} /*OpenLog */
/*!
@ -475,8 +604,8 @@ ReOpenLog(void)
{
int flags = O_WRONLY | O_APPEND | O_CREAT;
#if !defined(AFS_NT40_ENV)
if (serverLogSyslog) {
#ifdef HAVE_SYSLOG
if (serverLogOpts.dest == logDest_syslog) {
return 0;
}
#endif
@ -511,7 +640,7 @@ RotateLogFile(void)
close(serverLogFD);
serverLogFD = -1;
}
OpenLog(ourName);
OpenLogFile(ourName);
}
UNLOCK_SERVERLOG();
}
@ -525,8 +654,9 @@ void
CloseLog(void)
{
LOCK_SERVERLOG();
#ifndef AFS_NT40_ENV
if (serverLogSyslog) {
#ifdef HAVE_SYSLOG
if (serverLogOpts.dest == logDest_syslog) {
closelog();
} else
#endif

View File

@ -173,7 +173,6 @@ struct afs_FSStats {
struct afs_FSStats afs_fsstats;
int LogLevel = 0;
int supported = 1;
int Console = 0;
afs_int32 BlocksSpare = 1024; /* allow 1 MB overruns */

View File

@ -53,7 +53,6 @@ extern int CurrentConnections;
extern int SystemId;
extern int AnonymousID;
extern prlist AnonCPS;
extern int LogLevel;
extern struct afsconf_dir *confDir; /* config dir object */
extern int lwps; /* the max number of server threads */
extern afsUUID FS_HostUUID;
@ -1128,7 +1127,7 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host)
if (chain->hostPtr->z.interface &&
afs_uuid_equal(&chain->hostPtr->z.interface->uuid, uuid)) {
if (LogLevel >= 125) {
if (GetLogLevel() >= 125) {
afsUUID_to_string(&chain->hostPtr->z.interface->uuid, uuid1,
127);
afsUUID_to_string(uuid, uuid2, 127);
@ -1149,7 +1148,7 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host)
chain->hostPtr = host;
chain->next = hostUuidHashTable[index];
hostUuidHashTable[index] = chain;
if (LogLevel < 125)
if (GetLogLevel() < 125)
return;
afsUUID_to_string(uuid, uuid2, 127);
ViceLog(125,
@ -1173,7 +1172,7 @@ h_DeleteHostFromUuidHashTable_r(struct host *host)
/* hash into proper bucket */
index = h_UuidHashIndex(&host->z.interface->uuid);
if (LogLevel >= 125)
if (GetLogLevel() >= 125)
afsUUID_to_string(&host->z.interface->uuid, uuid1, 127);
for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) {
opr_Assert(uth->hostPtr);
@ -4259,7 +4258,7 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
h_AddHostToUuidHashTable_r(&interface->uuid, host);
if (LogLevel >= 125) {
if (GetLogLevel() >= 125) {
afsUUID_to_string(&interface->uuid, uuidstr, 127);
ViceLog(125, ("--- uuid %s\n", uuidstr));

View File

@ -71,6 +71,7 @@
#include <afs/audit.h>
#include <afs/partition.h>
#include <afs/dir.h>
#include <afs/afsutil.h>
#include "viced_prototypes.h"
#include "viced.h"
#include "host.h"
@ -89,7 +90,7 @@ static afs_int32 Do_VLRegisterRPC(void);
int eventlog = 0, rxlog = 0;
FILE *debugFile;
char *logFile = NULL;
static struct logOptions logopts;
pthread_mutex_t fsync_glock_mutex;
pthread_cond_t fsync_cond;
@ -115,7 +116,6 @@ int restartMode = RESTART_ORDINARY;
*/
struct afs_PerfStats afs_perfstats;
extern int LogLevel;
extern int Statistics;
int busyonrst = 1;
@ -629,9 +629,9 @@ PrintCounters(void)
ViceLog(0, ("Vice was last started at %s\n", tbuffer));
#ifdef AFS_DEMAND_ATTACH_FS
if (LogLevel >= 125) {
if (GetLogLevel() >= 125) {
stats_flags = VOL_STATS_PER_CHAIN2;
} else if (LogLevel >= 25) {
} else if (GetLogLevel() >= 25) {
stats_flags = VOL_STATS_PER_CHAIN;
}
VPrintExtendedCacheStats(stats_flags);
@ -912,7 +912,9 @@ enum optionsList {
OPT_logfile,
OPT_mrafslogs,
OPT_threads,
#ifdef HAVE_SYSLOG
OPT_syslog,
#endif
OPT_peer,
OPT_process,
OPT_nojumbo,
@ -1065,7 +1067,7 @@ ParseArgs(int argc, char *argv[])
CMD_OPTIONAL, "enable MRAFS style logging");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE, CMD_OPTIONAL,
"number of threads");
#if !defined(AFS_NT40_ENV)
#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
@ -1300,9 +1302,6 @@ ParseArgs(int argc, char *argv[])
optstring = NULL;
}
cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
cmd_OptionAsFlag(opts, OPT_mrafslogs, &mrafsStyleLogs);
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
lwps_max = max_fileserver_thread() - FILESERVER_HELPER_THREADS;
if (lwps > lwps_max)
@ -1311,12 +1310,40 @@ ParseArgs(int argc, char *argv[])
lwps = 6;
}
#ifndef AFS_NT40_ENV
/* Logging options. */
#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
serverLogSyslog = 1;
cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
}
if (cmd_OptionPresent(opts, OPT_logfile)) {
fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
return -1;
}
if (cmd_OptionPresent(opts, OPT_mrafslogs)) {
fprintf(stderr, "Invalid options: -syslog and -mrafslogs are exclusive.\n");
return -1;
}
logopts.lopt_dest = logDest_syslog;
logopts.lopt_facility = LOG_DAEMON;
logopts.lopt_tag = "fileserver";
cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
} else
#endif
{
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
if (cmd_OptionPresent(opts, OPT_logfile))
cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
else
logopts.lopt_filename = AFSDIR_SERVER_FILELOG_FILEPATH;
if (cmd_OptionPresent(opts, OPT_mrafslogs)) {
logopts.lopt_rotateOnReset = 1;
logopts.lopt_rotateStyle = logRotate_timestamp;
}
}
cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
if (cmd_OptionPresent(opts, OPT_peer))
rx_enablePeerRPCStats();
@ -1368,7 +1395,6 @@ ParseArgs(int argc, char *argv[])
busy_threshold = 3 * rxpackets / 2;
}
cmd_OptionAsString(opts, OPT_logfile, &logFile);
cmd_OptionAsString(opts, OPT_config, &FS_configPath);
@ -1809,7 +1835,7 @@ main(int argc, char *argv[])
CheckParms();
FS_configPath = strdup(AFSDIR_SERVER_ETC_DIRPATH);
logFile = strdup(AFSDIR_SERVER_FILELOG_FILEPATH);
memset(&logopts, 0, sizeof(logopts));
if (ParseArgs(argc, argv)) {
exit(-1);
@ -1834,11 +1860,7 @@ main(int argc, char *argv[])
/* initialize audit user check */
osi_audit_set_user_check(confDir, fs_IsLocalRealmMatch);
/* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
#ifndef AFS_NT40_ENV
serverLogSyslogTag = "fileserver";
#endif
OpenLog(logFile);
OpenLog(&logopts);
LogCommandLine(argc, argv, "starting", "", "File server", FSLog);
if (afsconf_GetLatestKey(confDir, NULL, NULL) == 0) {

View File

@ -15,7 +15,6 @@ afs_int32 sys_error_to_et(afs_int32 in);
void init_sys_error_to_et(void);
/* afsfileprocs.c */
extern int LogLevel;
extern afs_int32 BlocksSpare;
extern afs_int32 PctSpare;

View File

@ -52,7 +52,6 @@ afs_uint32 rd_HostAddress[MAXSERVERID + 1];
afs_uint32 wr_HostAddress[MAXSERVERID + 1];
static void *CheckSignal(void*);
int LogLevel = 0;
int smallMem = 0;
int restrictedQueryLevel = RESTRICTED_QUERY_ANYUSER;
int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
@ -147,7 +146,9 @@ enum optionsList {
OPT_database,
OPT_logfile,
OPT_threads,
#ifdef HAVE_SYSLOG
OPT_syslog,
#endif
OPT_peer,
OPT_process,
OPT_nojumbo,
@ -176,10 +177,10 @@ main(int argc, char **argv)
char clones[MAXHOSTSPERCELL];
afs_uint32 host = ntohl(INADDR_ANY);
struct cmd_syndesc *opts;
struct logOptions logopts;
char *vl_dbaseName;
char *configDir;
char *logFile;
char *auditFileName = NULL;
char *interface = NULL;
@ -205,6 +206,8 @@ main(int argc, char **argv)
#endif
osi_audit_init();
memset(&logopts, 0, sizeof(logopts));
/* Initialize dirpaths */
if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
#ifdef AFS_NT40_ENV
@ -217,7 +220,6 @@ main(int argc, char **argv)
vl_dbaseName = strdup(AFSDIR_SERVER_VLDB_FILEPATH);
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
logFile = strdup(AFSDIR_SERVER_VLOG_FILEPATH);
cmd_DisableAbbreviations();
cmd_DisablePositionalCommands();
@ -245,7 +247,7 @@ main(int argc, char **argv)
CMD_OPTIONAL, "location of logfile");
cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE, CMD_OPTIONAL,
"number of threads");
#if !defined(AFS_NT40_ENV)
#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
@ -308,9 +310,7 @@ main(int argc, char **argv)
free(interface);
}
cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
cmd_OptionAsString(opts, OPT_database, &vl_dbaseName);
cmd_OptionAsString(opts, OPT_logfile, &logFile);
if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
if (lwps > MAXLWP) {
@ -319,12 +319,32 @@ main(int argc, char **argv)
lwps = MAXLWP;
}
}
#ifndef AFS_NT40_ENV
cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
serverLogSyslog = 1;
cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
}
if (cmd_OptionPresent(opts, OPT_logfile)) {
fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
return -1;
}
logopts.lopt_dest = logDest_syslog;
logopts.lopt_facility = LOG_DAEMON; /* default value */
logopts.lopt_tag = "vlserver";
cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
} else
#endif
{
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
if (cmd_OptionPresent(opts, OPT_logfile))
cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
else
logopts.lopt_filename = AFSDIR_SERVER_VLOG_FILEPATH;
}
/* rx options */
if (cmd_OptionPresent(opts, OPT_peer))
@ -362,10 +382,7 @@ main(int argc, char **argv)
osi_audit_file(auditFileName);
}
#ifndef AFS_NT40_ENV
serverLogSyslogTag = "vlserver";
#endif
OpenLog(logFile); /* set up logging */
OpenLog(&logopts);
#ifdef AFS_PTHREAD_ENV
opr_softsig_Init();
SetupLogSoftSignals();

View File

@ -60,8 +60,6 @@
#ifdef FSSYNC_BUILD_CLIENT
extern int LogLevel;
static SYNC_client_state fssync_state =
{ -1, /* file descriptor */
FSSYNC_ENDPOINT_DECL, /* server endpoint */

View File

@ -143,7 +143,6 @@ static void GetHandler(struct pollfd *fds, int maxfds, int events, int *nfds);
static void CallHandler(fd_set * fdsetp);
static void GetHandler(fd_set * fdsetp, int *maxfdp);
#endif
extern int LogLevel;
static afs_int32 FSYNC_com_VolOp(osi_socket fd, SYNC_command * com, SYNC_response * res);
@ -1063,7 +1062,7 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res)
if (vp) {
if (VVolOpLeaveOnline_r(vp, &info)) {
VUpdateVolume_r(&error, vp, VOL_UPDATE_WAIT); /* At least get volume stats right */
if (LogLevel) {
if (GetLogLevel() > 0) {
Log("FSYNC: Volume %" AFS_VOLID_FMT " (%s) was left on line for an external %s request\n",
afs_printable_VolumeId_lu(V_id(vp)), V_name(vp),
vcom->hdr->reason == V_CLONE ? "clone" :

View File

@ -138,7 +138,7 @@ static pthread_cond_t worker_cv;
static void * SalvageChildReaperThread(void *);
static int DoSalvageVolume(struct SalvageQueueNode * node, int slot);
static void SalvageServer(int argc, char **argv);
static void SalvageServer(int argc, char **argv, struct logOptions *logopts);
static void SalvageClient(VolumeId vid, char * pname);
static int Reap_Child(char * prog, int * pid, int * status);
@ -194,6 +194,9 @@ handleit(struct cmd_syndesc *opts, void *arock)
VolumeId vid = 0;
struct cmdline_rock *rock = (struct cmdline_rock *)arock;
char *optstring = NULL;
struct logOptions logopts;
memset(&logopts, 0, sizeof(logopts));
#ifdef AFS_SGI_VNODE_GLUE
if (afs_init_kernel_config(-1) < 0) {
@ -253,12 +256,30 @@ handleit(struct cmd_syndesc *opts, void *arock)
free(optstring);
optstring = NULL;
}
#ifndef AFS_NT40_ENV /* ignore options on NT */
#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
serverLogSyslog = 1;
}
cmd_OptionAsInt(opts, OPT_syslogfacility, &serverLogSyslogFacility);
if (cmd_OptionPresent(opts, OPT_logfile)) {
fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
return -1;
}
logopts.lopt_dest = logDest_syslog;
logopts.lopt_facility = LOG_DAEMON;
logopts.lopt_tag = "salvageserver";
cmd_OptionAsInt(opts, OPT_syslogfacility, &logopts.lopt_facility);
} else
#endif
{
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
if (cmd_OptionPresent(opts, OPT_logfile))
cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
else
logopts.lopt_filename = AFSDIR_SERVER_SALSRVLOG_FILEPATH;
}
if (cmd_OptionPresent(opts, OPT_client)) {
if (cmd_OptionAsString(opts, OPT_partition, &optstring) == 0) {
@ -287,7 +308,7 @@ handleit(struct cmd_syndesc *opts, void *arock)
SalvageClient(vid, pname);
} else { /* salvageserver mode */
SalvageServer(rock->argc, rock->argv);
SalvageServer(rock->argc, rock->argv, &logopts);
}
return (0);
}
@ -393,7 +414,7 @@ main(int argc, char **argv)
cmd_AddParmAtOffset(ts, OPT_orphans, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
"ignore | remove | attach");
#if !defined(AFS_NT40_ENV)
#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(ts, OPT_syslog, "-syslog", CMD_FLAG, CMD_OPTIONAL,
"Write salvage log to syslogs");
cmd_AddParmAtOffset(ts, OPT_syslogfacility, "-syslogfacility", CMD_SINGLE,
@ -474,7 +495,7 @@ SalvageClient(VolumeId vid, char * pname)
static int * child_slot;
static void
SalvageServer(int argc, char **argv)
SalvageServer(int argc, char **argv, struct logOptions *logopts)
{
int pid, ret;
struct SalvageQueueNode * node;
@ -486,7 +507,7 @@ SalvageServer(int argc, char **argv)
/* All entries to the log will be appended. Useful if there are
* multiple salvagers appending to the log.
*/
OpenLog(AFSDIR_SERVER_SALSRVLOG_FILEPATH);
OpenLog(logopts);
SetupLogSignals();
Log("%s\n", cml_version_number);
@ -580,7 +601,8 @@ SalvageServer(int argc, char **argv)
static int
DoSalvageVolume(struct SalvageQueueNode * node, int slot)
{
char *childLog;
char *filename = NULL;
struct logOptions logopts;
struct DiskPartition64 * partP;
/* do not allow further forking inside salvager */
@ -591,13 +613,17 @@ DoSalvageVolume(struct SalvageQueueNode * node, int slot)
* another thread may have held the lock when fork was
* called!
*/
if (asprintf(&childLog, "%s.%d",
memset(&memset, 0, sizeof(logopts));
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateStyle = logRotate_none;
if (asprintf(&filename, "%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH, getpid()) < 0) {
fprintf(stderr, "out of memory\n");
return ENOMEM;
}
OpenLog(childLog);
free(childLog);
logopts.lopt_filename = filename;
OpenLog(&logopts);
free(filename);
if (node->command.sop.parent <= 0) {
Log("salvageServer: invalid volume id specified; salvage aborted\n");

View File

@ -111,7 +111,6 @@
pthread_t main_thread;
#endif
extern char *ShowLogFilename;
extern char cml_version_number[];
static int get_salvage_lock = 0;
@ -120,7 +119,6 @@ struct CmdLine {
char **argv;
};
#ifndef AFS_NT40_ENV
static int
TimeStampLogFile(char **logfile)
{
@ -137,11 +135,9 @@ TimeStampLogFile(char **logfile)
lt->tm_min, lt->tm_sec) < 0) {
return ENOMEM;
}
free(*logfile); /* free the default name */
*logfile = stampSlvgLog;
return 0;
}
#endif
static int
handleit(struct cmd_syndesc *as, void *arock)
@ -152,15 +148,18 @@ handleit(struct cmd_syndesc *as, void *arock)
afs_int32 seenpart = 0, seenvol = 0;
VolumeId vid = 0;
ProgramType pt;
char *logfile = strdup(AFSDIR_SERVER_SLVGLOG_FILEPATH);
#ifdef FAST_RESTART
afs_int32 seenany = 0;
#endif
char *filename = NULL;
struct logOptions logopts;
VolumePackageOptions opts;
struct DiskPartition64 *partP;
memset(&logopts, 0, sizeof(logopts));
#ifdef AFS_SGI_VNODE_GLUE
if (afs_init_kernel_config(-1) < 0) {
printf
@ -274,30 +273,47 @@ handleit(struct cmd_syndesc *as, void *arock)
|| strcmp(ti->data, "a") == 0)
orphans = ORPH_ATTACH;
}
#ifndef AFS_NT40_ENV /* ignore options on NT */
if ((ti = as->parms[16].items)) { /* -syslog */
if (ShowLog) {
fprintf(stderr, "Invalid options: -syslog and -showlog are exclusive.\n");
Exit(1);
}
serverLogSyslog = 1;
}
if ((ti = as->parms[17].items)) { /* -syslogfacility */
serverLogSyslogFacility = atoi(ti->data);
}
if ((ti = as->parms[18].items)) { /* -datelogs */
int code = TimeStampLogFile(&logfile);
if (code != 0) {
fprintf(stderr, "Failed to format log file name for -datelogs; code=%d\n", code);
Exit(code);
if ((ti = as->parms[18].items)) { /* -datelogs */
fprintf(stderr, "Invalid option: -syslog and -datelogs are exclusive.\n");
Exit(1);
}
ShowLogFilename = logfile;
}
#endif
#ifndef HAVE_SYSLOG
/* Do not silently ignore. */
fprintf(stderr, "Invalid option: -syslog is not available on this platform.\n");
Exit(1);
#else
logopts.lopt_dest = logDest_syslog;
logopts.lopt_tag = "salvager";
OpenLog(logfile);
if ((ti = as->parms[17].items)) /* -syslogfacility */
logopts.lopt_facility = atoi(ti->data);
else
logopts.lopt_facility = LOG_DAEMON; /* default value */
#endif
} else {
logopts.lopt_dest = logDest_file;
if ((ti = as->parms[18].items)) { /* -datelogs */
int code = TimeStampLogFile(&filename);
if (code != 0) {
fprintf(stderr, "Failed to format log file name for -datelogs; code=%d\n", code);
Exit(code);
}
logopts.lopt_filename = filename;
} else {
logopts.lopt_filename = AFSDIR_SERVER_SLVGLOG_FILEPATH;
}
}
OpenLog(&logopts);
SetupLogSignals();
free(filename); /* Free string created by -datelogs, if one. */
Log("%s\n", cml_version_number);
LogCommandLine(cmdline->argc, cmdline->argv, "SALVAGER", SalvageVersion, "STARTING AFS", Log);

View File

@ -40,7 +40,6 @@
* SALVSYNC is a feature specific to the demand attach fileserver
*/
extern int LogLevel;
extern int VInit;
extern pthread_mutex_t vol_salvsync_mutex;

View File

@ -115,7 +115,6 @@ static afs_int32 SALVSYNC_com_CancelAll(SALVSYNC_command * com, SALVSYNC_respons
static afs_int32 SALVSYNC_com_Link(SALVSYNC_command * com, SALVSYNC_response * res);
extern int LogLevel;
extern int VInit;
extern pthread_mutex_t vol_salvsync_mutex;

View File

@ -54,8 +54,6 @@ struct VnodeClassInfo VnodeClassInfo[nVNODECLASSES];
void VNLog(afs_int32 aop, afs_int32 anparms, ... );
extern int LogLevel;
/* logging stuff for finding bugs */
#define THELOGSIZE 5120
static afs_int32 theLog[THELOGSIZE];
@ -951,7 +949,7 @@ VnLoad(Error * ec, Volume * vp, Vnode * vnp,
Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); volume needs salvage\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
} else {
/* vnode is not allocated */
if (LogLevel >= 5)
if (GetLogLevel() >= 5)
Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); read %d bytes, errno %d\n",
Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp), (int)nBytes, errno);
*ec = VNOVNODE;

View File

@ -603,7 +603,11 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
numjobs++;
} else {
int fd;
char *logFileName;
char *filename;
struct logOptions logopts;
memset(&logopts, 0, sizeof(logopts));
logopts.lopt_dest = logDest_file;
for (fd = 0; fd < 16; fd++)
close(fd);
@ -612,11 +616,12 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
dup2(0, 2);
ShowLog = 0; /* Child processes do not display. */
if (asprintf(&logFileName, "%s.%d",
if (asprintf(&filename, "%s.%d",
AFSDIR_SERVER_SLVGLOG_FILEPATH,
jobs[startjob]->jobnumb) >= 0) {
OpenLog(logFileName);
free(logFileName);
logopts.lopt_filename = filename;
OpenLog(&logopts);
free(filename);
}
SalvageFileSys1(jobs[startjob]->partP, 0);
@ -626,10 +631,11 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
}
} /* while ( thisjob || (!partP && numjobs > 0) ) */
/* If waited for all jobs to complete, now collect log files and return */
#ifndef AFS_NT40_ENV
if (!serverLogSyslog) /* if syslogging - no need to collect */
#endif
/*
* If waited for all jobs to complete, now collect log files and return.
* No files can be collected when logging to the system log (syslog).
*/
if (GetLogDest() == logDest_file) {
if (!partP) {
char *buf = calloc(1, SALV_BUFFER_SIZE);
char *logFileName;
@ -655,7 +661,7 @@ SalvageFileSysParallel(struct DiskPartition64 *partP)
free(buf);
}
}
}
return;
}
@ -4842,17 +4848,17 @@ static void
SalvageShowLog(void)
{
char line[256];
char *filename;
FILE *logFile;
if (ShowLog == 0 || ClientMode) {
return;
}
if (ShowLogFilename == NULL) {
ShowLogFilename = strdup(AFSDIR_SERVER_SLVGLOG_FILEPATH);
return; /* nothing to do */
}
filename = strdup(GetLogFilename());
opr_Assert(filename != NULL);
CloseLog();
logFile = afs_fopen(ShowLogFilename, "r");
logFile = afs_fopen(filename, "r");
if (!logFile)
printf("Can't read %s, exiting\n", ShowLogFilename);
else {
@ -4860,6 +4866,7 @@ SalvageShowLog(void)
printf("%s", line);
fflush(stdout);
}
free(filename);
}
static void

View File

@ -176,8 +176,6 @@ static int VCheckDetach(Volume * vp);
static Volume * GetVolume(Error * ec, Error * client_ec, VolumeId volumeId,
Volume * hint, const struct timespec *ts);
int LogLevel; /* Vice loglevel--not defined as extern so that it will be
* defined when not linked with vice, XXXX */
ProgramType programType; /* The type of program using the package */
static VolumePackageOptions vol_opts;
@ -1125,7 +1123,7 @@ VAttachVolumesByPartition(struct DiskPartition64 *diskP, int * nAttached, int *
(*(vp ? nAttached : nUnattached))++;
if (error == VOFFLINE)
Log("Volume %d stays offline (/vice/offline/%s exists)\n", VolumeNumber(dp->d_name), dp->d_name);
else if (LogLevel >= 5) {
else if (GetLogLevel() >= 5) {
Log("Partition %s: attached volume %d (%s)\n",
diskP->name, VolumeNumber(dp->d_name),
dp->d_name);
@ -1356,7 +1354,7 @@ VShutdown_r(void)
for (queue_Scan(&VolumeHashTable.Table[i],vp,np,Volume)) {
code = VHold_r(vp);
if (code == 0) {
if (LogLevel >= 5)
if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
@ -1844,7 +1842,7 @@ VShutdownVolume_r(Volume * vp)
VCreateReservation_r(vp);
if (LogLevel >= 5) {
if (GetLogLevel() >= 5) {
Log("VShutdownVolume_r: vid=%" AFS_VOLID_FMT ", device=%d, state=%u\n",
afs_printable_VolumeId_lu(vp->hashid), vp->partition->device,
(unsigned int) V_attachState(vp));
@ -1872,7 +1870,7 @@ VShutdownVolume_r(Volume * vp)
case VOL_STATE_ATTACHED:
code = VHold_r(vp);
if (!code) {
if (LogLevel >= 5)
if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
@ -2299,7 +2297,7 @@ VPreAttachVolumeByVp_r(Error * ec,
VLRU_Init_Node_r(vp);
VChangeState_r(vp, VOL_STATE_PREATTACHED);
if (LogLevel >= 5)
if (GetLogLevel() >= 5)
Log("VPreAttachVolumeByVp_r: volume %" AFS_VOLID_FMT " pre-attached\n", afs_printable_VolumeId_lu(vp->hashid));
done:
@ -2578,7 +2576,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode)
goto done;
}
}
if (LogLevel)
if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n", afs_printable_VolumeId_lu(V_id(vp)),
V_name(vp));
}
@ -2728,7 +2726,7 @@ VAttachVolumeByVp_r(Error * ec, Volume * vp, int mode)
goto done;
}
}
if (LogLevel)
if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n",
afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
done:
@ -4233,7 +4231,7 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
VGET_CTR_INC(V6);
/* Only log the error if it was a totally unexpected error. Simply
* a missing inode is likely to be caused by the volume being deleted */
if (errno != ENXIO || LogLevel)
if (errno != ENXIO || GetLogLevel() != 0)
Log("Volume %" AFS_VOLID_FMT ": couldn't reread volume header\n",
afs_printable_VolumeId_lu(vp->hashid));
#ifdef AFS_DEMAND_ATTACH_FS
@ -4481,7 +4479,7 @@ VScanCalls_r(struct Volume *vp)
#endif /* AFS_DEMAND_ATTACH_FS */
for(queue_Scan(&vp->rx_call_list, cbv, ncbv, VCallByVol)) {
if (LogLevel > 0) {
if (GetLogLevel() != 0) {
struct rx_peer *peer;
char hoststr[16];
peer = rx_PeerOf(rx_ConnectionOf(cbv->call));
@ -5172,7 +5170,7 @@ VCheckOffline(Volume * vp)
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
if (LogLevel) {
if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
@ -5211,7 +5209,7 @@ VCheckOffline(Volume * vp)
V_inUse(vp) = 0;
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
if (LogLevel) {
if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
@ -7218,7 +7216,7 @@ VInitVLRU(void)
/* setup the timing constants */
VLRU_ComputeConstants();
/* XXX put inside LogLevel check? */
/* XXX put inside log level check? */
Log("VLRU: starting scanner with the following configuration parameters:\n");
Log("VLRU: offlining volumes after minimum of %d seconds of inactivity\n", VLRU_offline_thresh);
Log("VLRU: running VLRU soft detach pass every %d seconds\n", VLRU_offline_interval);

View File

@ -80,7 +80,7 @@ int DoPreserveVolumeStats = 0;
int rxJumbograms = 0; /* default is to not send and receive jumbograms. */
int rxMaxMTU = -1;
char *auditFileName = NULL;
char *logFile = NULL;
static struct logOptions logopts;
char *configDir = NULL;
#define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
@ -236,7 +236,9 @@ enum optionsList {
OPT_process,
OPT_preserve_vol_stats,
OPT_sync,
#ifdef HAVE_SYSLOG
OPT_syslog,
#endif
OPT_logfile,
OPT_config,
OPT_restricted_query
@ -283,7 +285,7 @@ ParseArgs(int argc, char **argv) {
CMD_OPTIONAL, "enable RX RPC statistics");
cmd_AddParmAtOffset(opts, OPT_preserve_vol_stats, "-preserve-vol-stats", CMD_FLAG,
CMD_OPTIONAL, "preserve volume statistics");
#if !defined(AFS_NT40_ENV)
#ifdef HAVE_SYSLOG
cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
CMD_OPTIONAL, "log to syslog");
#endif
@ -307,7 +309,6 @@ ParseArgs(int argc, char **argv) {
cmd_OptionAsFlag(opts, OPT_rxbind, &rxBind);
cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck);
cmd_OptionAsFlag(opts, OPT_preserve_vol_stats, &DoPreserveVolumeStats);
cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
if (cmd_OptionPresent(opts, OPT_peer))
rx_enablePeerRPCStats();
if (cmd_OptionPresent(opts, OPT_process))
@ -316,12 +317,31 @@ ParseArgs(int argc, char **argv) {
rxJumbograms = 0;
if (cmd_OptionPresent(opts, OPT_jumbo))
rxJumbograms = 1;
#ifndef AFS_NT40_ENV
#ifdef HAVE_SYSLOG
if (cmd_OptionPresent(opts, OPT_syslog)) {
serverLogSyslog = 1;
cmd_OptionAsInt(opts, OPT_syslog, &serverLogSyslogFacility);
}
if (cmd_OptionPresent(opts, OPT_logfile)) {
fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
return -1;
}
logopts.lopt_dest = logDest_syslog;
logopts.lopt_facility = LOG_DAEMON;
logopts.lopt_tag = "volserver";
cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
} else
#endif
{
logopts.lopt_dest = logDest_file;
logopts.lopt_rotateOnOpen = 1;
logopts.lopt_rotateStyle = logRotate_old;
if (cmd_OptionPresent(opts, OPT_logfile))
cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
else
logopts.lopt_filename = AFSDIR_SERVER_VOLSERLOG_FILEPATH;
}
cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
cmd_OptionAsInt(opts, OPT_rxmaxmtu, &rxMaxMTU);
if (cmd_OptionAsInt(opts, OPT_udpsize, &optval) == 0) {
if (optval < rx_GetMinUdpBufSize()) {
@ -355,7 +375,6 @@ ParseArgs(int argc, char **argv) {
return -1;
}
}
cmd_OptionAsString(opts, OPT_logfile, &logFile);
cmd_OptionAsString(opts, OPT_config, &configDir);
if (cmd_OptionAsString(opts, OPT_restricted_query,
&restricted_query_parameter) == 0) {
@ -415,7 +434,6 @@ main(int argc, char **argv)
}
configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
logFile = strdup(AFSDIR_SERVER_VOLSERLOG_FILEPATH);
if (ParseArgs(argc, argv)) {
exit(1);
@ -445,9 +463,8 @@ main(int argc, char **argv)
exit(1);
}
#endif
/* Open VolserLog and map stdout, stderr into it; VInitVolumePackage2 can
log, so we need to do this here */
OpenLog(logFile);
OpenLog(&logopts);
VOptDefaults(volumeServer, &opts);
if (VInitVolumePackage2(volumeServer, &opts)) {