openafs.git
5 years agoafs: change afs_nfs{2,3}_dispatcher signature 88/12988/3
Michael Meffie [Fri, 30 Mar 2018 03:32:40 +0000]
afs: change afs_nfs{2,3}_dispatcher signature

The fourth argument of the afs_nfs{2,3}_dispatcher functions is a pointer to a
pointer to a exportinfo structure.  However, this argument is not an output
argument, so the extra level of indirection is unnecessary.  A separate local
variable is used as an output argument to the afs_nfsclient_reqhandler call
within the dispatchers, which is not passed back to the afs_nfs{2,3}_dispatcher
caller.

In anticipation of other changes to fix warning messages, simplify the
signature of the afs_nfs{2,3}_dispatcher functions to avoid taking the address
of the exportinfo structure when calling afs_nfs{2,3}_dispatcher.

Change-Id: I6fb1a190e6aab286bfac41df783688a0be46a21f
Reviewed-on: https://gerrit.openafs.org/12988
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: fix missing afs_nfs3_dispatcher return value 87/12987/3
Michael Meffie [Fri, 30 Mar 2018 03:15:47 +0000]
afs: fix missing afs_nfs3_dispatcher return value

Fix a missing early return value in the function afs_nfs3_dispatcher.  All
callers check the return code of afs_nfs3_dispatcher and interpret values
greater that 1 to be errors. Return 3 as an error code for this code path,
which is the next available error code in afs_nfs3_dispatcher.

This commit fixes the following Solaris Studio warning message:

    ... warning: function expects to return value: afs_nfs3_dispatcher

Change-Id: I47b545bd57a46c03006b9f031da3647c8a530377
Reviewed-on: https://gerrit.openafs.org/12987
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoroken: do not clobber __attribute__ 61/12961/6
Michael Meffie [Thu, 15 Mar 2018 22:53:59 +0000]
roken: do not clobber __attribute__

The roken-common.h header defines an empty macro called __attribute__
when HAVE___ATTRIBUTE__ is not defined. This macro conditionally removes
the `format' function attributes in the roken headers at compile time.
Unfortunately, the empty __attribute__ macro will also clobber other
attribute types encountered after the roken.h header inclusion.

This is not an issue when building under gcc or clang, since the empty
attribute macro will not be defined. However Solaris Studio supports a
subset of the function attribute types, with `format' not currently
supported. This means roken will define an empty __attribute__ macro,
which prevents the use of other attribute types.

This commit does not change the roken files directly because they are
external.  Instead, the processing of the roken.h.in file has been
updated to undefine the __attribute__ macro at the end of the generated
roken.h header.

Change-Id: Iea5622ae175e7f82a60780838948178bd7f8b56f
Reviewed-on: https://gerrit.openafs.org/12961
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoautoconf: Split out krb5/gss tests 37/13237/4
Andrew Deason [Fri, 29 Jun 2018 19:48:58 +0000]
autoconf: Split out krb5/gss tests

Move our krb5 and GSS-related autoconf tests into their own separate
files, in src/cf/krb5.m4 and src/cf/gss.m4.

Change-Id: I4202df5d810f2d3942fc4ffb3fd406869f68029b
Reviewed-on: https://gerrit.openafs.org/13237
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoautoconf: do not reference the missing script 82/12982/9
Marcio Barbosa [Thu, 31 May 2018 12:46:56 +0000]
autoconf: do not reference the missing script

Currently, OpenAFS does not use automake. As a result, the missing script
is not copied to the build-tools directory. Since this script is not
present in the tree, am_missing_run is not initialized. Unfortunately,
the current version still has a few references to this variable. In order
to preserve a similar behavior, this commit replaces these references by
AC_ERROR.

While we are changing these, remove the AC_CHECK_PROGS calls for AR and
STRIP, since libtool already checks these for us.

Change-Id: I833dc6e8611dc7227db4ec77b0160dfa47b7e531
Reviewed-on: https://gerrit.openafs.org/12982
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoRemove obsolete retsigtype 03/12203/9
Peter Foley [Mon, 29 Feb 2016 21:39:14 +0000]
Remove obsolete retsigtype

Only relevent for pre-c89 K&R compilers.

[mmeffie@sinenomine.net: avoid changes to src/external]

Change-Id: I1b3bf14ddd50f1a6b3d50e0376abffffdb64fb81
Reviewed-on: https://gerrit.openafs.org/12203
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoautoconf: reformat long lines 25/13125/4
Michael Meffie [Sat, 26 May 2018 23:52:27 +0000]
autoconf: reformat long lines

The autoupdate tool was run to modernize the autoconf macros but
generates very long lines. Manually reformat the long lines to make them
more reasonable.

Change-Id: I6f08138aa7134d8110da885ea4375cebbe903575
Reviewed-on: https://gerrit.openafs.org/13125
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoautoconf: autoupdate macros 02/12202/7
Peter Foley [Mon, 29 Feb 2016 18:28:28 +0000]
autoconf: autoupdate macros

Run autoupdate on macros.

[mmeffie@sinenomine.net: re-run autoupdate, no other edits]

Change-Id: I8b45edea97cf2e065f23f02d2d7f6a0e7adcb8a5
Reviewed-on: https://gerrit.openafs.org/12202
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoautoconf: update curses.m4 21/13021/4
Michael Meffie [Fri, 20 Apr 2018 15:47:57 +0000]
autoconf: update curses.m4

Replace the obsolete AC_TRY_COMPILE with AC_COMPILE_IFELSE/AC_LANG_PROGRAM
in the curses check for the getmaxyx macro.

This change was done manually instead of using autoupdate because the
program prologue argument for this particular check is an m4 macro,
which will not expand to code when autoupdate adds m4 quotes to the
AC_LANG_PROGRAM arguments.

Change-Id: I85b65fb9b59b45d31286436a9f15110cec31bec8
Reviewed-on: https://gerrit.openafs.org/13021
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

5 years agoautoconf: update pthread checks 18/13018/4
Michael Meffie [Mon, 16 Apr 2018 14:42:49 +0000]
autoconf: update pthread checks

Replace obsolete AC_TRY_COMPILE with AC_COMPILE_IFELSE.  Replace shell
if/then conditionals with AS_IF macros.  Reformat indentation and
quoting.

This change was done manually, since autoupdate copes poorly with the
old, nested AC_TRY_COMPILE macros.

Change-Id: I2c34d1426f154daff65999076821f49ddaa16a24
Reviewed-on: https://gerrit.openafs.org/13018
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>

5 years agoautoconf: updates and cleanup 99/12199/6
Peter Foley [Mon, 29 Feb 2016 18:19:01 +0000]
autoconf: updates and cleanup

Update autoconf macros to their modern equivalents, according to what
the 'autoupdate' tool does. While we're here, remove automake references
that aren't being used, and remove the obsolete AC_PROG_LIBTOOL in favor
of AFS_LT_INIT.

Change-Id: I71066d6d72f8b1d8663e26fec83ae23d7f73f059
Reviewed-on: https://gerrit.openafs.org/12199
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoSOLARIS: suppress -xarch=amd64 is deprecated warnings 59/12959/4
Michael Meffie [Thu, 25 Jan 2018 23:27:00 +0000]
SOLARIS: suppress -xarch=amd64 is deprecated warnings

The -m64 flag to specify 64bit builds was introduced in Sun Studio 10, circa
2005. The old flag -xarch=amd64 was deprecated as of Sun Studio 12, circa 2007.
Ever since Sun Studio 12, the compiler complains with a warning message when
the old -xarch=amd64 flag is given:

cc: Warning: -xarch=amd64 is deprecated, use -m64 to create 64-bit programs

Update the cflags when building the Solaris kernel module for x86 to use the
modern -m64 under Solaris 11 or later. Since Solaris 11 has been available
since 2010, it is very unlikely a compiler on Solaris 11 would not support the
modern -m64 flag.

Change-Id: Ib13c00f1c69f34ab1905a8dd4a46c90895046f25
Reviewed-on: https://gerrit.openafs.org/12959
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafsd: Improve syscall tracing 58/11858/13
Perry Ruiter [Fri, 24 Apr 2015 04:33:27 +0000]
afsd: Improve syscall tracing

When afsd is started with the -debug flag, extensive debug output is
generated including tracing for each syscall.  Unfortunately the
existing syscall tracing is not especially helpful.  It dumps out two
constants that we already knew at compile time, the first parameter of
the syscall along with the syscall's return code.  Specifically it does
not tell you which syscall is currently being traced.  Here's a current
example of afsd -debug:

    afsd: cacheFiles autotuned to 581250
    afsd: dCacheSize autotuned to 10000
    afsd: cacheStatEntries autotuned to 15000
    SScall(183, 28, 6860800)=0
    SScall(183, 28, -847416368)=0
    SScall(183, 28, 1)=0
    afsd: Forking rx listener daemon.
    afsd: Forking rx callback listener.
    afsd: Forking rxevent daemon.
    SScall(183, 28, 0)=0
    SScall(183, 28, 1)=0
    ...

This patch drops the compile time constants (183 and 28 in the above
sample output) and replaces them with the name of the syscall being
traced.  Additionally the first parameter to a syscall is as likely to
be an address as a decimal value so display it in hex. Here's an example
of afsd -debug with these changes:

    afsd: cacheFiles autotuned to 581250
    afsd: dCacheSize autotuned to 10000
    afsd: cacheStatEntries autotuned to 15000
    os_syscall(AFSOP_SET_THISCELL, 0x68bf80)=0
    os_syscall(AFSOP_SEED_ENTROPY, 0x7fff9ce40c10)=0
    os_syscall(AFSOP_ADVISEADDR, 0x1)=0
    afsd: Forking rx listener daemon.
    afsd: Forking rx callback listener.
    afsd: Forking rxevent daemon.
    os_syscall(AFSOP_RXEVENT_DAEMON, 0x0)=0
    os_syscall(AFSOP_BASIC_INIT, 0x1)=0
    ...

[mmeffie@sinenomine.net: avoid c99 array initialization.]

Change-Id: I4f3d46d420d19abeddbf719efa04aef7e553d51f
Reviewed-on: https://gerrit.openafs.org/11858
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoautoconf: attribute type checks 63/12963/5
Michael Meffie [Sat, 17 Mar 2018 00:51:42 +0000]
autoconf: attribute type checks

Check for function attributes by type and update src/afs/stds.h to
conditionally include the attributes detected, instead of checking for
specific compilers and compiler versions.

This allows attributes to be used when building under Solaris Studio.

Change-Id: I8a4dbc1b2cb6032d28176349481085bf6deb309c
Reviewed-on: https://gerrit.openafs.org/12963
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoopr: avoid empty nonnull argument index lists 76/13276/3
Michael Meffie [Thu, 9 Aug 2018 19:18:50 +0000]
opr: avoid empty nonnull argument index lists

Commit 71dc077831d339fc5822f2c2c79b65afe14b12f8 changed the AFS_NONULL
macro in opr.h to fix a build error on windows by adding an empty
argument index list.

However, Solaris compilers do not support empty parameter lists.
Specify the argument index to allow so nonnull function attributes can
be supported on Solaris.

Change-Id: I3e629868374eb6484923c253da2cdd1d8eacdb2f
Reviewed-on: https://gerrit.openafs.org/13276
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoautoconf: check for format __attribute__ to avoid warnings 56/12956/6
Michael Meffie [Sun, 14 Jan 2018 14:38:26 +0000]
autoconf: check for format __attribute__ to avoid warnings

Building with Solaris Studio generates a ludicrous number of warnings
in the form:

   roken.h, line ...: warning: attribute "format" is unknown, ignored

Modern Solaris Studio supports several GCC-style function attributes,
including the `noreturn' attribute, however does not support the
`format' attribute.

Currently, configure defines HAVE___ATTRIBUTE__ when the `noreturn'
attribute is available. roken headers conditionally declare printf-like
functions with the `format' function attribute when HAVE___ATTRIBUTE__
is defined, leading to the warning messages when building under Solaris
Studio. Unsupported function attributes generate warnings, not errors.

Fix these warnings by defining HAVE___ATTRIBUTE__ if and only if the
`format' attribute is supported by the compiler, instead of checking for
`noreturn'.  Note that the `format' type is currently the only attribute
used by roken at this time.

Change-Id: I569167333d65df2583befc19befa8d719b93d75a
Reviewed-on: https://gerrit.openafs.org/12956
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoautoconf: import gcc function attribute check macro 62/12962/3
Michael Meffie [Sat, 17 Mar 2018 00:41:35 +0000]
autoconf: import gcc function attribute check macro

Import Gabriele Svelto's AC_GCC_FUNC_ATTRIBUTE autoconf macro to check for
GCC-style function attributes.  This macro is part of the GNU Autoconf
Archive[1]. The imported file is distributed under an all-permissive license.

[1] https://www.gnu.org/software/autoconf-archive/

Change-Id: I64ccd00717fa9606a26aeeeea9030f4fb4877cf8
Reviewed-on: https://gerrit.openafs.org/12962
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: Return memcache allocation errors 73/13273/2
Andrew Deason [Tue, 7 Aug 2018 22:08:26 +0000]
afs: Return memcache allocation errors

During cache initialization, we can fail to allocate our dcache
entries for memcache. Currently when this happens, we just log a
message and try to disable dcache access. However, this results in at
least one code path that causes a panic anyway during startup, since
afs_CacheTruncateDaemon will try to trim the cache, and afs_GetDownD
will call afs_MemGetDSlot, and we cannot find the given dslot.

To avoid this, change our cache initialization to return an error,
instead of trying to continue without a functional dcache. This causes
afs_dcacheInit to return an error in this case, and by extension
afs_CacheInit and the AFSOP_CACHEINIT syscall. Also change afsd to
actually detect errors from AFSOP_CACHEINIT, and to bail out when it
does.

Thanks to gsgatlin@ncsu.edu for reporting the relevant panic.

Change-Id: Ic89ff9638201faae6c4399a2344d4da3e251d537
Reviewed-on: https://gerrit.openafs.org/13273
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoLINUX: Update to Linux struct iattr->ia_ctime to timespec64 with 4.18 41/13241/6
Joe Gorse [Mon, 2 Jul 2018 20:36:04 +0000]
LINUX: Update to Linux struct iattr->ia_ctime to timespec64 with 4.18

With 4.18+ Linux kernels we see a transition to 64-bit time stamps by
default.

current_kernel_time() returns the 32-bit struct timespec.
current_kernel_time64() returns the 64-bit struct timespec64.

struct iattr->ia_ctime expects struct timespec64 as of 4.18+.

Timestamps greater than 31-bit rollover after 2147483647 or
January 19, 2038 03:14:07 UTC. This is the same approach taken by
the Linux developers for converting between timepsec64 and timespec.

Change-Id: Icc1cf5d1a6679f5c749f8720f225a9b293f675fd
Reviewed-on: https://gerrit.openafs.org/13241
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibuafs: Stop clobbering CFLAGS 62/13262/3
Andrew Deason [Thu, 26 Jul 2018 22:57:38 +0000]
libuafs: Stop clobbering CFLAGS

Currently, in the libuafs MakefileProto for every platform, CFLAGS is
set to a bunch of flags, ignoring any CFLAGS set by the 'make'
command-line provided by the user. Since most of the rest of the tree
honors CFLAGS, it is confusing and can cause errors when src/libuafs
ignore the user-set CFLAGS.

One example of this breaking the build is when building RHEL RPMs for
certain sub-architectures of the current machine. If you try to
'rpmbuild --target=i686' on 32-bit x86 RHEL 5, we will build with
-march=i686 in the CFLAGS, which will be used to build most objects
and is used in our configure tests. As a result, our configure tests
will say that gcc atomic intrinsics are available. But when we go to
build libuafs objects, we will not have -march=i686 in our CFLAGS,
which causes (on RHEL 5) gcc to default to building for i386, which
does not have gcc atomic intrinsics available. This causes build
errors like this:

    libuafs.a(rx.o): In function `rx_atomic_test_and_clear_bit':
    [...]/BUILD/openafs-1.8.0/src/rx/rx_atomic.h:462: undefined reference to `__sync_fetch_and_and_4'

To fix this, change the libuafs MakefileProtos to not set CFLAGS
directly; instead, set them in a new variable UAFS_CFLAGS.
Makefile.common then pulls those flags into MODULE_CFLAGS, which is
used in our *_CCRULE build rules.

While we are here, also move the common set of CFLAGS set by each
platform's MakefileProto into Makefile.common. Now, each MakefileProto
only needs to set CFLAGS that are specific to that platform, which
ends up being very few (since most platforms were using the exact same
set of CFLAGS).

Relevant issue identified and analyzed by mbarbosa@sinenomine.net.

Change-Id: I1bd21a6e7669137be3e5edee86227fd37f841d62
Reviewed-on: https://gerrit.openafs.org/13262
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: actually remove unused AFS::ukernel man page 57/13257/6
Marcio Barbosa [Thu, 26 Jul 2018 17:30:35 +0000]
redhat: actually remove unused AFS::ukernel man page

Commit 278581c24a802834719e0d57f27978321556c9bb (redhat: package libuafs
perl bindings) added swig as a build dependency on RHEL 6+/Fedora 15+ to
build and package AFS::ukernel perl bindings for libuafs.  The man page
for AFS::ukernel is generated from the pod files unconditionally, so
needs to be removed from the staging directories when AFS::ukernel is
not packaged.

Unfortunately, the full path to the staged AFS::ukernel manpage was
not given in that commit, so the rpmbuild will fail on RHEL 5 with
the error:

        RPM build errors:
        Installed (but unpackaged) file(s) found:
        /usr/share/man/man3/AFS::ukernel.3.gz

Fix this error by specifying the full path to the AFS::ukernel man page
to actually remove it when we are not packaging AFS::ukernel files.

[mmeffie: updated commit message]

Change-Id: If43f083a1014216e2f9a2669bf9e834149a40944
Reviewed-on: https://gerrit.openafs.org/13257
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: Save errno before logging 63/13263/2
Andrew Deason [Fri, 27 Jul 2018 18:36:15 +0000]
ubik: Save errno before logging

The value of errno can change after a syscall, and ViceLog may issue
syscalls (such as write()). So, make sure we save errno here before
calling ViceLog().

Issue spotted by kaduk@mit.edu.

Change-Id: I0f3308d64cd779bd97c97834ec2b270f5edd7ba6
Reviewed-on: https://gerrit.openafs.org/13263
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoubik: improve logging for database synchonizations 79/13079/6
Mark Vitale [Fri, 4 May 2018 21:32:51 +0000]
ubik: improve logging for database synchonizations

As an aid for debugging database synchronization issues, ensure that the
logging is consistent and unambiguous for both the client and server
sides of DISK_GetFile and DISK_SendFile.  Add new error messages as
required.

In addition, rework the "recovery sending version to <IP>" message in
urecovery_Interact.  This message is misleading because the new version
database is only sent to a DB server if its version is not up to date.
Instead, move this message into the version check block immediately
below it.  Also reword it for clarity and promote its log level from 5
to 0.  Finally, remove the now-superfluous "recovery stating local
database" log message.

Change-Id: If8bbaa1215cab9fd24b157a0ee57759b34e77e9c
Reviewed-on: https://gerrit.openafs.org/13079
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: urecovery_AbortAll diagnostic msgs 18/12618/7
Mark Vitale [Fri, 17 Mar 2017 22:12:23 +0000]
ubik: urecovery_AbortAll diagnostic msgs

As a troubleshooting aid for developers, add a few counters and a log
msg so we know when transactions are being aborted (if any) by
urecovery_AbortAll.

Change-Id: I528df6d51acd5d10bb2de30f43b8d4415adc7f8a
Reviewed-on: https://gerrit.openafs.org/12618
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

5 years agoubik: log important messages at default log level 17/12617/6
Mark Vitale [Tue, 9 May 2017 01:11:27 +0000]
ubik: log important messages at default log level

Many important ubik messages (e.g., errors, warnings, sync state
changes) are logged at log level 5 (-d 5) or higher.  Many sites are
reluctant to run ubik servers at a logging level higher than the default
due to the large number of extremely noisy informational messages at log
level 5.  Therefore, many important log messages are never seen.

Instead, issue critical errors, warnings, and other important messages
at log level 0 so that they are always seen, even at the default logging
level.

In addition, disambiguate the two "I am no longer sync-site" messages by
adding a unique reason text to each.

Change-Id: I057edf01e2502e39c5135836f1d0081d03559270
Reviewed-on: https://gerrit.openafs.org/12617
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

5 years agovldb_check: write mh entry header flags in network order 45/13245/2
Michael Meffie [Fri, 6 Jul 2018 19:22:36 +0000]
vldb_check: write mh entry header flags in network order

Commit 6b93ad695e53a86dbe9eea13bd0ff651e1d8c9b7 fixed a false error
reported when the vldb contained more than one mh extent blocks.  That
fix changed the readMH() function to convert the flags field to host
byte order of all the mh blocks, not just the first block, in order to
check the value of those flags.

Unfortunately, that commit missed converting non-zero blocks back to
network byte order in the complementary writeMH() function, which is
used to write the data back to disk when vldb_check is run with the -fix
option.

FIXES 134589

Change-Id: I4cdbd57b3336e78a9eb1e543ee6d09b33f5e6153
Reviewed-on: https://gerrit.openafs.org/13245
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: Make afs_osi_Free(NULL) a no-op 36/13236/2
Andrew Deason [Fri, 29 Jun 2018 20:25:48 +0000]
afs: Make afs_osi_Free(NULL) a no-op

In userspace, we assume that free(NULL) does nothing, which makes
certain cleanup code paths simpler. This may or may not be true for
our free() abstractions that can run in the kernel (like afs_osi_Free,
rxi_Free, etc), which is confusing. To make the higher-level free()
abstractions more consistent, change afs_osi_Free to guarantee that
passing a NULL pointer does nothing.

Change-Id: If7c7011795f66464eeb578eacfc943475b4d59f8
Reviewed-on: https://gerrit.openafs.org/13236
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: parallel builds 40/13240/2
Stephan Wiesand [Mon, 2 Jul 2018 12:05:47 +0000]
redhat: parallel builds

Parallel builds can be an order of magnitude faster. Add the
_smp_mflags macro to all invocations of make in the rpm spec,
to make use of all available cores and SMT threads on the build
system. This should also help noticing new dependency issues
early. Note the macro can be overridden on the rpmbuild command
line.

Change-Id: Idddf8b867500d1ee73ff51de9d8a173bb4cc8c68
Reviewed-on: https://gerrit.openafs.org/13240
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: speed up userland-only rpm builds 39/13239/2
Stephan Wiesand [Mon, 2 Jul 2018 11:33:20 +0000]
redhat: speed up userland-only rpm builds

When building with --define "build_modules 0", have configure
skip the Linux kernel tests, which are slow and many.

Change-Id: Ie318bf4939776c9a3f8594dcdd5be54b446f33dd
Reviewed-on: https://gerrit.openafs.org/13239
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: package new file include/opr/lock.h 38/13238/2
Stephan Wiesand [Mon, 2 Jul 2018 11:28:07 +0000]
redhat: package new file include/opr/lock.h

Commit 792dd44ac57032a3f2a4743c83c8a0208a08ecec added the
installation of include/opr/lock.h, but the rpm spec fails
to pick it up, making rpm builds fail. Add the new file
to the files list for the -devel package.

FIXES 134579

Change-Id: I998f48bd88308d81779dd775b322590eda75d5c8
Reviewed-on: https://gerrit.openafs.org/13238
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoLINUX: Detect NULL page during write_begin 42/13242/2
Andrew Deason [Thu, 5 Jul 2018 22:16:48 +0000]
LINUX: Detect NULL page during write_begin

In afs_linux_write_begin, we call grab_cache_page_write_begin to get a
page to use for writing data when servicing a write into AFS. Under
low-memory conditions, this can return NULL if Linux cannot find a
free page to use. Currently, we always try to reference the page
returned, and so this causes a BUG.

To avoid this, check if grab_cache_page_write_begin returns NULL, and
just return -ENOMEM, like other callers of grab_cache_page_write_begin
do.

Linux's fault injection framework is useful for testing code paths
like these. The following settings made it possible to
somewhat-reliably exercise the relevant code path on a test RHEL7
system:

    # grep ^ /sys/kernel/debug/fail_page_alloc/*
    /sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem:Y
    /sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:N
    /sys/kernel/debug/fail_page_alloc/interval:1
    /sys/kernel/debug/fail_page_alloc/min-order:0
    /sys/kernel/debug/fail_page_alloc/probability:100
    /sys/kernel/debug/fail_page_alloc/space:90
    /sys/kernel/debug/fail_page_alloc/task-filter:Y
    /sys/kernel/debug/fail_page_alloc/times:-1
    [...]

Change-Id: I00908658ae43aa3c8e12f2a0b956016d4441016c
Reviewed-on: https://gerrit.openafs.org/13242
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agorxevent: prevent negative rx_connection refCount 28/13228/4
Mark Vitale [Sat, 30 Jun 2018 21:35:09 +0000]
rxevent: prevent negative rx_connection refCount

rxi_ChallengeEvent is called directly from rxi_ChallengeOn to start the
first challenge; subsequent calls to rxi_ChallengeEvent are from the
event handler.  When called as an event, we must putConnection the
reference held by the event.  But when called directly for the first
time, the event has not been scheduled yet and so has not taken a
reference on the connection.  For this case, we must not putConnection
or the rx_connection refCount will go negative.

One reported symptom of this bug is a fileserver crash with:
  'Assertion failed! file rx.c, line 1327.'

Introduced by commit 304d758983b499dc568d6ca57b6e92df24b69de8
('Standardize rx_event usage').

Change-Id: I67122ff84ac9b1b6445ad4005e76e5f8482fd7be
Reviewed-on: https://gerrit.openafs.org/13228
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agovolser: DoVolDelete returning VNOVOL is success 76/12976/4
Jeffrey Altman [Sat, 24 Mar 2018 05:22:54 +0000]
volser: DoVolDelete returning VNOVOL is success

When moving, copying or releasing volumes, do not treat a failure
to delete a volume because the volume no longer exists as an error.
The volume clone has flags

  VTDeleteOnSalvage | VTOutOfService

assigned to it which means that the fileserver won't attach the volume
and volume has its deleteMe field assigned the value of DESTROY_ME.
Such a volume will be deleted the next time the salvager scans the
partition.  Once the transaction is complete the volume might be
removed.

Change-Id: I0bd38906e3836e0c96f3784a8bd9ad63f5b857c6
Reviewed-on: https://gerrit.openafs.org/12976
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: Change afs_AllocDCache to return error codes 27/13227/3
Andrew Deason [Thu, 28 Jun 2018 18:08:47 +0000]
afs: Change afs_AllocDCache to return error codes

Currently, afs_AllocDCache can fail in 2 different situations:

- When we are out of dslots on the free/discard lists
- When we encounter an i/o error when trying to traverse the dslot
  lists

But afs_AllocDCache cannot distinguish between these two cases to its
caller in any way, since all we have to return is a struct dcache (and
so we return NULL on any error).

Currently, the caller of afs_AllocDCache in afs_GetDCache is
determining which of these cases happened by looking at
afs_discardDCList and afs_freeDCList, to see if they look empty. This
is not great for at least a couple of reasons:

- We are examining afs_discardDCList/afs_freeDCList after we drop
  afs_xdcache (but while still holding GLOCK)

- If afs_discardDCList/afs_freeDCList are somehow changed while
  afs_AllocDCache is running, we may infer the wrong reason why
  afs_AllocDCache failed. (currently impossible, but this seems
  fragile)

And in general, this check against afs_discardDCList/afs_freeDCList is
rather indirect. It may be easier to follow if afs_AllocDCache just
directly returned the reason why it failed.

So do that, by changing afs_AllocDCache to return an error code, and
providing the struct dcache in an output argument. This involves
similiarly changing several called functions in the same way, to
return error codes. We only define 2 such error codes with this
commit:

- ENOSPC, when we are out of free/discrad dslots
- EIO, when we encounter a disk i/o error when trying to examine the
  dslot list

Note that this commit should not change any real logic; we're mostly
just changing how errors are returned from these various functions.

Change-Id: I07cc3d7befdcc98360889f4a2ba01fdc9de50848
Reviewed-on: https://gerrit.openafs.org/13227
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: Make afs_AllocDCache static 26/13226/2
Andrew Deason [Thu, 28 Jun 2018 17:50:52 +0000]
afs: Make afs_AllocDCache static

Nothing using afs_AllocDCache outside of afs_dcache.c. Declare the
function static, to ensure that nobody else uses it, and to maybe
allow for more compiler optimization.

Change-Id: I4e4d1e77e20e853fc20b3d5c5289a5f4124de7a4
Reviewed-on: https://gerrit.openafs.org/13226
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: log when a server is marked down, and why 16/12616/5
Mark Vitale [Sat, 18 Mar 2017 01:42:31 +0000]
ubik: log when a server is marked down, and why

In order to better manage voting and recovery, each ubik server tracks
(in array ubik_servers) which of its fellow quorum members are 'up' or
not.  However, ubik currently logs only when a server is "back up"; that
is, ubik_server->up transitions from 0 to 1.

Add new log messages to identify the time and reason when a server is
"marked down" (i.e., ubik_server->up transitions from 1 to 0).

Also modify two existing messages to have consistent wording with the
new "marked down" messages.  Also change them to ViceLog (log level
0) so they will always be logged.

Change-Id: I29ee93e96cb7b28b943171d1477671c540a10d78
Reviewed-on: https://gerrit.openafs.org/12616
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: remove dead code 10/13210/3
Mark Vitale [Thu, 14 Jun 2018 18:38:54 +0000]
afs: remove dead code

afs_CheckLocks has been dead code since openafs-ibm-1_0.

No functional change incurred.

Change-Id: I9d57cf3bbbddef182fb128f65b04465bfe0fb492
Reviewed-on: https://gerrit.openafs.org/13210
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agovol: remove dead code 09/13209/2
Mark Vitale [Thu, 14 Jun 2018 18:03:45 +0000]
vol: remove dead code

PartitionID has been dead code since openafs-ibm-1_0.

No functional change incurred.

Change-Id: I93da25ef853716db7a0b7f945f8b19a15a055a43
Reviewed-on: https://gerrit.openafs.org/13209
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoComment out missing comerr functions from afsauthent.def 19/13219/2
Benjamin Kaduk [Fri, 15 Jun 2018 14:07:04 +0000]
Comment out missing comerr functions from afsauthent.def

Apparently commit 70c4922980d1596155b4021cd72d6895c2371e23 was overzealous
in making Windows match Unix, as these functions are not available
in the Windows build.

Change-Id: Ia24430e5069cd61c0557a07d1bd2c35a6872db8c
Reviewed-on: https://gerrit.openafs.org/13219
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoComment out opr_AssertionFailed from afsrpc.def 16/13216/3
Benjamin Kaduk [Fri, 15 Jun 2018 13:39:47 +0000]
Comment out opr_AssertionFailed from afsrpc.def

Apparently the Windows utilities link opr.lib directly, so this
caused a "multiply defined symbol" error.

Change-Id: I0499f789a493960b99052e00763703698b3f9517
Reviewed-on: https://gerrit.openafs.org/13216
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoComment out (again!) xdr_Capabilities from afsrpc.def 15/13215/2
Benjamin Kaduk [Fri, 15 Jun 2018 13:16:26 +0000]
Comment out (again!) xdr_Capabilities from afsrpc.def

This shows up as an "unresolved external" when linking (though apparently
this error does not cause a buildbot failure), noticed when viewing
a related windows build log.

Change-Id: I8bd5e344c1b0e12e0c70e0340bacbc6a94984767
Reviewed-on: https://gerrit.openafs.org/13215
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: do not assign variables in logging argument lists 11/13211/2
Michael Meffie [Thu, 14 Jun 2018 19:01:18 +0000]
ubik: do not assign variables in logging argument lists

Several logging statements in ubik contain an assignment statement
within the logging function call argument list, which would set a
variable as side effect of evaluating the function call arguments.

These embedded assignments are problematic since the logging function
calls have been replaced by ViceLog macros, which avoid the overhead of
a function call depending on logging levels.

Remove the embedded assignments within the logging argument lists so the
variables are always set regardless of the logging level.

Change-Id: Ifc0f32df2d01f9d8105b49e2c56a95758b184449
Reviewed-on: https://gerrit.openafs.org/13211
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Joe Gorse <jhgorse@gmail.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoRemove the unused opr_AssertFailU() function 13/13213/2
Benjamin Kaduk [Fri, 15 Jun 2018 01:37:46 +0000]
Remove the unused opr_AssertFailU() function

Change-Id: Idb55adeea508d3376269bce998eb8b1c3e4cbd59
Reviewed-on: https://gerrit.openafs.org/13213
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoUn-export opr_AssertFailU 12/13212/2
Benjamin Kaduk [Fri, 15 Jun 2018 01:35:46 +0000]
Un-export opr_AssertFailU

It appears to have been created for parity with osi_AssertFailU, but
was then never used.

It is safe to remove the export line, since this export has never
been in a released version of OpenAFS.

Change-Id: Ia0bdaec891450fe9a3ca10badcaba68bea27c466
Reviewed-on: https://gerrit.openafs.org/13212
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agomcas: Make sure 'padding' is null-terminated 64/13164/4
Pat Riehecky [Wed, 6 Jun 2018 16:10:25 +0000]
mcas: Make sure 'padding' is null-terminated

With 'padding' explicitly filled with all spaces string copy operations
may result in unexpected values.  Padding is extended by 1 and null
terminated to avoid unexpected behavior.
(via cppcheck)

Change-Id: I8a9845ae87002018705ad23c2b089c8ef571b7bc
Reviewed-on: https://gerrit.openafs.org/13164
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsrpc: export more xdr functions 39/13139/4
Benjamin Kaduk [Fri, 1 Jun 2018 00:02:18 +0000]
libafsrpc: export more xdr functions

Most of the xdr functions in the library text are to support RXAFS and
RXAFSCB RPCs, which we explicitly do not expose from libafsrpc.
As such, they do not need to be in the export list, but a couple of
generic ones probably should be exported.

Do so, for both Unix and Windows.

Change-Id: I12ddf2427d807f4ee7b07af1e1c498fc119a0f1c
Reviewed-on: https://gerrit.openafs.org/13139
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agolibafsrpc: export some more rx functions 38/13138/4
Benjamin Kaduk [Fri, 1 Jun 2018 00:00:03 +0000]
libafsrpc: export some more rx functions

Change-Id: I6aea7eff7a5bc957896a5a7457a945dd0feaec88
Reviewed-on: https://gerrit.openafs.org/13138
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoExport missing opr functions from libafsrpc 37/13137/3
Benjamin Kaduk [Thu, 31 May 2018 23:40:21 +0000]
Export missing opr functions from libafsrpc

Our assertion macros expand to function calls, and we have assertions
included in macros in installed headers, so the public needs to be
able to link against them.

Export for both Unix and Windows.

Change-Id: Ibd1da844f274398e9296f00241b1be48bb95e4fe
Reviewed-on: https://gerrit.openafs.org/13137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsauthent: export additional xdr_ functions 31/13131/5
Benjamin Kaduk [Mon, 28 May 2018 03:54:01 +0000]
libafsauthent: export additional xdr_ functions

Formally, we need to use xdr_free to deallocate storage for RPC output
variables, in case the XDR stack uses a different allocator than the
standard application allocator.  Some types have non-autogenerated
wrappers exposed already (e.g., token_FreeSet()), but for a handful of
the base ptint types we need to expose the xdr routines in order for a
safe way to deallocate their storage to be available.

Change-Id: Iaac349cfaa1a07d5908a88e4c230874c6301471a
Reviewed-on: https://gerrit.openafs.org/13131
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: Stop looking for dcaches on Get*DSlot errors 34/13034/6
Andrew Deason [Thu, 26 Apr 2018 17:27:12 +0000]
afs: Stop looking for dcaches on Get*DSlot errors

In various places in the code, we'll be looking for a dslot, calling
afs_GetValidDSlot (or afs_GetUnusedDSlot) in a loop. In a few places,
we currently keep looking for the dslot when we get an error back,
since afs_GetValidDSlot may return successfully for other slots, and
we might find the dslot we're looking for.

This behavior was introduced in a few commits, including:

- commit 2679af76 (afs: Traverse discard/free dslot list if errors)
- commit 00fd34a6 (afs: Handle easy GetValidDSlot errors)
- commit 9a558660 (afs: Cope with afs_GetValidDSlot errors)

This behavior means that if afs_GetValidDSlot/afs_GetUnusedDSlot
returns an error for a particular dcache slot, but other slots are
okay, then we may still find the dcache we're looking for.

However, by far the most common reason that
afs_GetValidDSlot/afs_GetUnusedDSlot fails is because our disk cache
is completely unusable; it is very rare that only a few slots cannot
be used, but others are fine (this would mean that the disk cache was
corrupted in oddly specific ways, or there are small isolated errors
in the underlying disk). So continuing the dcache search in these
situations is not very useful.

On Linux, this is most commonly seen by the underlying disk cache i/o
calls returning -EINTR, which can happen if a SIGKILL signal is
pending for the current process when we try to do the i/o. In this
situation, all attempts to read in a dslot from disk will fail; trying
other slots or waiting will not improve the situation. Depending on
which specific code path encounters an afs_Get*DSlot error, we can
then flood the log with "disk cache read error in CacheItems" messages
emitted from afs_UFSGetDSlot, since we keep calling afs_Get*DSlot in
our loop.

The worst offender of this is usually afs_GetDSlotFromList via
afs_AllocDCache, since we end up calling afs_GetUnusedDSlot for every
single dslot in the free and discard lists. However, our other call
sites that are looking for dcaches for a specific file can still
generate quite a few of these messages, since we'll end up calling
afs_GetValidDSlot for every slot in a dcache hash chain.

So to avoid flooding the log in these situations, change most callers
of afs_GetValidDSlot and afs_GetUnusedDSlot to stop on the first
error, and act like we never found a dcache that we were looking for.

This commit also adjusts one caller in afs_ProcessOpCreate, which was
not handling errors from afs_GetValidDSlot at all, and changes
FlushVolumeData to be able to return error codes.

Change-Id: I3047da690d39c000ef59dfc0ad526ecc5e382104
Reviewed-on: https://gerrit.openafs.org/13034
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: Avoid GetDCache delays on screwy cache 33/13033/3
Andrew Deason [Thu, 26 Apr 2018 17:01:57 +0000]
afs: Avoid GetDCache delays on screwy cache

Currently, if our afs_AllocDCache call fails in afs_GetDCache, we
retry once per second for 5 minutes. The reasoning is that we're out
of dcache slots, and so if we wait a little while, maybe something
will become freeable and we can continue.

However, afs_AllocDCache can also fail if we have plenty of free
dslots, but we are unable to successfully call afs_GetUnusedDSlot() on
any of them. This can happen if our disk cache is screwed up, and so
waiting and retrying will not make things better (but we'll spew a ton
of "disk cache read error in CacheItems slot" errors in the log each
time, and do so 300 times).

So instead, only do our sleep/retry loop if we actually appear to be
out of free or discarded dslots. Otherwise, just return an error
immediately, since sleeping and retrying will not make anything
better.

Change-Id: I331913ab882216e3f71cc44da91f7f7d33c34004
Reviewed-on: https://gerrit.openafs.org/13033
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: Avoid GetDCache panic on AllocDCache failure 32/13032/3
Andrew Deason [Thu, 26 Apr 2018 17:02:18 +0000]
afs: Avoid GetDCache panic on AllocDCache failure

Currently, in afs_GetDCache, if afs_AllocDCache fails, we retry for 5
minutes and then panic. Panicing in this situation is completely
unnecessary; afs_GetDCache can fail for a variety of other mundane
reasons (such as, if we can't fetch the requested data from the
relevant fileserver).

It may seem unusual for afs_AllocDCache to fail for over 5 minutes
(this is supposed to mean that we're out of dslots, and our attempts
to free up dslots have failed). However, afs_AllocDCache can also fail
if we are having issues in accessing the disk cache, and so we may not
be out of cache space or dslots at all; we just can't access the
cache. In this case, afs_AllocDCache can easily fail forever; waiting
longer or trying to free up cache space isn't going to help.

So, to avoid panicing in such situations, just make afs_GetDCache
return an error. We just need to make sure afs_xdcache is unlocked,
and then we can just jump to 'done', like plenty of other codepaths
do; no extra cleanup is required.

Also since we are removing a panic, add a log message when this
situation happens, so EIO errors don't suddenly pop up silently.

Change-Id: I9b8dd6c861b8066822c44758566c05abd7dc1660
Reviewed-on: https://gerrit.openafs.org/13032
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agorxgk: Define some protocol constants 39/12939/3
Andrew Deason [Thu, 1 Mar 2018 00:25:46 +0000]
rxgk: Define some protocol constants

rxgk_int.xg is missing a few constants mentioned in the respective
protocol specs:

- The RPC-L definitions for PrAuthName are defined, but no
  PRAUTHTYPE_* constants for the 'kind' field are defined. Define at
  least PRAUTHTYPE_GSS, which rxgk uses.

- The rxgk spec indicates a size of 20 for the nonces used in rxgk
  challenge and response packets. Define a constant
  (RXGK_CHALLENGE_NONCE_LEN) for this value, to make it easier to
  define similarly-sized structures.

- The rxgk-afs spec defines the time value of 0 as a special "never
  expires" value. Define a constant (RXGK_NEVERDATE) to represent it.

Change-Id: I07e1a1b19d1c887fd3e1a1d0f270d5af7b8581b0
Reviewed-on: https://gerrit.openafs.org/12939
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: make ContactQuorum_* routines static 78/13078/3
Mark Vitale [Fri, 4 May 2018 19:42:14 +0000]
ubik: make ContactQuorum_* routines static

Most of the ContactQuorum_* routines are only used in ubik.c, so make
them all static - except for ContactQuorum_DISK_SetVersion, which is
called from disk.c.

Change-Id: I7d1ccd839e01ea8ee8d768dd369a892773361b05
Reviewed-on: https://gerrit.openafs.org/13078
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: remove unused ContactQuorum_DISK_Write 77/13077/3
Mark Vitale [Wed, 9 May 2018 20:50:55 +0000]
ubik: remove unused ContactQuorum_DISK_Write

This function is not used; remove it.

No functional change is incurred by this commit.

Change-Id: I7e3bb26fb62b0e28c8703154eb3df384d4dbc32d
Reviewed-on: https://gerrit.openafs.org/13077
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: disambiguate "Synchonize database with server" msgs 15/12615/4
Mark Vitale [Mon, 8 May 2017 21:50:00 +0000]
ubik: disambiguate "Synchonize database with server" msgs

Ubik issues the same message in two very different cases:
- sync server issues DISK_GetFile to obtain the latest version
- non-sync server receives DISK_SendFile from the sync server

Modify the messages so they provide more information and are
distinguishable from each other.

Change-Id: I99e8adc7229260f478a0df15791216e090d2e113
Reviewed-on: https://gerrit.openafs.org/12615
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoxdr: remove dead code, whitespace from xdr_enum 76/13076/4
Mark Vitale [Tue, 5 Jun 2018 18:12:20 +0000]
xdr: remove dead code, whitespace from xdr_enum

The 'enum sizecheck' declaration has been unused since openafs-ibm-1_0; it is
apparently vestigial from the original XDR code.  Remove it, along with some
extraneous whitespace.

No functional change is incurred by this commit.

Change-Id: I9f725ab6aff6cafa911975e9edaed8f07c8a328a
Reviewed-on: https://gerrit.openafs.org/13076
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoxdr: avoid xdr_enum memory overrun 75/13075/4
Mark Vitale [Wed, 6 Jun 2018 19:23:26 +0000]
xdr: avoid xdr_enum memory overrun

Since openafs-ibm-1_0, xdr_enum has used xdr_long to read and write, even
though enum_t is defined as int.  For systems where sizeof(int) ==
sizeof(long), this works by accident.  But other systems (e.g., DARWIN
ARCHFLAGS=x86_64) xdr_enum will overrun its int-sized second parameter.  For
XDR_DECODE, this results in memory corruption.

This was first noticed with OpenAFS 1.8.0 on macOS 10.13; if aklog is issued
while already holding a token, it will fail in token_SetsEquivalent with a
segfault in decodeToken.  The root cause is that the address passed to
decodeToken had been overwritten by a previous call to tokenType -> xdr_enum ->
xdr_long.

Instead, modify xdr_enum to use xdr_int for its work.

Change-Id: I671d55588d88e0640f365624b83bd04b53dc97cc
Reviewed-on: https://gerrit.openafs.org/13075
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsauthent: export ugen_ClientInit* 30/13130/2
Benjamin Kaduk [Sun, 27 May 2018 21:23:16 +0000]
libafsauthent: export ugen_ClientInit*

Windows was only exporting the bare version and not the Cell/Flags/Server
versions; Unix was exporting none of them.

These routines for obtaining a ubik client are more generic than the
historical (and already exported) ubik_ClientInit routine, allowing for
the use of an alternative configuration directory, additional flags,
and the like.

Change-Id: I6577ef5f95d2b801c049befa9fddd3b605ff80f5
Reviewed-on: https://gerrit.openafs.org/13130
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsauthent: Export more token-manipulation functions 29/13129/2
Benjamin Kaduk [Sun, 27 May 2018 21:03:12 +0000]
libafsauthent: Export more token-manipulation functions

For both Windows and Unix.

Change-Id: Icd90a2fd3f674b13dd44323d9bc20a8f1070a16e
Reviewed-on: https://gerrit.openafs.org/13129
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsauthent: export ktc token 'Ex' routines for Unix 28/13128/2
Benjamin Kaduk [Sun, 27 May 2018 20:18:12 +0000]
libafsauthent: export ktc token 'Ex' routines for Unix

We need these to handle the modern identity structures (they are
already exported on Windows).

Change-Id: I3a3f766e9c9a9fad96f2656c4f066a67cacee4a6
Reviewed-on: https://gerrit.openafs.org/13128
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolibafsauthent: export more afsconf_ functions 27/13127/2
Benjamin Kaduk [Sun, 27 May 2018 19:18:07 +0000]
libafsauthent: export more afsconf_ functions

We have new functions for (among other things) typed keys, and generic
rx identity management; expose them as well as the legacy key- and user-
management functions, on both Unix and Windows.

Change-Id: Id9bc394d631f9c00915520aff763af497ef2035b
Reviewed-on: https://gerrit.openafs.org/13127
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoSynchronize libafsauthent afsconf_ exports with windows 26/13126/2
Benjamin Kaduk [Sun, 27 May 2018 18:11:05 +0000]
Synchronize libafsauthent afsconf_ exports with windows

The Windows library was exporting several more afsconf_* symbols
than the Unix one; bring them into sync.

Change-Id: Ifba074124a0a3cfeed256553d7dbedbebd3c2996
Reviewed-on: https://gerrit.openafs.org/13126
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: fix broken volume callbacks (e.g. vos release) 90/13090/2
Mark Vitale [Fri, 25 May 2018 21:05:28 +0000]
afs: fix broken volume callbacks (e.g. vos release)

Commit e99bfcfaa3bca3e65f03928718c2c9eb5eff7c8c ('afs: use jenkins hash
for dcache, vcache tables') introduced new hashing implementations for
the dcache and vcache hash tables.  Unfortunately, a typo introduced a
bug into the VCHashV hash function; instead of hashing by volume id, it
currently hashes by vnode.

The most common symptom is that volume callbacks (RXAFSCB_Callback with
fid <volid>:0:0) fail to find and invalidate all the files for the
specified volume.  This typically manifests as persistent stale RO
content after a 'vos release' for new RW content.

This bug only affects the Unix cache manager; the Windows cache manager
implementation of RXAFSCB_Callback was unaffected.

Change-Id: I7edca660671b880a69f0c499d54adffbbe62d2b2
Reviewed-on: https://gerrit.openafs.org/13090
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoRemove pointless assignments 86/13086/3
Pat Riehecky [Fri, 25 May 2018 17:03:35 +0000]
Remove pointless assignments

scan-build identified these var assignements as being unused or redundant.

Change-Id: I3b51e3e1503c0724a2cf1bab37e1c02f4ae533b2
Reviewed-on: https://gerrit.openafs.org/13086
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoConvert extended character set to unicode 88/13088/2
Pat Riehecky [Fri, 25 May 2018 17:48:15 +0000]
Convert extended character set to unicode

Change-Id: I9989f16ac670e007827ecfe8e02daf9b36d98d4e
Reviewed-on: https://gerrit.openafs.org/13088
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoAdd missing va_end 87/13087/3
Pat Riehecky [Fri, 25 May 2018 17:11:54 +0000]
Add missing va_end

Per man va_start:
Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function.

Change-Id: I703bb3e633435f9c9a62717333a6027476b6bab8
Reviewed-on: https://gerrit.openafs.org/13087
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoAdd braces to empty conditional blocks 81/13081/5
Pat Riehecky [Wed, 23 May 2018 20:50:45 +0000]
Add braces to empty conditional blocks

GCC 7+ is able to quickly optimize away empty if/else blocks if the braces are
provided.  While this adds some additional syntax, it should also result
in faster optimization, so change our empty blocks after conditionals to use
braces.

FIXES 134377

Change-Id: I2b5e39fd8a3819e07077c2a4f28a9aa5ac432e1e
Reviewed-on: https://gerrit.openafs.org/13081
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoWindows: define AFS_IHANDLE_PIO_ENV for ihandle pio 70/12270/4
Michael Meffie [Mon, 25 Apr 2016 15:19:10 +0000]
Windows: define AFS_IHANDLE_PIO_ENV for ihandle pio

Support for positional i/o in the ihandle package was added to the
windows platform in commit 50b6a116a1c412d0e6d7442d13d6e92c9dbb35ee
using native windows functions.  That commit also defined HAVE_PIO in
the windows version of the afsconfig.h file. Unfortunately, that
definition of HAVE_PIO is not limited to the ihandle package.

Remove the project-wide HAVE_PIO definition from the windows afsconfig.h
file and define the new AFS_IHANDLE_PIO_ENV symbol when position i/o
support is available in the ihandle package.

Build the fallback ih_pread and ih_pwrite functions (which use lseek)
only when positional i/o is not available in the ihandle package for the
current platform.

Use AFS_IHANDLE_PIO_ENV instead of HAVE_PIO in ih_open() to determine
when it is is safe to share ihandles among threads.

Change-Id: I39b078177bc5a2f1daf8a8f8e6bfb1c76e6dfaf7
Reviewed-on: https://gerrit.openafs.org/12270
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: convert ubik_print to ViceLog 19/12619/5
Michael Meffie [Mon, 25 Apr 2016 15:06:11 +0000]
ubik: convert ubik_print to ViceLog

Use the server logging macros instead of the utility functions to avoid
function call overhead, especially at logging level 25.  The server
logging macros perform a logging level check in-line to avoid the
unnecessary ubik_dprint* calls.

Change-Id: Ia86efad6257b764f0922957017fe8326f0de76d3
Reviewed-on: https://gerrit.openafs.org/12619
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoptserver: improve PR_GetHostCPS logging 43/13043/3
Mark Vitale [Tue, 24 Apr 2018 18:41:11 +0000]
ptserver: improve PR_GetHostCPS logging

The IP address of the host is logged as a signed number.  Instead, log
it as the unsigned (and hex) representation of the host IP addr.

Change-Id: Ic8b2b7da852a3dc7e9984b63da70d0403845452e
Reviewed-on: https://gerrit.openafs.org/13043
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoExport afs_getDirPath from shared libraries 59/13059/2
Benjamin Kaduk [Sat, 5 May 2018 20:59:08 +0000]
Export afs_getDirPath from shared libraries

Add this function to the export list for libafsauthent on Windows
and Unix.

Change-Id: Ib6f219e407b75a6052d6e29008977c8545b2aa36
Reviewed-on: https://gerrit.openafs.org/13059
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoRename getDirPath to afs_getDirPath in preparation for export 58/13058/2
Benjamin Kaduk [Sat, 5 May 2018 20:42:51 +0000]
Rename getDirPath to afs_getDirPath in preparation for export

The symbol name getDirPath is rather generic and we probably shouldn't
squat on it in the application's namespace.  In preparation for exporting
this functionality from the Unix shared libraries, rename it to
afs_getDirPath.

Retain a Windows-only wrapper getDirPath that can continue to be
exported from libafsauthent on Windows, for ABI compatibility.
New consumers should use afs_getDirPath.

Change-Id: Ie3f3f7b0662451353834d2e3b5c3dd1131c1935e
Reviewed-on: https://gerrit.openafs.org/13058
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoRemove duplicates from liboafs_util.la.sym 57/13057/2
Benjamin Kaduk [Sat, 5 May 2018 20:35:03 +0000]
Remove duplicates from liboafs_util.la.sym

Remove the extra copy of things which appeared twice.

Change-Id: I95542172f28759852a76589d05845869cf7e9c9a
Reviewed-on: https://gerrit.openafs.org/13057
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoExport ubik_PR_ symbols from libafsauthent 56/13056/2
Benjamin Kaduk [Sat, 5 May 2018 19:42:31 +0000]
Export ubik_PR_ symbols from libafsauthent

Also export from liboafs_prot the ones missing from this set.

This brings the unix exports in sync with the Windows exports
(of ubik_PR_ symbols), and is tested as being sufficient to compile
python-afs.

Change-Id: I77941aa7fbbcb154c67769fe875474920d86d756
Reviewed-on: https://gerrit.openafs.org/13056
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoExport comerr initialization functions from libafsauthent 55/13055/3
Benjamin Kaduk [Sat, 5 May 2018 19:00:27 +0000]
Export comerr initialization functions from libafsauthent

Add to the libafsauthent export symbol list these comerr initialization
functions so that they are usable by consumers.

Change-Id: I72c6f9402a46aff6fa2719c0b9e0974c7ff7b57e
Reviewed-on: https://gerrit.openafs.org/13055
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoopr: install afs/opr.h and opr/lock.h 54/13054/2
Benjamin Kaduk [Sat, 5 May 2018 18:11:00 +0000]
opr: install afs/opr.h and opr/lock.h

These headers are (transitively) referenced from rx_pthread.h, which is pulled
in from rx.h when AFS_PTHREAD_ENV is defined.  As such, we are presenting an
incomplete public API without this header.

Change-Id: I8afd1d635534910739ec37d56201a86998962cfa
Reviewed-on: https://gerrit.openafs.org/13054
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: remove redundant memset from udisk_write 21/12621/4
Mark Vitale [Fri, 19 May 2017 20:34:21 +0000]
ubik: remove redundant memset from udisk_write

When udisk_write is extending the database, DRead will return a null
buffer.  udisk_write then calls DNew to get a brand new buffer for the
extension write, and clears it with memset.  However, this is redundant,
since DNew has already cleared the new buffer.

Remove the redundant memset.

No functional change should be incurred by this commit.

Change-Id: Ia6768098fb3c67475c8948c874b92b91bf17cdb7
Reviewed-on: https://gerrit.openafs.org/12621
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoubik: death to orphaned signals 20/12620/3
Mark Vitale [Wed, 17 May 2017 20:32:20 +0000]
ubik: death to orphaned signals

ubik has a few very old "orphaned" LWP events that are signalled via
LWP_NoYieldSignal, but have no matching waits (LWP_WaitProcess).

Each "signal" runs the LWP waiting element list for each LWP on the
blocked queue; this may add up to substantial wasted overhead on a
heavily loaded ubik server.

Remove the orphaned signals.

No functional difference should be incurred by this commit.

Change-Id: I66eba45975a829216e7af1927e51ec6aab63f570
Reviewed-on: https://gerrit.openafs.org/12620
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agolwp: Fix possible memory leak from scan-build 80/13080/3
Pat Riehecky [Wed, 23 May 2018 20:42:09 +0000]
lwp: Fix possible memory leak from scan-build

It is possible for LWP_CreateProcess to return early. When it does, it
should free up any memory it allocated before leaving scope.

Change-Id: Ib5644d36dc01bbac33804f4a039661ce2c78969d
Reviewed-on: https://gerrit.openafs.org/13080
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoutil: check for trailing characters in partition names 39/13039/4
Michael Meffie [Sat, 28 Apr 2018 03:08:34 +0000]
util: check for trailing characters in partition names

The function which maps partition names to partition ids currently
ignores trailing characters in the partition names. For example, the
partition name "/vicepbogus" is currently considered a valid partition
name ("/vicepbogus" maps to "bo" which is id 66). Although this is not a
regression, it is problematic for several reasons.

Firstly, this can lead to duplicate partition ids on the server, for
example "/vicepbad" and "/vicepbar" both map to the same partition id
("ba" is id 52).

Second, partitions are internally tracked by numeric id. The partition
names are generated from numeric ids when reporting partition names.
This means the trailing characters are lost when reporting the partition
names. For example, vos reports the attached partition "/vicepbad" as
"/vicepba".

Third, it could be possible (but perhaps unlikely) in the future to
extend the range of partition ids, so the trailing characters could
become significant at that time.

Finally, it could be confusing to admins that such partition names are
attached by the fileserver. For example, "/vicepaa-backup" is attached
and is used by the fileserver as partition id 26.

This change adds a check for trailing characters in partition names in
the volutil_GetPartitionID function, so it is more strict in what it
accepts as a valid partition name.  That function will now return -1
(illegal partition name) when trailing characters are found in
partition names.

Change-Id: Iad9aee05fcf439cac9afcd89cf367be693261fbd
Reviewed-on: https://gerrit.openafs.org/13039
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

5 years agovol: check for bad partition names 38/13038/2
Michael Meffie [Sat, 28 Apr 2018 02:59:57 +0000]
vol: check for bad partition names

Currently, servers attempt to attach any partition name starting with
"/vicep", even partition names which map to out of range partition ids.
Examples of such misnamed partitions are "/vicepzz", "/vicep0", and
others.

The presence of these misnamed partitions cause the server processes to
crash on startup, since the out of range partition ids are used as an
index.

Add a check for the bad partition names in VCheckPartitions to avoid
attaching them. Log a warning for such partitions to let the admins know
why the partitions are not attached.

Change-Id: I553ce6cc8bc751b9ed789312f7efb4e0f737a52e
Reviewed-on: https://gerrit.openafs.org/13038
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: Make udisk_Log* functions static 69/13069/2
Andrew Deason [Thu, 10 May 2018 21:23:48 +0000]
ubik: Make udisk_Log* functions static

Nothing uses the udisk_Log* functions outside of disk.c. Declare these
static to make sure they stay that way, to make it easier to change
their semantics.

Change-Id: I068684782b22af788ce892c995a6d80f2d9fb2e0
Reviewed-on: https://gerrit.openafs.org/13069
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: Remove 'mtime' from ubik_stat 68/13068/2
Andrew Deason [Thu, 10 May 2018 21:05:10 +0000]
ubik: Remove 'mtime' from ubik_stat

Nothing uses the 'mtime' field from ubik_stat. Remove it.

Change-Id: I7611a7ca5aa5743be43aefafeda5ecf9a5d47598
Reviewed-on: https://gerrit.openafs.org/13068
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoviced: SRXAFS_InlineBulkStatus set InterfaceVersion on error 67/13067/2
Jeffrey Altman [Fri, 11 May 2018 19:44:24 +0000]
viced: SRXAFS_InlineBulkStatus set InterfaceVersion on error

AFSFetchStatus.InterfaceVersion is required to be "1" for any
of the fields in the structure to be considered valid.  Therefore,
InterfaceVersion must be set to one when returning an 'errorCode'
value.

When RXAFS_InlineBulkStatus was introduced by OpenAFS in
362d26c733b086d26f013bd229af979a112098f5 not only wasn't
InterfaceVersion set but neither was the memory allocated
to OutStats initialized.  As a result the InterfaceVersion field
value could be not only zero but random.  The OutStats memory
was initialized to zeros beginning with
726e1e13ff93e2cc1ac21964dc8d906869e64406.

Change-Id: I5ca1b08cb32d01843a1c6dee87d8ba1d560396c8
Reviewed-on: https://gerrit.openafs.org/13067
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoubik: clones should not request votes 54/12654/3
Marcio Barbosa [Tue, 15 May 2018 21:10:45 +0000]
ubik: clones should not request votes

Clones should not be able to become the sync-site. To make it possible,
regular sites do not vote for a site tagged as clone. In other words,
the clones ask for votes but they cannot be the sync-site. Knowing that
their requests for votes should be refused by the regular sites, they
should never have enough votes to win the election.

In addition to the unnecessary network traffic created by these
unnecessary requests, this current approach can be problematic in some
specific situations. As an example, consider the following scenario:

    The user wants to turn a regular site, called host1, into a clone.
    To do so, he runs the following commands on every single server:

    $ bos removehost -server <server> -host host1
    $ bos addhost -server <server> -host host1 -clone

After that, he restarts the servers, one by one. Depending on the delay
between the restarts, a clone can become the sync-site. This is possible
because the clones request votes from the other sites. If enough regular
sites are not aware (yet) that the request for vote came from a clone,
the clone in question can get enough votes to win the election.

To fix the problems mentioned above, do not request votes if you cannot
be the sync-site.

Change-Id: Ic3569af8264dfff32f2a86b8dd99b922193f010a
Reviewed-on: https://gerrit.openafs.org/12654
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoafs: alloc openafs_lck_grp before osi_Init() on darwin 65/13065/3
Marcio Barbosa [Thu, 10 May 2018 03:46:01 +0000]
afs: alloc openafs_lck_grp before osi_Init() on darwin

Commit a27bed59cae1a4244429c752edfde0a8363c8a3b moved init_hckernel_init
to osi_Init. On Darwin (AFS_DARWIN80_ENV), MUTEX_INIT
(called by init_hckernel_init) uses openafs_lck_grp as the argument of
one of the functions called during the initialization of the mutex in
question. Since openafs_lck_grp was not allocated yet, we crash.

To fix this problem, call MUTEX_SETUP() before osi_Init() on Darwin.

Change-Id: Ib53118208d3ca7982e712768f334299e3d948805
Reviewed-on: https://gerrit.openafs.org/13065
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agorx: fix atomics on darwin 63/13063/3
Marcio Barbosa [Mon, 14 May 2018 19:46:26 +0000]
rx: fix atomics on darwin

As described by commit b2a21422129ca1eeeb5ea1a1f7b08b537fd2a9f7, the API
used for atomic operations in kernel space is not the same as the one
used in user space. To fix this problem, the commit mentioned above
introduced macros to correct the name of these functions in kernel space.
Unfortunately, the return value of the functions used in kernel space is
not the same as the ones used in user space. Generally speaking, the
kernel space atomic functions return the original value of the variable
received as an argument before the operation in question. On the other
hand, the user space atomic functions return the new value, after the
operation has been performed. To fix this problem, this commit provides
a new set of inline functions (only used in kernel space) with the
expected return values.

Also, in order to get the inline implementations of the OSAtomic
interfaces in terms of the <stdatomic.h> primitives, commit
74f837fd943ddfa20d349a83d6286a0183cb4663 defines OSATOMIC_USE_INLINED
on OS X 10.12. However, the definition of this macro only affects the
user space legacy interfaces for atomic operations. The kernel space
interfaces for atomics are not deprecated and OSATOMIC_USE_INLINED does
not affect these functions. To fix this problem, only define
OSATOMIC_USE_INLINED in user space (OS X 10.12+).

Change-Id: Ia6cbc76daa7068625dc9f6dff385d0568d6503bd
Reviewed-on: https://gerrit.openafs.org/13063
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoLINUX: Remove unused osi_fetchstore.c 61/13061/4
Andrew Deason [Wed, 9 May 2018 00:09:42 +0000]
LINUX: Remove unused osi_fetchstore.c

Ever since commit ae5f411c (Linux 4.4: Do not use splice()), most of
osi_fetchstore.c has been '#if 0'd out. The only portion that isn't is
a function definition that is unreferenced (afs_linux_read_actor).

Remove the unused code, and other '#if 0' references to it; the code
can always be added back later when we can actually use it.

Change-Id: Ifc062d5665393aa6693eb0db63aa23e4feb44df4
Reviewed-on: https://gerrit.openafs.org/13061
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: WriteThroughDSlots: Avoid write error panic 47/13047/4
Andrew Deason [Mon, 30 Apr 2018 22:58:43 +0000]
afs: WriteThroughDSlots: Avoid write error panic

Currently, afs_WriteThroughDSlots panics if our call to
afs_WriteDCache fails. Since afs_WriteThroughDSlots is called every
minute by a background daemon, this means that if our cache fs becomes
inaccessible (by being forced read-only, or for any other reason), we
are virtually guaranteed to panic relatively quickly.

To try to avoid this at least for some cases, change
afs_WriteThroughDSlots to return an error to our caller when we
encounter such an error. For our background task, we can just ignore
the error and retry the writes on a future iteration. During shutdown,
we still panic if we encounter an error, to try to avoid silently
allowing a corrupt cache to be used on subsequent boots.

Change-Id: Ia5f180a5c709881c3e884629c02e9ff93729fa88
Reviewed-on: https://gerrit.openafs.org/13047
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

5 years agoafs: Avoid afs_GetDCache panic on cache open error 46/13046/4
Andrew Deason [Mon, 30 Apr 2018 22:33:14 +0000]
afs: Avoid afs_GetDCache panic on cache open error

When we need to populate a dcache entry, afs_GetDCache calls
afs_CFileOpen to get a handle for our file backing that dcache.
Currently, if we cannot open the file, we panic.

To handle this a little more gracefully, just return an error from
afs_GetDCache instead. The relevant userspace request will probably
fail with EIO, but this is better than possibly crashing the whole
system.

Change-Id: If570ecc7f0fd0aab8340b568fc6cb2e2d316f35a
Reviewed-on: https://gerrit.openafs.org/13046
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoUse afs_DestroyReq in afs_PrefetchNoCache() 60/13060/2
Benjamin Kaduk [Tue, 8 May 2018 23:04:21 +0000]
Use afs_DestroyReq in afs_PrefetchNoCache()

Since commit 76ad941902c650a4a716168d3cbe68f62aef109f we use afs_DestroyReq()
instead of osi_Free() directly.

Also update the UKERNEL version of the function to afs_CreateReq() properly.

FIXES 134533

Change-Id: I4a13f6232dbed12ee00ce219cb5f515529fff58c
Reviewed-on: https://gerrit.openafs.org/13060
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoLINUX: Return NULL for afs_linux_raw_open error 45/13045/3
Andrew Deason [Mon, 30 Apr 2018 22:30:56 +0000]
LINUX: Return NULL for afs_linux_raw_open error

Currently, afs_linux_raw_open (and by extension, LINUX's
implementation of osi_UFSOpen) panic when they are unable to open the
given cache file. To allow callers to handle the error more
gracefully, change afs_linux_raw_open and osi_UFSOpen to return NULL
on error, instead of panic'ing. Expand the language a little on the
message logged while we're here, since the system might keep running
after this situation now.

This commit also changes all callers that did not already handle
afs_linux_raw_open/osi_UFSOpen errors to assert on errors, so we still
panic for all situations where we encounter an error. More graceful
behavior will be added in future commits; this commit does not change
the behavior on its own.

An error on opening cache files can legitimately happen when there is
corruption in the filesystem backing the disk cache, but possibly the
easiest way to generate an error is if the filesystem has been
forcibly mounted readonly (which can happen at runtime due to
filesystem corruption or various hardware faults). The latter will
generate -EROFS (-30) errors, but of course other errors are probably
possible.

Change-Id: I1462ec43c76c0b07e9368b37a9dbaedf6b6f4409
Reviewed-on: https://gerrit.openafs.org/13045
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoBSD: Work around panic in FlushVCache 14/13014/3
Benjamin Kaduk [Fri, 13 Apr 2018 13:07:59 +0000]
BSD: Work around panic in FlushVCache

Commit 64cc7f0ca7a44bb214396c829268a541ab286c69 created the very useful
afs_StaleVCache() helper function, but unfortunately it also introduced
a subtle change into how we check for whether a vcache may be a directory.
Previously, we just used the low bit of the Fid's Vnode number, since files
have an even number and non-files an odd number.  The new version uses
that check but also explicitly checks `vType(avc)` against VDIR, and this new
check involves consulting information stored in the associated vnode entry,
not the vcache directly.  The afs_FlushVCache() implementation for
XBSD and DARWIN NULLs removes the cross-linkage between vcache and vnode,
so that AFSTOV(avc) becomes NULL.  Just a few lines later, it calls
afs_StaleVCacheFlags(), at which point vType() dereferences a bad pointer
(offset from a NULL pointer) and panics.  This would happen during shutdown,
or other periodic reclaim/flush events that can be scheduled.

Change-Id: I0800e5c743cedcbec628bfa8c8ea8978c2488c1c
Reviewed-on: https://gerrit.openafs.org/13014
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: PACKAGE_VERSION macro no longer exists 31/13031/2
Stephan Wiesand [Thu, 26 Apr 2018 17:50:06 +0000]
redhat: PACKAGE_VERSION macro no longer exists

Commit 0d0e7699c9f789214205fe6837cded1a4c95f9c0 replaced all uses
of the %PACKAGE_VERSION macro in the spec with the %version one, but
missed an instance in the kmodtool script. Fix this, to avoid a
warning during rpmbuild.

Change-Id: I363241f45c5261aaf2fa0619fb159022f6dbd56a
Reviewed-on: https://gerrit.openafs.org/13031
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

5 years agoredhat: Make separate debuginfo for kmods work with recent rpm 30/13030/2
Stephan Wiesand [Thu, 26 Apr 2018 17:33:31 +0000]
redhat: Make separate debuginfo for kmods work with recent rpm

Commit 443dd5367e0cd9050ad39a6594c5be521271b4e9 introduced the
creation of separate debuginfo packages for kmod packages, and
commmit 387ae9536888419d7b101513e04e1c644e3218d6 moved the code
from the spec into the kmodtool script.

Recent versions of rpm (the issue was found on Fedora 27) extract
the debuginfo data from a copy of the original files having the
package version-release as a suffix. This broke the original
change since the regular expression passed to find-debuginfo.sh
no longer matched the name of the openafs.ko file. The file list
for the -debuginfo package remained empty, which caused rpmbuild
to fail.

Relax the regex to match the previous and current file names we
are after. It is possible but unlikely that .*openafs\.ko.* will
ever match any file not being a kernel module.

Change-Id: I57178ed2c593551ede6f4ab2679dd0360dc362cf
Reviewed-on: https://gerrit.openafs.org/13030
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

6 years agorx: connection aborts send serial zero when no conn available 32/12932/3
Jeffrey Altman [Fri, 23 Feb 2018 23:47:46 +0000]
rx: connection aborts send serial zero when no conn available

When no connection object is available, send serial number zero (0)
instead of one (1).  There is no harm in sending one (1) but it might
be confused as the first packet sent on the connection.  Multiple
connection aborts sent would all be sent with serial one (1).

Serial number zero (0) can be an indication to humans reading packet
traces that the sender has no knowledge of the connection.

Change-Id: I1951284f810170bd130e4f1d8ed93b903cd66659
Reviewed-on: https://gerrit.openafs.org/12932
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

6 years agorx: pass serial number to rxi_SendRawAbort 31/12931/3
Jeffrey Altman [Fri, 23 Feb 2018 23:26:24 +0000]
rx: pass serial number to rxi_SendRawAbort

The practice of stamping abort packets with the connection's next
serial number was altered by a0ae8f514519b73ba7f7653bb78b9fc5b6e228f8.

This change restores the prior behavior by passing a serial number
as a parameter to rxi_SendRawAbort() so that the serial number can
be obtained from the connection instead of hard coded as 1.

Change-Id: I0fb516b2c596e675fa4bc44598a697de81d36d83
Reviewed-on: https://gerrit.openafs.org/12931
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

6 years agoautoconf: add kernel module to the summary 05/13005/2
Michael Meffie [Mon, 9 Apr 2018 23:54:54 +0000]
autoconf: add kernel module to the summary

Add the kernel module to the list of optional build items in the
configure summary to indicate whether the kernel module build is
enabled.

Change-Id: I11d247ac66d8119910a90a0240b0ce5854449db4
Reviewed-on: https://gerrit.openafs.org/13005
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

6 years agoautoconf: remove uss from configure summary 04/13004/2
Michael Meffie [Mon, 9 Apr 2018 23:50:28 +0000]
autoconf: remove uss from configure summary

Commit 00a33b26d74aa067086ddc340efb82184715857f (uss: always build uss)
made the uss build unconditional. Remove it from the list of optional
items in the configure summary.

Change-Id: Ia249451c574974b4f0892c4d6d626c57404ea8ce
Reviewed-on: https://gerrit.openafs.org/13004
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>