Commit Graph

12918 Commits

Author SHA1 Message Date
Mark Vitale
eb1d2ef203 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>
2018-06-08 10:08:47 -04:00
Benjamin Kaduk
ef6a1e8118 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>
2018-06-08 09:13:15 -04:00
Benjamin Kaduk
1974eac772 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>
2018-06-08 09:09:26 -04:00
Benjamin Kaduk
4008f83ca8 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>
2018-06-08 09:06:02 -04:00
Benjamin Kaduk
cdd1f16f5e 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>
2018-06-08 09:03:56 -04:00
Benjamin Kaduk
bcce41bd99 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>
2018-06-08 09:01:48 -04:00
Mark Vitale
1dc9bb4e73 afs: fix broken volume callbacks (e.g. vos release)
Commit e99bfcfaa3 ('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>
2018-05-25 22:05:14 -04:00
Pat Riehecky
e71985bce5 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>
2018-05-25 21:47:40 -04:00
Pat Riehecky
9670937d5f 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>
2018-05-25 21:12:47 -04:00
Pat Riehecky
2b08d687b9 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>
2018-05-25 15:34:22 -04:00
Pat Riehecky
a411366f57 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>
2018-05-25 11:52:59 -04:00
Michael Meffie
759f29cfdf 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 50b6a116a1
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>
2018-05-25 10:04:50 -04:00
Michael Meffie
343234d221 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>
2018-05-25 09:55:35 -04:00
Mark Vitale
8225518cd0 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>
2018-05-25 09:09:16 -04:00
Benjamin Kaduk
849ddd4fde 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>
2018-05-25 07:54:09 -04:00
Benjamin Kaduk
554c38473d 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>
2018-05-25 07:53:24 -04:00
Benjamin Kaduk
b48fe6b57f 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>
2018-05-25 07:50:01 -04:00
Benjamin Kaduk
3be1de0e82 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>
2018-05-25 07:49:40 -04:00
Benjamin Kaduk
70c4922980 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>
2018-05-25 07:47:41 -04:00
Benjamin Kaduk
792dd44ac5 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>
2018-05-25 07:47:14 -04:00
Mark Vitale
845c8927ef 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>
2018-05-25 07:44:29 -04:00
Mark Vitale
e4c7321560 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>
2018-05-25 07:00:32 -04:00
Pat Riehecky
55013a1113 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>
2018-05-24 21:52:59 -04:00
Michael Meffie
850c7c50dc 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>
2018-05-19 10:15:20 -04:00
Michael Meffie
c0f2c26e92 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>
2018-05-19 10:15:10 -04:00
Andrew Deason
f1d389e803 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>
2018-05-18 21:54:16 -04:00
Andrew Deason
b8617f08d1 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>
2018-05-18 21:50:08 -04:00
Jeffrey Altman
f045de21a4 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
362d26c733 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
726e1e13ff.

Change-Id: I5ca1b08cb32d01843a1c6dee87d8ba1d560396c8
Reviewed-on: https://gerrit.openafs.org/13067
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-05-15 19:18:05 -04:00
Marcio Barbosa
3cc22a442e 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>
2018-05-15 18:48:40 -04:00
Marcio Barbosa
8e740aed77 afs: alloc openafs_lck_grp before osi_Init() on darwin
Commit a27bed59ca 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>
2018-05-15 18:40:47 -04:00
Marcio Barbosa
c16423ec4e rx: fix atomics on darwin
As described by commit b2a2142212, 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
74f837fd94 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>
2018-05-15 18:39:20 -04:00
Andrew Deason
96a4bee20d 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>
2018-05-11 11:21:15 -04:00
Andrew Deason
46d5695a38 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>
2018-05-11 10:40:17 -04:00
Andrew Deason
22e64df8e0 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>
2018-05-11 09:56:36 -04:00
Benjamin Kaduk
3ec0414f76 Use afs_DestroyReq in afs_PrefetchNoCache()
Since commit 76ad941902 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>
2018-05-11 09:02:40 -04:00
Andrew Deason
f6af4a155d 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>
2018-05-11 08:51:12 -04:00
Benjamin Kaduk
54e84a98f9 BSD: Work around panic in FlushVCache
Commit 64cc7f0ca7 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>
2018-05-08 08:34:50 -04:00
Stephan Wiesand
cfa74883e4 redhat: PACKAGE_VERSION macro no longer exists
Commit 0d0e7699c9 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>
2018-04-28 14:15:39 -04:00
Stephan Wiesand
076b73e06d redhat: Make separate debuginfo for kmods work with recent rpm
Commit 443dd5367e introduced the
creation of separate debuginfo packages for kmod packages, and
commmit 387ae95368 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>
2018-04-28 14:15:09 -04:00
Jeffrey Altman
09f31d4c21 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>
2018-04-13 21:39:53 -04:00
Jeffrey Altman
cacf2b6467 rx: pass serial number to rxi_SendRawAbort
The practice of stamping abort packets with the connection's next
serial number was altered by a0ae8f5145.

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>
2018-04-13 21:39:00 -04:00
Michael Meffie
3d3e7bc51a 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>
2018-04-11 00:24:58 -04:00
Michael Meffie
85e9db22b2 autoconf: remove uss from configure summary
Commit 00a33b26d7 (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>
2018-04-11 00:23:02 -04:00
Michael Meffie
833a81eeda autoconf: remove more linux 2.4 references
Remove old linux 2.2 and 2.4 references in the autoconf macros left over
from the linux 2.2 and 2.4 days.

Change-Id: Ie859d938fa1fee1d98a035b55e5e41120b66bc69
Reviewed-on: https://gerrit.openafs.org/13003
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-04-11 00:21:18 -04:00
Michael Meffie
28ea20d03f redhat: remove the openafs-kernel-version.sh script
Commit ec706b2153 (Remove Linux 2.4 compat
from RedHat packaging) removed the use of the script
openafs-kernel-version.sh, which was used in the linux 2.4 days to look
up the current kernel version.  Nowadays, we use the openafs-kmodtool
script to determine the kernel version.

Remove the unused openafs-kernel-version.sh script from the package
sources.

Change-Id: I6494812004f7b59c786ff670ff37c2fdc354f371
Reviewed-on: https://gerrit.openafs.org/12996
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-04-06 11:38:20 -04:00
Michael Meffie
9f0164f425 redhat: remove extra kernel version check
Commit a1c072ac56 (redhat: fix rpmbuild command
line option defaults) added logic to set the default value of the kernvers
variable when not specified as an rpmbuild command line option.

This default value is not necessary, since 'kmodtool verrel' already returns
the current running kernel version by default.  The result of 'kmodtool verrel'
sets the kverrel variable, which holds the value of the kernel version we are
building.  The kernvers variable is only used as an argument to 'kmodtool
verrel' and may be empty by default to indicate the current version should be
returned.

Remove the unnecessary setting of the default value of kernvers.

Also update the information banner to show the value of kverrel, which is the
actual version we are building, instead of kernvers, which is empty be default.

Change-Id: I45ded3b4f61ec60a64288b89c1d553df9fa7b867
Reviewed-on: https://gerrit.openafs.org/12995
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-04-06 09:32:23 -04:00
Ian Wienand
909d835810 Remove warning "find_preferred_connection: no connection and !create"
find_preferred_connection() is called with !create via
afs_ConnByHost->afs_ConnBySA to determine if there is a cached
connection available.  Don't warn, as it will next be called with the
create flag to create the connection anyway.

Change-Id: I02c2150a04ef20c54da793926fb402b946311f9a
Reviewed-on: https://gerrit.openafs.org/12964
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-04-05 21:05:19 -04:00
Stephan Wiesand
1545128319 FBSD: param.h consistency
Commit 88dc4d93f5 ("Add param.h
files for recent FreeBSD") introduced an inconsistency between
the i386 and amd64 param.h files for 11.1 and 12.0 regarding
the *_FBSD101_ENV #defines.

Citing Benjamin Kaduk: "Traditionally we have the param.h for
a FreeBSD N.0 release include the (N-1).Y values that existed
at the time of the N.0 release, and freeze that set of (N-1).Y
values for the lifetime of FreeBSD N.x, if that makes sense."

Given that FreeBSD 11.0 was released shortly after 10.3, and
12.0 is not yet released, consistently #define
*_FBSD10{1..3}_ENV for 11.1 and *_FBSD10{1..4}_ENV for 12.0

Change-Id: Ibb7e6c4caaab7aa97b32eeec7aa0bbe998bb57f7
Reviewed-on: https://gerrit.openafs.org/12990
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-04-05 20:37:59 -04:00
Marcio Barbosa
1a0d686765 autoconf: remove check for lorder
Currently, lorder is not being used. Remove the conditional that checks
if this binary exists.

Change-Id: I5ccee8b34f33ba0bda38a1d0478ff7a46f73f79c
Reviewed-on: https://gerrit.openafs.org/12981
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-03-30 10:05:14 -04:00
Stephan Wiesand
387ae95368 redhat: Create unique debuginfo packages for kmods
Commit 443dd5367e ("redhat:
separate debuginfo package for kmod rpm") introduced the
creation of separate debuginfo packages for the kmod packages.
As such, this is useful, but all debuginfo packages for a given
OpenAFS release ended up with the same name/version/release for
the kmod debuginfo package, no matter which kernel release or
variant the kmod was built for.

Move the additional black magic from the spec into the kmodtool
script where we have the means to do better: Use the same naming
and versioning conventions as for the kmod-openafs packages
themselves.

Change-Id: Ibcb34e4c8efde13d0600005772751d8aeb8154aa
Reviewed-on: https://gerrit.openafs.org/12977
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-03-30 09:54:35 -04:00