From: Michael Meffie Date: Wed, 9 Sep 2015 17:22:26 +0000 (-0400) Subject: salvager: redd up showlog global flag X-Git-Tag: openafs-stable-1_8_0pre1~194 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=d646387c8e52eb13fc36e95f5cfe21360d3e056e salvager: redd up showlog global flag Clean up the show log flag so it is only set by the salvager and is reset when spawning a child process. Change-Id: I1702cf98faca583409594d1199a8215ffe08a75e Reviewed-on: http://gerrit.openafs.org/12001 Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c index 7e4717b..dca7792 100644 --- a/src/vol/salvaged.c +++ b/src/vol/salvaged.c @@ -606,7 +606,6 @@ DoSalvageVolume(struct SalvageQueueNode * node, int slot) logFile = afs_fopen(childLog, "a"); if (!logFile) { /* still nothing, use stdout */ logFile = stdout; - ShowLog = 0; } free(childLog); } diff --git a/src/vol/salvager.c b/src/vol/salvager.c index d9b96ad..bd5119f 100644 --- a/src/vol/salvager.c +++ b/src/vol/salvager.c @@ -252,7 +252,6 @@ handleit(struct cmd_syndesc *as, void *arock) #ifndef AFS_NT40_ENV /* ignore options on NT */ if ((ti = as->parms[16].items)) { /* -syslog */ useSyslog = 1; - ShowLog = 0; } if ((ti = as->parms[17].items)) { /* -syslogfacility */ useSyslogFacility = atoi(ti->data); diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 8ad286d..4a7b2eb 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -281,6 +281,8 @@ char *tmpdir = NULL; /* Forward declarations */ +static void QuietExit(int) AFS_NORETURN; +static void SalvageShowLog(void); static int IsVnodeOrphaned(struct SalvInfo *salvinfo, VnodeId vnode); static int AskVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber); @@ -608,7 +610,7 @@ SalvageFileSysParallel(struct DiskPartition64 *partP) } else { int fd; - ShowLog = 0; + ShowLog = 0; /* Child processes do not display. */ for (fd = 0; fd < 16; fd++) close(fd); open(OS_DIRSEP, 0); @@ -663,8 +665,7 @@ SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) if (!canfork || debug || Fork() == 0) { SalvageFileSys1(partP, singleVolumeNumber); if (canfork && !debug) { - ShowLog = 0; - Exit(0); + QuietExit(0); } } else Wait("SalvageFileSys"); @@ -1304,8 +1305,7 @@ GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile, VolumeId singleVolume goto error; } if (canfork && !debug) { - ShowLog = 0; - Exit(0); + QuietExit(0); } } else { if (Wait("Inode summary") == -1) { @@ -2192,8 +2192,7 @@ DoSalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nV IH_RELEASE(salvinfo->VGLinkH); if (canfork && !debug) { - ShowLog = 0; - Exit(0); + QuietExit(0); } } @@ -4763,12 +4762,9 @@ Fork(void) return f; } -void -Exit(int code) +static void +QuietExit(int code) { - if (ShowLog) - showlog(); - #ifdef AFS_DEMAND_ATTACH_FS if (programType == salvageServer) { /* release all volume locks before closing down our SYNC channels. @@ -4802,6 +4798,14 @@ Exit(int code) #endif } +void +Exit(int code) +{ + SalvageShowLog(); + QuietExit(code); +} + + int Wait(char *prog) { @@ -4836,7 +4840,6 @@ CheckLogFile(char * log_path) #ifndef AFS_NT40_ENV if (useSyslog) { - ShowLog = 0; return; } #endif @@ -4850,7 +4853,6 @@ CheckLogFile(char * log_path) if (!logFile) { /* still nothing, use stdout */ logFile = stdout; - ShowLog = 0; } #ifndef AFS_NAMEI_ENV AFS_DEBUG_IOPS_LOG(logFile); @@ -4881,11 +4883,15 @@ TimeStampLogFile(char * log_path) } #endif -void -showlog(void) +static void +SalvageShowLog(void) { char line[256]; + if (ShowLog == 0 || logFile == stdout || logFile == stderr) { + return; + } + #ifndef AFS_NT40_ENV if (useSyslog) { printf("Can't show log since using syslog.\n"); @@ -4950,13 +4956,12 @@ Abort(const char *format, ...) if (logFile) { fprintf(logFile, "%s", tmp); fflush(logFile); - if (ShowLog) - showlog(); + SalvageShowLog(); } if (debug) abort(); - Exit(1); + QuietExit(1); } char * diff --git a/src/vol/vol-salvage.h b/src/vol/vol-salvage.h index 014cf68..83bc55f 100644 --- a/src/vol/vol-salvage.h +++ b/src/vol/vol-salvage.h @@ -252,7 +252,6 @@ extern int SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp, struct ViceInodeInfo *inodes, int RW, int check, int *deleteMe); -extern void showlog(void); extern int UseTheForceLuke(char *path);