From ff07fa706e00f6dde13c58588d2f75e7fc26ecf5 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 10 Jan 2020 09:06:38 -0500 Subject: [PATCH 01/11] tests: do not resolve addresses in vos/vl test The vos-t test adds a set of 10.* test addresses to a test vlserver and runs vos to read them back. When the test is run in an environment where hosts have been assigned in the 10.* internal network, vos will resolve the addresses to hostnames and the test fails. Pass the -noresolve option to vos for this test when checking for the expected list of addresses. Example test output before this commit: ./vos-t ... # seen: 10.0.0.0 10.0.0.1 myhost.example.com 10.0.0.3 ... not ok 5 - vos output matches Reviewed-on: https://gerrit.openafs.org/14020 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit dcf44ab5fc5c1f5e2e759ea4b6156f7e1faa4b7a) Change-Id: Ie2a6d97070fe47886a1ccf8c0ddf03012f805beb Reviewed-on: https://gerrit.openafs.org/14105 Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- tests/volser/vos-t.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/volser/vos-t.c b/tests/volser/vos-t.c index 57161f477..a82316add 100644 --- a/tests/volser/vos-t.c +++ b/tests/volser/vos-t.c @@ -78,7 +78,7 @@ TestListAddrs(struct ubik_client *client, char *dirname) exit(1); } execl(binPath, "vos", - "listaddrs", "-config", dirname, "-noauth", NULL); + "listaddrs", "-config", dirname, "-noauth", "-noresolve", NULL); exit(1); } close(outpipe[1]); -- 2.27.0 From 278592ef2d766c77de821b9da80359f24fec5b62 Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Mon, 27 Jan 2020 12:26:41 -0500 Subject: [PATCH 02/11] uss: more gcc9 truncation warning appeasement uss_procs_PickADir needs a larger buffer to avoid a truncation warning. While here, replace some magic numbers with existing symbols. Reviewed-on: https://gerrit.openafs.org/14049 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk (cherry picked from commit 6c54bc9e121b923ec5fdd60ee510171987e55017) Change-Id: I5cb76a8a9b2a9b342a1ddae2f41ecab82f762326 Reviewed-on: https://gerrit.openafs.org/14140 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Stephan Wiesand --- src/uss/uss_procs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uss/uss_procs.c b/src/uss/uss_procs.c index d7d4ad8bc..ff5619f74 100644 --- a/src/uss/uss_procs.c +++ b/src/uss/uss_procs.c @@ -659,12 +659,12 @@ afs_int32 uss_procs_PickADir(char *path, char *cp) { /*uss_procs_PickADir */ - char cd[300]; /*Current directory for search */ + char cd[uss_DirPoolLen]; /*Current directory for search */ int i, count, MinIndex = 0, mina = 10000; struct dirent *dp; DIR *dirp; - char dirname[301]; + char dirname[uss_DirPoolLen*2]; if (uss_NumGroups == 0) { fprintf(stderr, "%s: No choice yet given to replace $AUTO\n", -- 2.27.0 From a2eec64374d6b754b29c509b554573cb6e53eb46 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 22 May 2020 12:16:48 -0600 Subject: [PATCH 03/11] Avoid duplicate definitions of globals GCC 10 changed a default flag from -fcommon to -fno-common. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678 for some background. The change in gcc 10 results in build link-time errors. For example: ../../src/xstat/.libs/liboafs_xstat_cm.a(xstat_cm.o):(.bss+0x2050): multiple definition of `numCollections'; Ensure that only one definition for global data objects exist and change references to use "extern" as needed. To ensure that future changes do not introduce duplicated global definitions, add the -fno-common flag to XCFLAGS when using the configure --enable-checking setting. [cwills@sinenomine.net: Note for 1.8.x: renamed terminationEvent to cm_terminationEvent/fs_terminationEvent instead of deleting it.] Reviewed-on: https://gerrit.openafs.org/14106 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit 0e2072ae386d4111bef161eb955964b649c31386) Change-Id: I54ca61d372cf763e4a28c0b0829ea361219f6203 Reviewed-on: https://gerrit.openafs.org/14217 Reviewed-by: Andrew Deason Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/bucoord/main.c | 6 ++---- src/butc/dbentries.c | 2 +- src/butc/dump.c | 7 +++---- src/butc/lwps.c | 2 +- src/butc/tcmain.c | 2 +- src/cf/osconf.m4 | 2 +- src/fsprobe/fsprobe.h | 1 - src/uss/uss_vol.c | 2 +- src/viced/host.c | 2 ++ src/viced/host.h | 2 +- src/vol/fssync-server.c | 3 --- src/vol/volume.c | 3 --- src/xstat/xstat_cm.c | 7 +++---- src/xstat/xstat_cm.h | 3 +-- src/xstat/xstat_cm_test.c | 4 ++-- src/xstat/xstat_fs.c | 7 +++---- src/xstat/xstat_fs.h | 3 +-- src/xstat/xstat_fs_test.c | 4 ++-- 18 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/bucoord/main.c b/src/bucoord/main.c index d2a5f368b..a453cc9dd 100644 --- a/src/bucoord/main.c +++ b/src/bucoord/main.c @@ -47,9 +47,9 @@ char tcell[64]; /* * Global configuration information for the Backup Coordinator. */ -struct bc_config *bc_globalConfig; /*Ptr to global BC configuration info */ +extern struct bc_config *bc_globalConfig; /*Ptr to global BC configuration info */ -struct ubik_client *cstruct; /* Ptr to Ubik client structure */ +extern struct ubik_client *cstruct; /* Ptr to Ubik client structure */ time_t tokenExpires; /* The token's expiration time */ static const char *DefaultConfDir; /*Default backup config directory */ @@ -162,8 +162,6 @@ bc_InitTextConfig(void) udbClientTextP ctPtr; int i; - extern struct bc_config *bc_globalConfig; - mkdir(DefaultConfDir, 777); /* temporary */ /* initialize the client text structures */ diff --git a/src/butc/dbentries.c b/src/butc/dbentries.c index 37b35d307..29ddcbd01 100644 --- a/src/butc/dbentries.c +++ b/src/butc/dbentries.c @@ -31,7 +31,7 @@ #include "error_macros.h" dlqlinkT savedEntries; -dlqlinkT entries_to_flush; +static dlqlinkT entries_to_flush; int dbWatcherinprogress; diff --git a/src/butc/dump.c b/src/butc/dump.c index 1f4eb9b8f..f8fc943a6 100644 --- a/src/butc/dump.c +++ b/src/butc/dump.c @@ -42,8 +42,7 @@ extern int isafile; extern int forcemultiple; extern struct ubik_client *cstruct; -dlqlinkT savedEntries; -dlqlinkT entries_to_flush; +extern dlqlinkT savedEntries; extern afs_int32 groupId; extern afs_int32 BufferSize; @@ -61,8 +60,8 @@ extern char *xbsalGName; extern char *globalButcLog; #endif /*xbsa */ -afs_int32 dataSize; /* Size of data to read on each rx_Read() call */ -afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */ +extern afs_int32 dataSize; /* Size of data to read on each rx_Read() call */ +extern afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */ /* TBD * diff --git a/src/butc/lwps.c b/src/butc/lwps.c index d262991d8..aff5e9e07 100644 --- a/src/butc/lwps.c +++ b/src/butc/lwps.c @@ -51,7 +51,7 @@ extern int forcemultiple; #endif /* XBSA Global Parameters */ -afs_int32 xbsaType; +extern afs_int32 xbsaType; #ifdef xbsa struct butx_transactionInfo butxInfo; #endif diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index e8a20938e..a0298addb 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -66,7 +66,7 @@ #define TL_PREFIX "TL" #define CFG_PREFIX "CFG" -struct ubik_client *cstruct; +extern struct ubik_client *cstruct; FILE *logIO, *ErrorlogIO, *centralLogIO, *lastLogIO; char lFile[AFSDIR_PATH_MAX]; char logFile[AFSDIR_PATH_MAX + 256]; diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 5f0d73fc2..e36152bd4 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -672,7 +672,7 @@ if test "x$GCC" = "xyes"; then XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Wpointer-arith" fi if test "x$enable_checking" != "xno"; then - XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith" + XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith -fno-common" if test "x$enable_checking" != "xall"; then CFLAGS_NOERROR="-Wno-error" CFLAGS_NOUNUSED="-Wno-unused" diff --git a/src/fsprobe/fsprobe.h b/src/fsprobe/fsprobe.h index 94083bfe9..3060371ae 100644 --- a/src/fsprobe/fsprobe.h +++ b/src/fsprobe/fsprobe.h @@ -103,7 +103,6 @@ struct fsprobe_ProbeResults { extern int fsprobe_numServers; /*# servers connected */ extern struct fsprobe_ConnectionInfo *fsprobe_ConnInfo; /*Ptr to connections */ -extern int numCollections; /*Num data collections */ extern struct fsprobe_ProbeResults fsprobe_Results; /*Latest probe results */ extern int fsprobe_Init(int, struct sockaddr_in *, int, int (*)(void), int ); diff --git a/src/uss/uss_vol.c b/src/uss/uss_vol.c index c9c13941d..b31a42a06 100644 --- a/src/uss/uss_vol.c +++ b/src/uss/uss_vol.c @@ -61,7 +61,7 @@ extern int line; * will work and we can avoid nasty little core dumps. */ struct ubik_client *uconn_vldbP; /*Ubik connection struct */ -struct ubik_client *cstruct; /*Required name for above */ +extern struct ubik_client *cstruct; /*Required name for above */ /* * ------------------------ Private globals ----------------------- diff --git a/src/viced/host.c b/src/viced/host.c index 36f9e88c0..e7657caac 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -67,6 +67,8 @@ int hostCount = 0; /* number of hosts in hostList */ int rxcon_ident_key; int rxcon_client_key; +struct host *(hosttableptrs[h_MAXHOSTTABLES]); + static struct rx_securityClass *sc = NULL; static int h_quota_limit; diff --git a/src/viced/host.h b/src/viced/host.h index fead948f6..272dcdbe7 100644 --- a/src/viced/host.h +++ b/src/viced/host.h @@ -254,7 +254,7 @@ extern int h_RestoreState(void); #define H_ENUMERATE_BAIL(flags) ((flags)|0x80000000) #define H_ENUMERATE_ISSET_BAIL(flags) ((flags)&0x80000000) -struct host *(hosttableptrs[h_MAXHOSTTABLES]); /* Used by h_itoh */ +extern struct host *(hosttableptrs[h_MAXHOSTTABLES]); /* Used by h_itoh */ #define h_htoi(host) ((host)->index) /* index isn't zeroed, no need to lock */ #define h_itoh(hostindex) (hosttableptrs[(hostindex)>>h_HTSHIFT]+((hostindex)&(h_HTSPERBLOCK-1))) diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index 2d7cd6011..69d902f1b 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -79,9 +79,6 @@ #endif /* USE_UNIX_SOCKETS */ #ifdef FSSYNC_BUILD_SERVER - -int (*V_BreakVolumeCallbacks) (VolumeId volume); - #define MAXHANDLERS 4 /* Up to 4 clients; must be at least 2, so that * move = dump+restore can run on single server */ #define MAXOFFLINEVOLUMES 128 /* This needs to be as big as the maximum diff --git a/src/vol/volume.c b/src/vol/volume.c index f1ff10a7b..3d9e47ef3 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -124,9 +124,6 @@ pthread_cond_t vol_vinit_cond; int vol_attach_threads = 1; #endif /* AFS_PTHREAD_ENV */ -/* start-time configurable I/O parameters */ -ih_init_params vol_io_params; - #ifdef AFS_DEMAND_ATTACH_FS pthread_mutex_t vol_salvsync_mutex; diff --git a/src/xstat/xstat_cm.c b/src/xstat/xstat_cm.c index d8600c124..3f5bfc843 100644 --- a/src/xstat/xstat_cm.c +++ b/src/xstat/xstat_cm.c @@ -32,9 +32,8 @@ int xstat_cm_numServers; /*Num connected servers */ struct xstat_cm_ConnectionInfo *xstat_cm_ConnInfo; /*Ptr to connection array */ -int numCollections; /*Number of data collections */ struct xstat_cm_ProbeResults xstat_cm_Results; /*Latest probe results */ -char terminationEvent; /*One-shot termination event */ +char cm_terminationEvent; /*One-shot termination event */ afs_int32 xstat_cmData[AFSCB_MAX_XSTAT_LONGS]; /*Buffer for collected data */ @@ -315,8 +314,8 @@ xstat_cm_LWP(void *unused) */ if (xstat_cm_debug) printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn, - &terminationEvent); - oneShotCode = LWP_SignalProcess(&terminationEvent); + &cm_terminationEvent); + oneShotCode = LWP_SignalProcess(&cm_terminationEvent); if (oneShotCode) fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn, oneShotCode); diff --git a/src/xstat/xstat_cm.h b/src/xstat/xstat_cm.h index efbba531c..569011cc2 100644 --- a/src/xstat/xstat_cm.h +++ b/src/xstat/xstat_cm.h @@ -86,10 +86,9 @@ struct xstat_cm_ProbeResults { extern int xstat_cm_numServers; /*# connected servers */ extern struct xstat_cm_ConnectionInfo *xstat_cm_ConnInfo; /*Ptr to connections */ -extern int numCollections; /*Num data collections */ extern struct xstat_cm_ProbeResults xstat_cm_Results; /*Latest probe results */ -extern char terminationEvent; /*One-shot termination event */ +extern char cm_terminationEvent; /*One-shot termination event */ /* * ------------------------ Exported functions ------------------------ diff --git a/src/xstat/xstat_cm_test.c b/src/xstat/xstat_cm_test.c index b284237aa..7c5e56864 100644 --- a/src/xstat/xstat_cm_test.c +++ b/src/xstat/xstat_cm_test.c @@ -881,8 +881,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock) */ if (debugging_on) printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT - "\n", rn, &terminationEvent); - waitCode = LWP_WaitProcess(&terminationEvent); + "\n", rn, &cm_terminationEvent); + waitCode = LWP_WaitProcess(&cm_terminationEvent); if (debugging_on) printf("[%s] Returned from LWP_WaitProcess()\n", rn); if (waitCode) { diff --git a/src/xstat/xstat_fs.c b/src/xstat/xstat_fs.c index 51dbe3847..dff930472 100644 --- a/src/xstat/xstat_fs.c +++ b/src/xstat/xstat_fs.c @@ -33,9 +33,8 @@ int xstat_fs_numServers; /*Num connected servers */ struct xstat_fs_ConnectionInfo *xstat_fs_ConnInfo; /*Ptr to connection array */ -int numCollections; /*Number of data collections */ struct xstat_fs_ProbeResults xstat_fs_Results; /*Latest probe results */ -char terminationEvent; /*One-shot termination event */ +char fs_terminationEvent; /*One-shot termination event */ afs_int32 xstat_fsData[AFS_MAX_XSTAT_LONGS]; /*Buffer for collected data */ @@ -334,8 +333,8 @@ xstat_fs_LWP(void *unused) */ if (xstat_fs_debug) printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn, - &terminationEvent); - oneShotCode = LWP_SignalProcess(&terminationEvent); + &fs_terminationEvent); + oneShotCode = LWP_SignalProcess(&fs_terminationEvent); if (oneShotCode) fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn, oneShotCode); diff --git a/src/xstat/xstat_fs.h b/src/xstat/xstat_fs.h index 6e2b77b85..a800ba679 100644 --- a/src/xstat/xstat_fs.h +++ b/src/xstat/xstat_fs.h @@ -87,10 +87,9 @@ struct xstat_fs_ProbeResults { extern int xstat_fs_numServers; /*# connected servers */ extern struct xstat_fs_ConnectionInfo *xstat_fs_ConnInfo; /*Ptr to connections */ -extern int numCollections; /*Num data collections */ extern struct xstat_fs_ProbeResults xstat_fs_Results; /*Latest probe results */ -extern char terminationEvent; /*One-shot termination event */ +extern char fs_terminationEvent; /*One-shot termination event */ /* * ------------------------ Exported functions ------------------------ diff --git a/src/xstat/xstat_fs_test.c b/src/xstat/xstat_fs_test.c index 853c2121e..d58ecf014 100644 --- a/src/xstat/xstat_fs_test.c +++ b/src/xstat/xstat_fs_test.c @@ -778,8 +778,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy) */ if (debugging_on) printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT "\n", rn, - &terminationEvent); - waitCode = LWP_WaitProcess(&terminationEvent); + &fs_terminationEvent); + waitCode = LWP_WaitProcess(&fs_terminationEvent); if (debugging_on) printf("[%s] Returned from LWP_WaitProcess()\n", rn); if (waitCode) { -- 2.27.0 From d5fc5283e91ea94a67df8364a5b8bf8970ffe934 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 9 Oct 2017 22:16:09 -0400 Subject: [PATCH 04/11] afsmonitor: remove unused LWP_WaitProcess Remove the unimplemented once-only flag and the unused LWP_WaitProcess call. Reviewed-on: https://gerrit.openafs.org/12745 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 7c27365ea24aed5787f6fc03f30f6085c78ece51) Change-Id: I3b61f9fb4f45564304b0e35878d3535a10e31d02 Reviewed-on: https://gerrit.openafs.org/14226 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/afsmonitor/afsmonitor.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index e7b303071..a6a9e9741 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -56,7 +56,6 @@ int afsmon_debug = 0; /* debug info to file ? */ FILE *debugFD; /* debugging file descriptor */ static int afsmon_output = 0; /* output to file ? */ static int afsmon_detOutput = 0; /* detailed output ? */ -static int afsmon_onceOnly = 0; /* probe once only ? (not implemented) */ int afsmon_probefreq; /* probe frequency */ static int wpkg_to_use; /* graphics package to use */ static char output_filename[80]; /* output filename */ @@ -3794,8 +3793,6 @@ afsmon_execute(void) } FSinitFlags = 0; - if (afsmon_onceOnly) /* option not provided at this time */ - FSinitFlags |= XSTAT_FS_INITFLAG_ONE_SHOT; if (afsmon_debug) { fprintf(debugFD, "[ %s ] Calling xstat_fs_Init \n", rn); @@ -3867,8 +3864,6 @@ afsmon_execute(void) collIDs[num_cm_collections++] = AFSCB_XSTATSCOLL_FULL_PERF_INFO; CMinitFlags = 0; - if (afsmon_onceOnly) /* once only ? */ - CMinitFlags |= XSTAT_CM_INITFLAG_ONE_SHOT; if (afsmon_debug) { fprintf(debugFD, "[ %s ] Calling xstat_cm_Init \n", rn); @@ -3892,19 +3887,6 @@ afsmon_execute(void) /* end of process cache manager entries */ - /* if only one probe was required setup a waiting process for the - * termination signal */ - if (afsmon_onceOnly) { - code = LWP_WaitProcess(&terminationEvent); - if (code) { - if (afsmon_debug) { - fprintf(debugFD, "LWP_WaitProcess() returned error %d\n", - code); - fflush(debugFD); - } - afsmon_Exit(135); - } - } /* start the gtx input server */ code = (intptr_t)gtx_InputServer(afsmon_win); -- 2.27.0 From 5a14bd0abe83b580f0cc7a200ae963399ab7de5f Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Tue, 26 May 2020 12:11:28 -0600 Subject: [PATCH 05/11] vol: Fix format-truncation warning with gcc-10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building with gcc-10.1 produces a warning (error if --enable-checking) in vol-salvage.c error: ‘%s’ directive output may be truncated writing up to 755 bytes into a region of size 255 [-Werror=format-truncation=] 809 | snprintf(inodeListPath, 255, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name, Use strdup/asprintf to allocate the buffer dynamically instead of using a buffer with a hardcoded size. Reviewed-on: https://gerrit.openafs.org/14207 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit d73680c5f70ee5aeb634a9ec88bf1097743d0f76) Change-Id: I8d3bf244a70f723f585738905deea7ddfb1bb862 Reviewed-on: https://gerrit.openafs.org/14232 Reviewed-by: Mark Vitale Tested-by: Cheyenne Wills Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/vol/vol-salvage.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index fb6c83d24..006aca1a5 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -701,7 +701,7 @@ void SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) { char *name, *tdir; - char inodeListPath[256]; + char *inodeListPath = NULL; FD_t inodeFile = INVALID_FD; static char tmpDevName[100]; static char wpath[100]; @@ -811,10 +811,16 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) tdir = (tmpdir ? tmpdir : salvinfo->fileSysPath); #ifdef AFS_NT40_ENV (void)_putenv("TMP="); /* If "TMP" is set, then that overrides tdir. */ - (void)strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255); + inodeListPath = strdup(_tempnam(tdir, "salvage.inodes.")); + if (inodeListPath == NULL) { + Abort("Error allocating memory for inodeListPath\n"); + } #else - snprintf(inodeListPath, 255, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name, + code = asprintf(&inodeListPath, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name, getpid()); + if (code == -1) { + Abort("Error allocating memory for inodeListPath\n"); + } #endif inodeFile = OS_OPEN(inodeListPath, O_RDWR|O_TRUNC|O_CREAT, 0666); @@ -843,11 +849,16 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) if (GetInodeSummary(salvinfo, inodeFile, singleVolumeNumber) < 0) { OS_CLOSE(inodeFile); + free(inodeListPath); return; } salvinfo->inodeFd = inodeFile; if (salvinfo->inodeFd == INVALID_FD) Abort("Temporary file %s is missing...\n", inodeListPath); + + free(inodeListPath); + inodeListPath = NULL; + OS_SEEK(salvinfo->inodeFd, 0L, SEEK_SET); if (ListInodeOption) { PrintInodeList(salvinfo); -- 2.27.0 From 0f67e733e82a9001f3f9253c5e1880be845d537b Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Thu, 2 Apr 2020 13:27:50 -0600 Subject: [PATCH 06/11] LINUX: Include linux/time.h for linux/errqueue.h The configuration test for errqueue.h fails with an undefined structure error on a Linux 3.17 (or higher) system. This prevents setting HAVE_LINUX_ERRQUEUE_H, which is used to define AFS_RXERRQ_ENV. Linux commit f24b9be5957b38bb420b838115040dc2031b7d0c (net-timestamp: extend SCM_TIMESTAMPING ancillary data struct) - which was picked up in linux 3.17 added a structure that uses the timespec structure. After this commit, we need to include linux/time.h to pull in the definition of the timespec struct. Reviewed-on: https://gerrit.openafs.org/13950 Reviewed-by: Andrew Deason Tested-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit 086d185872da5f19447cf5ec7846e7ce5104563f) Change-Id: I67d01b11c5ea95b8b87832fc833f8fc850ade684 Reviewed-on: https://gerrit.openafs.org/14130 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/cf/headers.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cf/headers.m4 b/src/cf/headers.m4 index 913af4403..af4a4ddb8 100644 --- a/src/cf/headers.m4 +++ b/src/cf/headers.m4 @@ -88,7 +88,8 @@ AC_CHECK_HEADERS([security/pam_modules.h],[],[],[AC_INCLUDES_DEFAULT # include #endif]) -AC_CHECK_HEADERS(linux/errqueue.h,,,[#include ]) +AC_CHECK_HEADERS(linux/errqueue.h,,,[#include +#include ]) AC_CHECK_TYPES([fsblkcnt_t],,,[ #include -- 2.27.0 From d7fc5bf9bf031089d80703c48daf30d5b15a80ca Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 3 Jul 2020 10:33:51 -0600 Subject: [PATCH 07/11] LINUX 5.8: Replace kernel_setsockopt with new funcs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux 5.8-rc1 commit 'net: remove kernel_setsockopt' (5a892ff2facb) retires the kernel_setsockopt function. In prior kernel commits new functions (ip_sock_set_*) were added to replace the specific functions performed by kernel_setsockopt. Define new config test 'HAVE_IP_SOCK_SET' if the 'ip_sock_set' functions are available. The config define 'HAVE_KERNEL_SETSOCKOPT' is no longer set in Linux 5.8. Create wrapper functions that replace the kernel_setsockopt calls with calls to the appropriate Linux kernel function(s) (depending on what functions the kernel supports). Remove the unused 'kernel_getsockopt' function (used for building with pre 2.6.19 kernels). For reference Linux 2.6.19 introduced kernel_setsockopt Linux 5.8 removed kernel_setsockopt and replaced the functionality with a set of new functions (ip_sock_set_*) Reviewed-on: https://gerrit.openafs.org/14247 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit c48072b9800759ef1682b91ff1e962f6904a2594) Change-Id: I2724fad06b1882149d2066d13eced55eff5ee695 Reviewed-on: https://gerrit.openafs.org/14267 Tested-by: BuildBot Reviewed-by: Michael Laß Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_compat.h | 43 +++++++++++++++++++++++++------------ src/cf/linux-kernel-func.m4 | 6 ++++++ src/rx/LINUX/rx_knet.c | 11 +++------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index 4999b89b9..620b3730c 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -314,9 +314,22 @@ zero_user_segment(struct page *pp, unsigned int from1, unsigned int to1) } #endif -#ifndef HAVE_LINUX_KERNEL_SETSOCKOPT +#if defined(HAVE_LINUX_IP_SOCK_SET) +# include +/* ip_sock_set_* introduced in linux 5.8 */ +static inline void +afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu) +{ + ip_sock_set_mtu_discover(sockp->sk, pmtu); +} +static inline void +afs_linux_sock_set_recverr(struct socket *sockp) +{ + ip_sock_set_recverr(sockp->sk); +} +#else +# if !defined(HAVE_LINUX_KERNEL_SETSOCKOPT) /* Available from 2.6.19 */ - static inline int kernel_setsockopt(struct socket *sockp, int level, int name, char *val, unsigned int len) { @@ -329,20 +342,22 @@ kernel_setsockopt(struct socket *sockp, int level, int name, char *val, return ret; } +# endif /* !HAVE_LINUX_KERNEL_SETSOCKOPT */ -static inline int -kernel_getsockopt(struct socket *sockp, int level, int name, char *val, - int *len) { - mm_segment_t old_fs = get_fs(); - int ret; - - set_fs(get_ds()); - ret = sockp->ops->getsockopt(sockp, level, name, val, len); - set_fs(old_fs); - - return ret; +static inline void +afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu) +{ + kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu, + sizeof(pmtu)); } -#endif +static inline void +afs_linux_sock_set_recverr(struct socket *sockp) +{ + int recverr = 1; + kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr, + sizeof(recverr)); +} +#endif /* !HAVE_LINUX_IP_SOCK_SET */ #ifdef HAVE_TRY_TO_FREEZE static inline int diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 index 07627db52..78ff48294 100644 --- a/src/cf/linux-kernel-func.m4 +++ b/src/cf/linux-kernel-func.m4 @@ -151,6 +151,12 @@ AC_CHECK_LINUX_FUNC([lru_cache_add_file], [#include ], [lru_cache_add_file(NULL);]) +dnl Linux 5.8 replaced kernel_setsockopt with helper functions +dnl e.g. ip_sock_set_mtu_discover, ip_sock_set_recverr +AC_CHECK_LINUX_FUNC([ip_sock_set], + [#include ], + [ip_sock_set_mtu_discover(NULL, 0);]) + dnl Consequences - things which get set as a result of the dnl above tests AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"], diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c index 9fbb563f3..50607c8f5 100644 --- a/src/rx/LINUX/rx_knet.c +++ b/src/rx/LINUX/rx_knet.c @@ -34,7 +34,6 @@ #include #include #endif - #include "osi_compat.h" /* rxk_NewSocket @@ -76,14 +75,10 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) return NULL; } - kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu, - sizeof(pmtu)); + afs_linux_sock_set_mtu_discover(sockp, pmtu); + #ifdef AFS_RXERRQ_ENV - { - int recverr = 1; - kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr, - sizeof(recverr)); - } + afs_linux_sock_set_recverr(sockp); #endif return (osi_socket *)sockp; } -- 2.27.0 From 335f37be13d2ff954e4aeea617ee66502170805e Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 3 Jul 2020 10:34:42 -0600 Subject: [PATCH 08/11] LINUX 5.8: do not set name field in backing_dev_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux-5.8-rc1 commit 'bdi: remove the name field in struct backing_dev_info' (1cd925d5838) Do not set the name field in the backing_dev_info structure if it is not available. Uses an existing config test 'STRUCT_BACKING_DEV_INFO_HAS_NAME' Note the name field in the backing_dev_info structure was added in Linux-2.6.32 Reviewed-on: https://gerrit.openafs.org/14248 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit d8ec294534fcdee77a2ccd297b4b167dc4d5573d) Change-Id: I3d9e18092db998a4c4f26bd63ee3b75383a53d4c Reviewed-on: https://gerrit.openafs.org/14268 Tested-by: BuildBot Reviewed-by: Michael Laß Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_vfsops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index 8bbb5f225..ca1d5c83b 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -121,7 +121,9 @@ afs_fill_super(struct super_block *sb, void *data, int silent) code = super_setup_bdi(sb); if (code) goto out; +# if defined(STRUCT_BACKING_DEV_INFO_HAS_NAME) sb->s_bdi->name = "openafs"; +# endif sb->s_bdi->ra_pages = 32; #else /* used for inodes backing_dev_info field, also */ -- 2.27.0 From facff58b840a47853592510617ba7a1da2e3eaa9 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 3 Jul 2020 10:35:06 -0600 Subject: [PATCH 09/11] LINUX 5.8: use lru_cache_add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Linux-5.8-rc1 commit 'mm: fold and remove lru_cache_add_anon() and lru_cache_add_file()' (6058eaec), the lru_cache_add_file function is removed since it was functionally equivalent to lru_cache_add. Replace lru_cache_add_file with lru_cache_add. Introduce a new autoconf test to determine if lru_cache_add is present For reference, the Linux changes associated with the lru caches: __pagevec_lru_add introduced before v2.6.12-rc2 lru_cache_add_file introduced in v2.6.28-rc1 __pagevec_lru_add_file replaces __pagevec_lru_add in v2.6.28-rc1 vmscan: split LRU lists into anon & file sets (4f98a2fee) __pagevec_lru_add removed in v5.7 with a note to use lru_cache_add_file mm/swap.c: not necessary to export __pagevec_lru_add() (bde07cfc6) lru_cache_add_file removed in v5.8 mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() (6058eaec) lru_cache_add exported mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() (6058eaec) Openafs will use: lru_cache_add on 5.8 kernels lru_cache_add_file from 2.6.28 through 5.7 kernels __pagevec_lru_add/__pagevec_lru_add_file on pre 2.6.28 kernels Reviewed-on: https://gerrit.openafs.org/14249 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Yadavendra Yadav Reviewed-by: Benjamin Kaduk (cherry picked from commit 7d85ce221d6ccc19cf76ce7680c74311e4ed2632) Change-Id: Iba6ef4441687dbf60d227a708e2a032c2c0dc79f Reviewed-on: https://gerrit.openafs.org/14269 Tested-by: BuildBot Reviewed-by: Michael Laß Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_vnodeops.c | 8 +++++++- src/cf/linux-kernel-func.m4 | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 00995b27a..36a4f685e 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -71,7 +71,7 @@ extern struct vcache *afs_globalVp; /* Handle interfacing with Linux's pagevec/lru facilities */ -#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) +#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) || defined(HAVE_LINUX_LRU_CACHE_ADD) /* * Linux's lru_cache_add_file provides a simplified LRU interface without @@ -90,7 +90,13 @@ afs_lru_cache_init(struct afs_lru_pages *alrupages) static inline void afs_lru_cache_add(struct afs_lru_pages *alrupages, struct page *page) { +# if defined(HAVE_LINUX_LRU_CACHE_ADD) + lru_cache_add(page); +# elif defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) lru_cache_add_file(page); +# else +# error need a kernel function to add a page to the kernel lru cache +# endif } static inline void diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 index 78ff48294..11d071806 100644 --- a/src/cf/linux-kernel-func.m4 +++ b/src/cf/linux-kernel-func.m4 @@ -147,10 +147,17 @@ AC_CHECK_LINUX_FUNC([inode_lock], [inode_lock(NULL);]) dnl lru_cache_add_file added to Linux 2.6.28. +dnl removed in Linux 5.8 AC_CHECK_LINUX_FUNC([lru_cache_add_file], [#include ], [lru_cache_add_file(NULL);]) +dnl lru_cache_add exported in Linux 5.8 +dnl replaces lru_cache_add_file +AC_CHECK_LINUX_FUNC([lru_cache_add], + [#include ], + [lru_cache_add(NULL);]) + dnl Linux 5.8 replaced kernel_setsockopt with helper functions dnl e.g. ip_sock_set_mtu_discover, ip_sock_set_recverr AC_CHECK_LINUX_FUNC([ip_sock_set], -- 2.27.0 From ee578e92d9f810d93659a9805d0c12084fe2bb95 Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Thu, 2 May 2019 16:02:47 -0400 Subject: [PATCH 10/11] Linux: use override_creds when available Linux may perform some access control checks at the time of an I/O operation, rather than relying solely on checks done when the file is opened. In some cases (e.g. AppArmor), these checks are done based on the current tasks's creds at the time of the I/O operation, not those used when the file was open. Because of this, we must use override_creds() / revert_creds() to make sure we are using privileged credentials when performing I/O operations on cache files. Otherwise, cache I/O operations done in the context of a task with a restrictive AppArmor profile will fail. Reviewed-on: https://gerrit.openafs.org/13751 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit cd3221d3532a28111ad22d4090ec913cbbff40da) Change-Id: I8955ff6150462fecba9a10a8f99bce9ee8163435 Reviewed-on: https://gerrit.openafs.org/14082 Reviewed-by: Cheyenne Wills Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Jeffrey Hutzelman Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_file.c | 34 ++++++++++++++++++++++++++++++++++ src/cf/linux-kernel-func.m4 | 3 +++ 2 files changed, 37 insertions(+) diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 5b0a0c01d..b48280193 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -59,6 +59,9 @@ afs_linux_raw_open(afs_dcache_id_t *ainode) struct inode *tip = NULL; struct dentry *dp = NULL; struct file* filp; +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + const struct cred *cur_cred; +#endif dp = afs_get_dentry_from_fh(afs_cacheSBp, ainode, cache_fh_len, cache_fh_type, afs_fh_acceptable); @@ -67,6 +70,9 @@ afs_linux_raw_open(afs_dcache_id_t *ainode) tip = dp->d_inode; tip->i_flags |= S_NOATIME; /* Disable updating access times. */ +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + cur_cred = override_creds(cache_creds); +#endif #if defined(STRUCT_TASK_STRUCT_HAS_CRED) /* Use stashed credentials - prevent selinux/apparmor problems */ filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, cache_creds); @@ -74,6 +80,9 @@ afs_linux_raw_open(afs_dcache_id_t *ainode) filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, current_cred()); #else filp = dentry_open(dget(dp), mntget(afs_cacheMnt), O_RDWR); +#endif +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + revert_creds(cur_cred); #endif if (IS_ERR(filp)) { afs_warn("afs: Cannot open cache file (code %d). Trying to continue, " @@ -169,10 +178,20 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat) int osi_UFSClose(struct osi_file *afile) { +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + const struct cred *cur_cred; +#endif + AFS_STATCNT(osi_Close); if (afile) { if (OSIFILE_INODE(afile)) { +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + cur_cred = override_creds(cache_creds); +#endif filp_close(afile->filp, NULL); +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + revert_creds(cur_cred); +#endif } } kfree(afile); @@ -186,12 +205,18 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) struct osi_stat tstat; struct iattr newattrs; struct inode *inode = OSIFILE_INODE(afile); +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + const struct cred *cur_cred; +#endif AFS_STATCNT(osi_Truncate); /* This routine only shrinks files, and most systems * have very slow truncates, even when the file is already * small enough. Check now and save some time. */ +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + cur_cred = override_creds(cache_creds); +#endif code = afs_osi_Stat(afile, &tstat); if (code || tstat.size <= asize) return code; @@ -219,6 +244,9 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) up_write(&inode->i_alloc_sem); #endif afs_linux_unlock_inode(inode); +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + revert_creds(cur_cred); +#endif AFS_GLOCK(); return code; } @@ -380,6 +408,9 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw) size_t count; unsigned long savelim; loff_t pos; +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + const struct cred *cur_cred = override_creds(cache_creds); +#endif savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur; current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; @@ -435,6 +466,9 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw) #endif /* AFS_FILE_NEEDS_SET_FS */ current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim; +#if defined(HAVE_LINUX_OVERRIDE_CREDS) + revert_creds(cur_cred); +#endif return code; } diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 index 11d071806..10b7c97dd 100644 --- a/src/cf/linux-kernel-func.m4 +++ b/src/cf/linux-kernel-func.m4 @@ -86,6 +86,9 @@ AC_CHECK_LINUX_FUNC([ktime_get_real_ts64], AC_CHECK_LINUX_FUNC([locks_lock_file_wait], [#include ], [locks_lock_file_wait(NULL, NULL);]) +AC_CHECK_LINUX_FUNC([override_creds], + [#include ], + [override_creds(0);]) AC_CHECK_LINUX_FUNC([page_follow_link], [#include ], [page_follow_link(0,0);]) -- 2.27.0 From 179a418ea5063785a23e4faf35134f063a6f3e1c Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 13 Mar 2020 13:00:35 -0500 Subject: [PATCH 11/11] LINUX: Properly revert creds in osi_UFSTruncate Commit cd3221d3 (Linux: use override_creds when available) caused us to force the current process's creds to the creds of afsd during osi_file.c file ops, to avoid access errors in some cases. However, in osi_UFSTruncate, one code path was missed to revert our creds back to the original user's creds: when the afs_osi_Stat call fails or deems the truncate unnecessary. In this case, the calling process keeps the creds for afsd after osi_UFSTruncate returns, causing our subsequent access-checking code to think that the current process is in the same context as afsd (typically uid 0 without a pag). This can cause the calling process to appear to transiently have the same access as non-pag uid 0; typically this will be unauthenticated access, but could be authenticated if uid 0 has tokens. To fix this, modify the early return in osi_UFSTruncate to go through a 'goto done' destructor instead, and make sure we revert our creds in that destructor. Thanks to cwills@sinenomine.net for finding and helping reproduce the issue. Reviewed-on: https://gerrit.openafs.org/14098 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Jeffrey Hutzelman Reviewed-by: Cheyenne Wills Tested-by: Cheyenne Wills (cherry picked from commit 57b4f4f9be1e25d5609301c10f717aff32aef676) Change-Id: I714eb2dea9645ffe555f26b5d69707a7afbe8d81 Reviewed-on: https://gerrit.openafs.org/14099 Reviewed-by: Andrew Deason Reviewed-by: Jeffrey Hutzelman Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index b48280193..0afb87525 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -219,7 +219,7 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) #endif code = afs_osi_Stat(afile, &tstat); if (code || tstat.size <= asize) - return code; + goto done; AFS_GUNLOCK(); afs_linux_lock_inode(inode); #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM @@ -244,10 +244,11 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) up_write(&inode->i_alloc_sem); #endif afs_linux_unlock_inode(inode); + AFS_GLOCK(); + done: #if defined(HAVE_LINUX_OVERRIDE_CREDS) revert_creds(cur_cred); #endif - AFS_GLOCK(); return code; } -- 2.27.0