Andrew Deason [Tue, 9 Mar 2010 20:48:36 +0000 (14:48 -0600)]
vos: correct syncvldb -verbose server byte order
'vos syncvldb -verbose' outputs the before/after VLDB entries for
altered entries, but the 'after' output shows server addresses in NBO.
EnumerateEntry expects server IPs to be in NBO, so correct one location
where they were passed in HBO.
Andrew Deason [Wed, 10 Mar 2010 20:15:58 +0000 (14:15 -0600)]
vos: Avoid LWP stack overflow error on SIGINT
vsproc's method of longjmp'ing out of a signal handler can thoroughly
confuse LWP. At the very least, the information on our stack becomes
incorrect, since we're no longer using the stack supplied by LWP. At the
very least, we seem to (almost) always fail the sanity check checking
for stack overflow. To prevent the test from happening, NULL the stack
pointer before the longjmp so we can attempt recovery.
Andrew Deason [Wed, 10 Mar 2010 17:58:04 +0000 (11:58 -0600)]
vos: Use IOMGR_SoftSig for signals
When vsprocs tries to longjmp from the signal handler, use IOMGR_SoftSig
first, so sleeping processes are woken back up. Without this, IOMGR can
bail out since it finds no processes READY when we attempt to do
anything with RX.
Andrew Deason [Wed, 10 Mar 2010 00:07:18 +0000 (18:07 -0600)]
vos: Mark longjmp-used variables as 'volatile'
vsprocs tries to do error recovery by calling longjmp from a signal
handler. Although this is quite error-prone since we call a ton of
non-async-signal-safe functions, make it a bit more likely to work by
marking variables that are used after the longjmp as volatile. This
reduces how often (depending on the platform) these values will be
completely worthless after a longjmp since they were cached in a
register or similar.
Russ Allbery [Mon, 22 Mar 2010 22:00:39 +0000 (15:00 -0700)]
Fix strict aliasing problems or add -fno-strict-aliasing
Create a new CFLAGS_NOSTRICT Autoconf substitution variable which
is set to -fno-strict-aliasing if we're using gcc to compile. Add
@CFLAGS_NOSTRICT@ to the C compiler flags for source files that have
significant strict-aliasing issues.
Fix minor strict-aliasing issues elsewhere in the tree by using memcpy
to copy the data into a properly typed variable.
Andrew Deason [Mon, 15 Mar 2010 17:41:11 +0000 (12:41 -0500)]
Use AC_USE_SYSTEM_EXTENSIONS
Instead of defining various symbols like _XOPEN_SOURCE, _BSD_SOURCE, and
the like, just use autoconf's AC_USE_SYSTEM_EXTENSIONS to define all of
the appropriate symbols for us. Deal with some fallout by removing some
of the existing defines.
Simon Wilkinson [Thu, 18 Feb 2010 00:04:22 +0000 (00:04 +0000)]
XDR: Stop the madness
We currently attempt to align our XDR implementation with what may
be provided by the host system. This leads to a huge amount of parameter
fudging, and general pain and misfortune. However, the only place that
we still actually use the system XDR is for UKERNEL builds.
Change this so that we use our XDR everywhere. Fix all of our type and
function definitions so that they're standard. Remove the warning
inhibitions.
Russ Allbery [Mon, 22 Mar 2010 19:56:09 +0000 (12:56 -0700)]
Use sigset_t and sigfillset instead of memset
Rather than using an arbitrary array memset to ones as our signal
mask, use the POSIX sigfillset function and eliminate the static
variable. Fixes strict aliasing errors with --enable-checking and
gcc 4.4.3 on Linux x86.
Change-Id: Ic3e0499d03657d94f60808ed12e090dc62cce6fc
Reviewed-on: http://gerrit.openafs.org/1616 Tested-by: Russ Allbery <rra@stanford.edu> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com> Tested-by: Marc Dionne <marc.c.dionne@gmail.com> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
Russ Allbery [Mon, 22 Mar 2010 19:42:48 +0000 (12:42 -0700)]
Move non-executable stack assembly code to end of file
The non-executable stack annotation used for Linux works by adding
an additional section to the generated object. The annotation added
in 9bfd03d723a9cf17673f40513a7adde1d503bcbc was added to the beginning
of each assembly file. This caused build failures on Linux s390
because the remainder of the assembly code was then put in that
section, which was discarded during linking.
Add the annotation to the end of each assembly file instead, following
the instructions at:
Andrew Deason [Wed, 3 Feb 2010 19:02:23 +0000 (13:02 -0600)]
Create missing root directory when ORPH_ATTACH
When we are salvaging with ORPH_ATTACH, orphans are normally attached to
a volume's root directory. If the volume is missing a root directory,
however, nothing is attached, and the volume can appear empty or
unusable.
So, to make it possible to get a useful volume out of a volume that lost
(only) its root directory, create a new root dir, and attach orphans to
that root.
Simon Wilkinson [Wed, 17 Mar 2010 11:56:12 +0000 (11:56 +0000)]
Don't count root session keyrings against quota
AFS PAM modules can call setpag() as root, regardless of the UID
being authenticated. This leads to the session keyring being created
using roots quota - on some systems (RHEL5) this quota is both small,
and of a fixed size.
Modify our keyring allocation code so that when a keyring is created
by root, we don't do any quota checks.
Derrick Brashear [Thu, 18 Mar 2010 19:27:35 +0000 (15:27 -0400)]
macos fsevents hinting
add support for faking it. no exported interface exists, sadly.
currently does only authentication events, and is best-effort only,
however for people who get tokens after viewing directories in finder,
this is a drastic improvement.
Jeffrey Altman [Sat, 6 Mar 2010 22:32:57 +0000 (17:32 -0500)]
afsadminutil: translate krb5 error messages on Windows
util_AdminErrorCodeTranslate() is used to translate error
code messages within the libadmin library set and is used
by translate_et. This has in the past not translated
krb5 error codes.
This patchset conditionally adds support for using
krb5_get_error_message() or error_message() on the Windows
platform if KFW is installed. This is accomplished by
adding new functions to afsutil.lib:
initialize_krb5()
fetch_krb5_error_message()
which are used within util_AdminErrorCodeTranslate()
only if AFS_KRB5_ERROR_ENV is defined.
Support for Unix is not provided at the present time
because doing this "right" will lead to a dependence on
kerberos libraries from this library, which we might want
to avoid.
Andrew Deason [Fri, 19 Mar 2010 14:31:04 +0000 (09:31 -0500)]
volume_inline.h does not need sys/file.h
src/vol/volume_inline.h does not need sys/file.h; at one point, it was
using macros from sys/file.h for locking constants, but now we use the
lwp/lock.h constants. So, include that instead. Also, only include it
for DAFS, since we only use the constants in the DAFS case. Thanks,
Jeffrey Altman.
Dan Hyde [Tue, 2 Feb 2010 15:37:47 +0000 (10:37 -0500)]
VOL_LOCK needed when traversing DiskPartitionList
VLockPartition sets VOL_LOCK, opens (perhaps creating) the lock file
for a partition, and flock's it. VUnlockPartition, sets VOL_LOCK, and
closes the lock file fd.
VLockPartition is called from the salvager. Nothing ever calls
VUnlockPartition.
VPFullUnlock is called every 30 seconds, does NOT set VOL_LOCK, and
happily closes any lock file fd it finds, breaking any lock set with
flock.
Other routines use the VOL_LOCK when traversing DiskPartitionList.
Change-Id: I683547f574b1f760e72014f5d44ce3987f07b5df
Reviewed-on: http://gerrit.openafs.org/1213 Reviewed-by: Dan Hyde <drh@umich.edu> Tested-by: Dan Hyde <drh@umich.edu> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
Ben Kaduk [Wed, 17 Mar 2010 05:55:41 +0000 (01:55 -0400)]
Catch up with FBSD80's removal of thread argument to VFS calls
FreeBSD SVN rev 191990 removed the thread argument to
filesystem-dependent VFS calls. Curthread is always assumed.
There is a __FreeBSD_version bump that we could check if
we felt like being precise, but FBSD80_ENV is probably good enough.
Derrick Brashear [Mon, 15 Mar 2010 17:15:34 +0000 (13:15 -0400)]
aix vnode hold simplification
instead of special-casing aix's AFS_FAST_xxx *and* calling
VREFCOUNT_INC for AIX, make it all consistent; side effect, remove
now-superfluous AIX ifdef'd code
Derrick Brashear [Wed, 17 Mar 2010 17:23:30 +0000 (13:23 -0400)]
kill apsl afssettings and fstab
replace both
afssettings with something patterned from webdav's (BSD-licensed)
mount program with general plist reading code. the lists of
valid oid objects of course have to be the same. eject old
darwins. add the new one.
Andrew Deason [Fri, 19 Feb 2010 23:13:01 +0000 (17:13 -0600)]
DAFS: Replace partition locks with volume locks
In DAFS, replace uses of the VLockPartition_r partition-level locks with
the approprivate VLockVolume*NB volume-level locks (and sometimes
FSYNC_VerifyCheckout). This allows for greater parallelization of
volserver attachment / volume creation, for volume operations to occur
during salvages, and for multiple salvages on a single partition to
occur simultaneously.
More architectural details of volume-level locks can be found in the
changes to doc/arch/dafs-overview.txt.
Andrew Deason [Fri, 19 Feb 2010 23:02:08 +0000 (17:02 -0600)]
Add code for locking individual volumes on disk
This adds the necessary APIs and associated changes to lock (on disk) an
individual volume on a particular partition. Nothing yet calls these new
functions.
Ben Kaduk [Tue, 16 Mar 2010 21:07:04 +0000 (17:07 -0400)]
Avoid panic on shutdown with memcache and INVARIANTS
When running with memcache, the filesystem cache is not initialized,
so the file-local struct vnode *volumeVnode is never set to non-NULL.
However, shutdown_cache() unconditionally calls vrele(volumeVnode),
which triggers a KASSERT that the argument to vrele() is non-NULL.
For certain kernel configurations, this results in a panic.
Change this so that vrele() is only conditionally called if the
volumeVnode is non-NULL.
Ben Kaduk [Thu, 11 Mar 2010 05:13:12 +0000 (00:13 -0500)]
Allocate and free backing store for event mutices
Actually get memory for the event mutex. With this and a locking
tweak, afsd actually starts (with memcache; the UFS cache still
has some locking issues).
Note that struct mtx is small enough that we may want to just
include it inline in afs_event_t and avoid having to do a separate
allocation/free step. However, Derrick wants to merge the FBSD and
DARWIN versions of this file, so stick with the more compatible
version for now.
I find that without the memset(), mtx_init() will (sometimes?) complain
that the mutex is already initialized. The glock should ensure
serialization here, though, so that we only allocate and initialize
one mutex per event.
Also remove an unnecessary cast while here.
afs_MarinerLogFetch(), a void routine, attempts to return a value.
While gcc (amongst others) merely issues a warning about this, the
Sun Studio C compiler gets cranky (at least on x86) and treats it as
a hard error, thereby aborting the build. Since there actually is no
value to return, this update simply removes the attempt.
Andrew Deason [Tue, 9 Feb 2010 19:03:06 +0000 (13:03 -0600)]
vlserver: make rxinfo threadsafe
The vlserver has a function 'rxinfo' used for printing out information
about an RX call for logging purposes, which used a static string.
Change it to use a caller-passed buffer, so it is safe to use in
multiple threads.
Jeffrey Altman [Sat, 13 Mar 2010 16:47:51 +0000 (11:47 -0500)]
Windows: warnings removal for afskfw.c
Use StrSafe string manipulation functions in place of most
instances of strcpy, strcat, sprintf, etc. With the use
of StringCbCopy, StringCbCat, StringCbPrintf, etc. there
is no longer a need to manually assign a NUL to the end
of a C string buffer as was required with strncpy or
strncat.
There is one strcpy instance remaining due to the inability
to know what the length of the destination buffer. The API
needs to be altered to make the destlen available and that is
not an appropriate change for this patchset. A deprecated
warning is a reminder to revisit this in the future.
Several int to unsigned int type changes to avoid signed
vs unsigned warnings.
Shuffle the order of header files to avoid macro
redefinition warnings.
Jeffrey Altman [Sat, 6 Mar 2010 22:30:17 +0000 (17:30 -0500)]
Windows: afskfw - conditionalize use of krb5_get_error_message for KFW 3.1 and earlier
KFW 3.1 is supported by OpenAFS but does not contain krb5_get_error_message
or krb5_free_error_message. As a result it must be loaded at run-time
and conditionally used.
Jeffrey Altman [Sat, 6 Mar 2010 22:32:22 +0000 (17:32 -0500)]
Windows: netidmgr - conditionalize use of krb5_get_error_message for KFW 3.1 and earlier
KFW 3.1 is supported by OpenAFS but does not contain krb5_get_error_message
or krb5_free_error_message. As a result it must be loaded at run-time
and conditionally used.
Derrick Brashear [Thu, 11 Mar 2010 17:10:38 +0000 (12:10 -0500)]
macos dropbox fix for finder
sadly this can mean we lie and say delete will work when it will fail, but
finder looks for KAUTH_VNODE_DELETE_CHILD along with
KAUTH_VNODE_ADD_SUBDIRECTORY and KAUTH_VNODE_ADD_FILE, not as one-offs.
Andrew Deason [Wed, 10 Mar 2010 16:16:04 +0000 (10:16 -0600)]
Squash pthreaded vos warnings
Trying to build vos in src/tvolser can produce a warning, at least on
amd64_linux26, since we cast to an int of the wrong size in SendFile and
ReceiveFile. Use intptr_t like we do everywhere else instead.
Simon Wilkinson [Wed, 10 Mar 2010 15:40:50 +0000 (15:40 +0000)]
Don't always use the local cell for db clients
Commit d008089a79ef268bbca91d660a840f32cb416865 broke things so that
we were always trying to use the local cell, rather than the one specified
by the user. Fix this so that the command line cell is used, unles -localauth
is specified, which restores the existing behaviour.
Andrew Deason [Tue, 9 Mar 2010 17:43:42 +0000 (11:43 -0600)]
vldb_check: do not ntohl u_chars
vldb_check was ntohl'ing fields like serverNumber when reading in a VL
entry. Since this is a u_char, ntohl'ing will just always result in 0,
not the actual value. Remove the ntohls so we read in VL data correctly.
Andrew Deason [Fri, 19 Feb 2010 23:04:29 +0000 (17:04 -0600)]
Add FSYNC_VerifyCheckout
Add the function FSYNC_VerifyCheckout, which can be used to verify that
a previous checkout of a volume is still known by the fileserver, and
hasn't been forgotten about (by e.g. the fileserver restarting).
Andrew Deason [Tue, 23 Feb 2010 21:43:11 +0000 (15:43 -0600)]
Add DAFS documentation overview for developers
Add some developer documentation for DAFS. This isn't comprehensive or
extremely detailed, but is intended to provide a larger-picture overview
of some of the pieces of DAFS. More detailed docs are intended to exist
in source comments (doxygen and such), and should already be there for
the most part.
Andrew Deason [Fri, 19 Feb 2010 21:17:56 +0000 (15:17 -0600)]
Schedule all salvages via VScheduleSalvage_r
Change I03ecf6302436c35fec705cd6c84a40b7cdbf6f97 allowed non-fileserver
programs to schedule salvages via FSSYNC, making the FSSYNC call
directly in VRequestSalvage_r. This isn't as safe as making the call in
VScheduleSalvage_r (as is done when the fileserver schedules a salvage
via SALVSYNC), since we may not have relinquished all of our handles and
such for the volume by the time the salvager starts.
So instead, make this path a bit more like the fileserver, and make
non-fileserver programs actually make the FSSYNC call in
VScheduleSalvage_r. Consequently, make VScheduleSalvage_r conditionally
hit FSSYNC or SALVSYNC. Add a VCheckSalvage to attach2 failures, so
non-fileserver salvage requests actually get scheduled.
Also, reorganize the attach2 error handling a bit to make this a bit
easier.
Andrew Deason [Thu, 18 Feb 2010 20:22:39 +0000 (14:22 -0600)]
Add FSSYNC debug logging
Add logging for what FSSYNC commands are being received by the
fileserver, so it is possible to see what's going on with FSSYNC. Log at
level 125, since this isn't interesting unless you knows some FSSYNC
details, and it can get quite verbose.
Andrew Deason [Wed, 24 Feb 2010 15:47:03 +0000 (09:47 -0600)]
Move *SYNC string translation out of fssync-debug
Move the routines for translating ProgramType codes, and SYNC command
codes, response codes, etc out of fssync-debug, and into header files
anyone can use. These routines are useful especially for SYNC-related
debug or error logs.
Andrew Deason [Thu, 18 Feb 2010 18:21:45 +0000 (12:21 -0600)]
Do not rely on vol header for V*VolumeHandles_r
VCloseVolumeHandles_r and VReleaseVolumeHandles_r were using V_id to get
the id of the volume; just use vp->hashid so we can call these even if
we lack a header.
also report unload. in event of panic after module is unloaded (which
*shouldn't* happen but i have evidence it might) you can retcon where the
module was
Ben Kaduk [Tue, 9 Mar 2010 04:38:15 +0000 (23:38 -0500)]
Export prototypes for osi_fbsd_{alloc,free} for use in rx
Include prototypes for osi_fbsd_alloc() and osi_fbsd_free() in
osi_machdep.h, since afs_prototypes.h is not included when compiling
the rx code. afs_osi_Alloc_NoSleep is #defined to be osi_fbsd_free,
and is used in the rx code; if the prototype for the latter is not
included, then int is assumed for all parameters and return values,
which breaks the calling convention for 64-bit pointers.
Ben Kaduk [Sat, 6 Mar 2010 20:37:50 +0000 (15:37 -0500)]
Use correct types for UFS devices
For the FreeBSD 5.3 release, UFS (and everything else) took a
"dreaded s/dev_t/struct cdev */" change; we need to keep up
with this when comparing mountpoints' devices.
Ben Kaduk [Sat, 6 Mar 2010 20:20:18 +0000 (15:20 -0500)]
Use the correct API for msleep() in FBSD's afs_osi_TimedSleep()
msleep() does not take a struct timespec*, it takes its timeout
value as a multiple of the kernel's HZ parameter (tuneable at
startup). Since the afs_osi_TimedSleep interface is documented
to take a timeout in milliseconds, we must correct for the (sometimes)
different units (currently HZ defaults to 1000). We prefer
to multiply the timeout by HZ before dividing by 1000 so as to
not lose precision; overflow is assumed to be unlikely.
OpenBSD 4.7 (currently in beta) removes the (dummy) VREF() macro from the
system header files. For at least as far back as OpenBSD 3.6, all this
macro does is expand to a call to a system routine by the same name in
lower case. This patch therefore replaces the single OpenBSD use of
VREF() with a direct call to the routine to which it expanded.
Ben Kaduk [Sat, 6 Mar 2010 19:51:17 +0000 (14:51 -0500)]
Be type correct in osi_ThreadUnique() for FBSD
Formerly, in AFS_FBSD50_ENV, we used curproc for the ThreadUnique
value; however, curproc (#defined as curthread->td_proc) is a
struct proc *, not an actual pid. (As such, it suffers from
a 32/64-bit mismatch on 64-bit systems.) Use the correct value,
curproc->p_pid, instead.
Ben Kaduk [Mon, 1 Mar 2010 01:08:52 +0000 (20:08 -0500)]
FBSD module loads now
Actually declare the global afs_global_owner, in afs_osi.c.
This allows all symbols to resolve, so that the loader will
accept the module. There are still significant issues, though.
Jeffrey Altman [Fri, 5 Mar 2010 14:49:12 +0000 (09:49 -0500)]
Windows: use krb5_get_error_message instead of error_message
krb5_get_error_message() can return more descriptive errors
based upon the context in which the error occurred by extracting
the cached error message from the krb5_context. Since aklog
has a krb5_context, use that instead of error_message().
Use GetProcAddress to load krb5_get_error_message and
krb5_free_error_message function pointers because versions
of KFW prior to 3.2 do not export them.
Simon Wilkinson [Sat, 6 Mar 2010 00:13:06 +0000 (00:13 +0000)]
Linux: Make keyring destructor remove all tokens
The keyring destructor on Linux was only destroying the first
unixuser structure found for the PAG being destroyed. In environments
where each PAG contains tokens for multiple cells, this led to us
leaking unixuser structures, and eventually grinding to a hault due
to the length of the resulting hash chains (and some horrific
O(n-squared) performance in the PAG statistics code).
Add a utility function for the keyring destruction function to call
which will mark as deleted all unixuser structures for a particular
PAG, and use it.
Simon Wilkinson [Sat, 6 Mar 2010 11:21:06 +0000 (11:21 +0000)]
Linux: Fix builds on RHEL4
RHEL4 has a very old 2.6 kernel (2.6.9), which predates the start of
the Linux git tree. When I started using page_offset, I mistakenly assumed
that everything in the initial commit to that tree was available in all
2.6 versions we care about. That isn't the case, sadly.
Secondly, the new readpage code uses zero_user_segments, which has only
been available in the mainline kernel since 2.6.25 (RHEL5 appears to have
a backport)
Implement local wrappers for both of these functions when configure can't
find them in the kernel we're building for.
These functions have been created independently of the Linux tree.
page_offset is a copy of the code we used before we replaced it.
zero_user_segments() is a first-principles implementation
of the function (which zeros a pair of memory ranges within a single page)
Marc Dionne [Fri, 5 Mar 2010 22:54:42 +0000 (17:54 -0500)]
Linux: replace invalidate_inode_pages
This helper has been deprecated for a while, and gets removed
with 2.6.34.
Replace it with invalidate_remote_inode, which has been around for
all of 2.6's life, according to Chaskiel in RT #124377.
Jeffrey Altman [Fri, 5 Mar 2010 14:43:13 +0000 (09:43 -0500)]
Windows: Add krb5 error message functions to loadfuncs header
Add krb5_get_error_message and krb5_free_error_message
to loadfuncs-krb5.h so that they can be used in conjunction
with LoadFuncs to obtain function pointers when available.
Jeffrey Altman [Thu, 4 Mar 2010 21:23:36 +0000 (16:23 -0500)]
Windows: reset local mount point count during freelance re-initialization
When a re-initialization is taking place, be sure to reset
cm_noLocalMountPoints to 0 in case someone deletes the "Freelance"
registry key out from underneath the service.
Marc Dionne [Fri, 26 Feb 2010 22:00:58 +0000 (17:00 -0500)]
Remove duplicate make targets in tubik, cleanup dependencies
Eliminate a few duplicate targets in the tubik Makefile, and
clean up some dependencies that could cause the same source file
to be compiled by different threads simultaneously when building
in parallel. At least on my current gcc this would consistently
result in a gcc internal error.
The duplicate targets generate make warnings.
Derrick Brashear [Sat, 27 Feb 2010 20:30:06 +0000 (15:30 -0500)]
BOP_MOVE and userspace move EXDEV helper
turns background daemons into afsdb helper-like processes, which can
exit and do work. for macos, add BOP_MOVE and implement mv in afsd:
(macos EXDEV move is cp+rm, literally)
run cp + rm and pass the return back in. if it fails, just give
the client the error it had already
Claudio Bisegni [Mon, 1 Mar 2010 19:41:48 +0000 (20:41 +0100)]
OSXPreferencePane
checkAfsStatusForStartup method modification for search /afs volume for determinate if afs is on has been transfered into checkAfsStatus. checkAfsStatusForStartup method is used to check when afs start axitn system startup. Anyway these are only workaround we must use osx api or afs api to make this job.