Marc Dionne [Fri, 4 Feb 2011 01:51:06 +0000 (20:51 -0500)]
ubik: Introduce version lock
The "version" lock is a new lock that protects the database version
information. The goal is to allow the beacon thread to use the
protected values without blocking for an extended period of time,
which could occur if it was using the database lock.
Reading requires holding either lock, while writing requires holding
both locks.
The following values are protected:
ubik_epochTime
db->version
db->flags
db->tidCounter
db->writeTidCounter
Based on analysis and design work from Jeffrey Hutzelman.
Marc Dionne [Sun, 23 Jan 2011 03:17:14 +0000 (22:17 -0500)]
ubik: Introduce new vote lock
Introduce a new lock to protect ubik data related to voting.
Specifically, it protects the following globals:
ubik_lastYesTime
lastYesHost
lastYesClaim
lastYesState
lowestHost
lowestTime
syncHost
syncTime
ubik_dbVersion
ubik_dbTid
Variables are grouped along with the lock in a new structure.
Also introduce a few helper functions to safely deal with ubik_dbVersion:
uvote_eq_dbVersion: Return true if the passed version is equal to the
current ubik_dbVersion
uvote_set_dbVersion: Set ubik_dbVersion to a specified value
Marc Dionne [Sat, 22 Jan 2011 18:51:07 +0000 (13:51 -0500)]
ubik: Introduce new beacon lock
A new lock is introduced to protect beacon related data when
compiled with pthreads. A global structure is added containing
the lock itself and the global variables that it protects.
The lock also protects some values in the ubik_server structures:
lastVoteTime
lastBeaconSent
lastVote
up
beaconSinceDown
Based on some analysis and design work by Jeffrey Hutzelman
Simon Wilkinson [Sun, 3 Apr 2011 15:09:44 +0000 (16:09 +0100)]
Tidy up gettimeofday usage
The roken gettimeofday implementation doesn't return timezone
information. Audit the whole code to make sure that we don't rely on
this, and tidy up those places where we were passing an unused
timezone structure to the gettimeofday call.
Simon Wilkinson [Sat, 2 Apr 2011 12:43:15 +0000 (13:43 +0100)]
Remove NINTERFACE define
Whatever behaviour was controlled by the -DNINTERFACE define is long
gone from our code base (git log -SNINTERFACE can't find any references,
which suggests that its removal predates OpenAFS).
Simon Wilkinson [Sat, 2 Apr 2011 12:33:36 +0000 (13:33 +0100)]
Replace afs_ctime with strftime and friends
Replace our local afs_ctime() hack with strftime and localtime_r,
which roken can provide for us if necessary. This avoids the
compatibility problems inherent with ctime_r, and removes another bit
of platform compatibility goo from libutil.
Simon Wilkinson [Mon, 4 Apr 2011 10:02:17 +0000 (11:02 +0100)]
Irix: Supress some more warnings in kernel builds
Suppress the following warnings in kernel builds:
*) The function "blah" was declared but never referenced (1174)
*) The indicated trailing comma is non-standard (1201)
*) The parameter "blah" was never referenced (3201)
*) implicit conversion of a 64-bit integral type to a smaller
integral type (3968)
Andrew Deason [Fri, 1 Apr 2011 18:43:13 +0000 (13:43 -0500)]
afs: Retry unlock after afs_StoreAllSegments
HandleFlock calls afs_StoreAllSegments when unlocking an exclusive
flock lock. This can drop the write lock on avc, so we must
effectively retry the entire lock operation again, since the world may
have changed while we were waiting to reacquire the lock on avc. So,
retry once all of the lock checks up to that point, to ensure that a
lock on the file actually still exists.
Simon Wilkinson [Sun, 3 Apr 2011 09:23:56 +0000 (10:23 +0100)]
roken: Add env functions to configure checks
Add the putenv, setenv and unsetenv functions to the list of
functions that configure checks for. This avoids the roken header
redefining them to rk_*, which we're then not providing an
implementation of.
Marc Dionne [Sat, 2 Apr 2011 12:40:15 +0000 (08:40 -0400)]
fsprobe: call RXAFS_GetTime directly
Call RXAFS_GetTime directly instead of using ubik_Call which is
not prototyped and has logic that we don't need/want here since
we're targeting a specific server.
Simon Wilkinson [Fri, 1 Apr 2011 15:37:32 +0000 (16:37 +0100)]
Linux: Fix USE_UCONTEXT detection
On Linux, afs/param.h determines whether to use the ucontext()
function based on the glibc version. However, the glibc version
macros aren't available until a C library header has been included.
There have been a couple of attempts to fix this. The first included
afs_sysnames.h before the C library check, but this wasn't sufficient
to pull in a header for all builds. The second included stdio.h before
including afs/param.h in process.c.
Whilst the second approach works, it has the drawback that it breaks
our convention that afsconfig.h and afs/param.h must always be the first
includes in a file. More seriously, it means that the behaviour of
afs/param.h is different depending on where it appears in the include
order - which is especially dangerous for 3rd party user.
So, this patch tries to resolve all of this by explicitly including
features.h before doing the glibc version checks. The only danger I
can see here is that Linux platforms without glibc may lack a
features.h, but I suspect we have trouble building on such platforms
in any case.
Andrew Deason [Fri, 1 Apr 2011 21:43:24 +0000 (16:43 -0500)]
afs: Avoid memory leak on recursive write flock
When a process requests an exclusive lock on a file on which it
already holds an exclusive lock, we basically form a no-op. However,
HandleFlock was allocating a new SimpleLocks and attaching it to
avc->slocks, without freeing the old SimpleLocks structure.
Since we don't need to do anything if we already hold an exclusive
lock, just break out of the loop right away when we detect that
scenario. Thus we avoid adding a new structure to avc->slocks, and we
avoid a memory leak.
This patch is intended to bring libafscp into accordance with the
current OpenAFS coding standards while also fixing a few small
issues. Apologies in advance for the numerous whitespace changes.
Marc Dionne [Wed, 30 Mar 2011 22:32:04 +0000 (18:32 -0400)]
Linux: Fix fallout from path_lookup commit
Fix a few issues with the recent commit to deal withg the removal
of path_lookup, spotted on RHEL 5:
- the configure tests needs fs.h to be included before namei.h, to
get the definition of struct inode
- we need to avoid the use of struct path unless its needed; on
older kernels the structure doesn't exist
Ben Kaduk [Wed, 30 Mar 2011 02:26:50 +0000 (22:26 -0400)]
Unbreak make dest for FBSD
It turns out that we do need an afs.rc.fbsd that is set up for
transarc paths in this directory. To get it to work properly
will require the user to symlink to it from a dir that gets
checked by rcorder, but them's the breaks.
OpenBSD: Complete implementation of afs_osi_TimedSleep
The OpenBSD version of afs_osi_TimedSleep() is missing the required
afs_event structure and afs_getevent routine. This update adds them
(by borrowing a copy of the code from the FreeBSD implementation).
Andrew Deason [Tue, 29 Mar 2011 17:28:46 +0000 (12:28 -0500)]
vol: Add timeouts to SYNC server select() calls
Normally *SYNC server processes wait indefinitely for activity to
occur on one of the SYNC sockets. On some Linux kernels, there exists
a race condition where data can come in on a socket, but the select()
call continues to wait. To ensure that we do not hang forever in such
a scenario, add a timeout to the select() call, which will ensure we
notice the new data within 10 seconds. Raise the timeout on non-Linux
to reduce impact elsewhere.
The Linux kernel bug is tracked in
<https://bugzilla.redhat.com/show_bug.cgi?id=494404>, though that bug
report may not represent all affected kernels.
Andrew Deason [Tue, 29 Mar 2011 18:04:48 +0000 (13:04 -0500)]
Always set LIB_roken when we find libroken
If we found an external libroken when configuring, we were not setting
LIB_roken if --with-roken=DIR was not specified. Set LIB_roken when we
find a libroken without --with-roken=DIR.
rx: always use/protect the xdr routines in the kernel
This clears up some warnings about duplicate symbols with Solaris 11
since the Solaris kernel already has these routines. Since we never
use stock kernel version of the xdr routines perhaps we should always
use/protect our version of the symbols.
Simon Wilkinson [Mon, 28 Mar 2011 09:23:22 +0000 (10:23 +0100)]
fssync: Rename state
The structure 'state' in fssync-debug conflicts with a structure
of the same name in AIX's resolv.h header. Renaming the structure here
to fssync_state to avoid the conflict.
Simon Wilkinson [Fri, 25 Mar 2011 00:37:52 +0000 (00:37 +0000)]
volser: More renaming of putshort and putint32
Commit 2d6bc153689f14f8690878b15d9fb711a56b0546 renamed the putshort
and putint32 macros in dumpstuff.c to avoid conflicts with macros
that are defined in resolv.h. However, an almost identical copy of
that code also exists in vol-dump.c
Simon Wilkinson [Thu, 24 Mar 2011 15:36:49 +0000 (15:36 +0000)]
afs_snprintf is dead, long live rk_snprintf
We were shipping our own implementation of snprintf and friends, as
afs_snprintf. Now that we're using roken everywhere, we can make use
of roken's rk_snprintf, and no longer need to ship our own.
As Window's snprintf isn't C99 compliant, roken always uses its own
on this platform. The effect of this is that we can no longer use
AFS_UINT64_FMT and AFS_INT64_FMT for snprintf calls (and the Log
functions that call them). Instead, we need to always use the
Unix format specifiers when calling these functions.
Simon Wilkinson [Sun, 27 Mar 2011 20:06:27 +0000 (21:06 +0100)]
Windows: Don't use %I for IP addresses
%I isn't supported by the roken printf functions. In preparation
for switching over to them, replace our use of asprintf to convert
IP addresses to strings with the afs_inet_ntoa_r function.
Marc Dionne [Sun, 27 Mar 2011 15:20:17 +0000 (11:20 -0400)]
Linux: 2.6.39: deal with BKL removal
For 2.6 kernels the OpenAFS code is already BKL free, but the
corresponding header file smp_lock.h is still included in various
places. This header no longer exists, so remove all occurrences
outside of LINUX24.
Simon Wilkinson [Fri, 25 Mar 2011 17:34:51 +0000 (17:34 +0000)]
crypto: Fixes for recent Heimdal changes
The last Heimdal import changed the name of a number of structures
so that they are private to the krb5 code. Mirror this by changing our
prototypes to match the new names.
This solves the key_type problem that we previously fixed by #defining
key_type to hc_key_type, so remove that define.
Ben Kaduk [Fri, 17 Dec 2010 06:16:30 +0000 (01:16 -0500)]
new files for FreeBSD packaging at 1.6.0pre3
Packaging for use with FreeBSD's Ports Collection.
The directory layout is flattened, and a couple of files that do not
make sense here are not included.
The afsd rc script lives in packaging/ as it is not runnable in
its committed form, it requires variable substitution that occurs
at install-time from the Ports Collection.
Ben Kaduk [Mon, 22 Nov 2010 04:32:37 +0000 (23:32 -0500)]
Remove outdated rc file for afsd on FBSD
The semantics of rc scripts have changed drastically since this
was written. It will need to be rewritten from scratch; the
new version will live in src/packaging/FreeBSD as afsd.in, as it
is included with the port packaging in that form.
Andrew Deason [Fri, 25 Mar 2011 20:54:01 +0000 (15:54 -0500)]
viced: REALLYCLOSE origfdP after CoW
In StoreData_RXStyle, we save a pointer to the original FdHandle_t if
we need to CopyOnWrite the target vnode, for the purposes of possibly
copying additional data later on.
After the CopyOnWrite call, this points to an inode that is not in the
current volume, and is thus less likely to be accessed. In CopyOnWrite
itself, the original file handle is FDH_REALLYCLOSE'd because of this,
so the handle does not remain in the cache. Do the same in
StoreData_RXStyle, so origfdP is always FDH_REALLYCLOSE'd after we
have called CopyOnWrite.
The only difference between FDH_CLOSE and FDH_REALLYCLOSE has to do
with ihandle cache behavior. FDH_REALLYCLOSE just indicates that the
reference we are closing is not likely to be used by other code, and
should be kicked out of the cache immediately (thus closing the file
descriptor). So, if there is another reference to that FdHandle_t, and
it issues an FDH_CLOSE, it thinks that the reference is likely to be
used again soon, and so the handle should not be kicked out of the
cache. Thus, the behavior before a50f4c8d was already correct.