Mark Vitale [Mon, 7 Apr 2014 22:56:26 +0000 (18:56 -0400)]
afs: maintain afs_users buckets in sorted order
Modify afs_GetUser() to insert a new unixuser into an afs_users
hash bucket in sorted order, by uid/PAG. This is in support of
other small optimizations in future commits.
Mark Vitale [Thu, 3 Apr 2014 20:37:51 +0000 (16:37 -0400)]
afs: only reset access caches for the matching cell
When an AFS user's tokens change (unlog, aklog) or expire,
afs_ResetAccessCache() is called to reset all the access caches
for that uid/PAG.
However, a user/PAG may have tokens for multiple cells, and they
may expire or be set/reset at different times. Therefore, it is
incorrect to assume that all access caches for a uid/PAG should
be discarded when only one cell's tokens have changed.
Modify afs_ResetAccessCache() to acccept a new argument 'cell',
and only reset the access caches for a uid/PAG if the vcache
resides in the specified cell. If the caller really wants to
reset all a user's access caches, specify cell=-1.
For cache managers that are running with multiple PAGs and multiple
cells, this should improve performance because 1) it avoids
scanning access caches chains for vcaches that are not part of the
current cell and 2) it avoids deleting access caches that may still
good, thus preventing unnecessary FetchStatus calls.
Michael Meffie [Tue, 3 Jun 2014 03:24:45 +0000 (23:24 -0400)]
linux: dont ignore kmod build errors
Errors from the linux kmod build are not propagated, since make is
run as the first command in a pipeline, and the shell returns the
exit code of the last command in the pipeline. Run the make command
in a subshell to detect errors, and exit afterwards. (This method
is more portable than bash specific pipeline processing options.)
Thanks to Mark Vitale for pointing out this build system defect
to me.
Change-Id: If3e204fe31dbdc9e7416d52fae897f792d27d678
Reviewed-on: http://gerrit.openafs.org/11186 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: D Brashear <shadow@your-file-system.com>
- That commit makes the RPC fail in situations where it did not
before. But even if we cannot calculate the checksum, we can still
return other information about the key, so this is undesirable.
- It masks the previous 'code' value, returned from stat(). The
return code of stat() is now effectively ignored, except for the
purposes of setting st_mtime, whereas previously a failure caused
the RPC to fail. This is a behavior change.
So, effectively revert c04de52da4e89e15b211b4a19a3d9bc4d612b209.
Explicitly cast the return value of ka_KeyCheckSum to void, to make it
clear that we are intentionally ignoring the return value, so
hopefully this will not be flagged as a warning by code analysis tools
such as coverity.
Change-Id: Iac745d7c88ed7c2d97660e6949caa63580eef6e2
Reviewed-on: http://gerrit.openafs.org/11194 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Perry Ruiter <pruiter@sinenomine.net> Reviewed-by: D Brashear <shadow@your-file-system.com>
Benjamin Kaduk [Thu, 5 Jun 2014 00:41:57 +0000 (20:41 -0400)]
rx: Do not try to cancel nonexistent events
Unconditionally cancelling the resend event and releasing the
reference it was supposed to have on the call, can cause the
call reference count to go negative.
In particular, the call chain when a new rx_call structure is
allocated would cause its reference count to become negative.
Behave similarly to all the other rxevent_Cancel calls touched
by 20034a815750beff262d49b37fba225c72dd0ab1, and only cancel the
event and drop a reference when the event is present on the call.
Stephan Wiesand [Mon, 2 Jun 2014 14:15:15 +0000 (16:15 +0200)]
fstrace: Don't read uninitialised data on other platforms either
Commit 908105fe8d51551e45692de4e145022138a0356c fixed an off-by-one
error potentially causing a buffer overread in CheckTypes, but only
in the IRIX/AIX version of the function. Apply the same fix to the
code for the other platforms.
Perry Ruiter [Tue, 27 May 2014 08:26:59 +0000 (01:26 -0700)]
config: Move AFS_LRALLOCSIZ to afs_args.h
AFS_LRALLOCSIZ is currently defined in afs/afs.h. Other memory
related definitions such as AFS_SMALLOCSIZ and AFS_MDALLOCSIZ
are defined in config/afs_args.h. Move AFS_LRALLOCSIZ to
config/afs_args.h for consistency.
Change-Id: Ie1e286c24be6a2def404a54355a2fa4b2c42330d
Reviewed-on: http://gerrit.openafs.org/11174 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com>
Marc Dionne [Tue, 29 Apr 2014 16:48:03 +0000 (12:48 -0400)]
libafs: Speed up afs_CheckTokenCache
On systems with a large number of PAGs and files in use, the
periodic daemon job that checks for expired credentials and
cleans up the axs cache can run for a very long time. This
can lead to kernel soft lockups and eventually hang processes
and file access because of unavailable locks.
Rework the scanning logic in afs_CheckTokenCache to make the
scanning more efficient in most real world cases. On a test
system accessing ~4000 files from processes in 1000 PAGs, this
has been observed to reduce the runtime of afs_CheckTokenCache
from a problematic ~70s down to about 0.7s.
Additionally, this changes the conditions in which an axscache is
discarded. uid+cell (rather than just uid) must now match, and
if no matching unixuser is found, it will also be discarded.
Adapted from code from Jeffrey Altman who provided the original
loop algorithm and code.
Change-Id: I65b275b4244b3b6ab65453623bb8729530a9e1a6
Reviewed-on: http://gerrit.openafs.org/11123 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com>
Ben Kaduk [Fri, 4 Jan 2013 21:16:04 +0000 (16:16 -0500)]
Dummy Makefile for rxgk
Include a libtool export symbol list for the shared library, which
only has the client RPC calls and the NewFooSecurityObject primitives
for now, since that's all that's stubbed out.
Also connect the rxgk directory up to be buildable from the root, but
nothing depends on it yet so it will not be built.
Looking ahead, build a libafsrpc_rxgk.la object.
Change-Id: I12ddefbdaa1ad4845649e3a32efdeaaa21b5e9b7
Reviewed-on: http://gerrit.openafs.org/10563 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Ben Kaduk [Fri, 6 Dec 2013 20:24:58 +0000 (15:24 -0500)]
Add rxgk boilerplate
Just the skeleton of what needs to be there. The actual import is split
over multiple commits, to make the reviewer's burden more manageable.
Error table, protocol description, and stubs for the security object
routines, with header to declare them.
The public header rxgk.h currently only contains a few typedefs and the
NewSecurityObject prototypes, and includes the RPC interface and com_err
code headers.
Change-Id: I7893f78119bb4aef12112cc1e51e1ec69de326c2
Reviewed-on: http://gerrit.openafs.org/10562 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Ben Kaduk [Fri, 6 Dec 2013 19:56:25 +0000 (14:56 -0500)]
Add some configure bits for GSS-API
rxgk will require gss_pseudo_random and might want a couple other
krb5-specific bits. We'll also need substvars to tell whether or
not we can try building these things.
Change-Id: Id18eb3f554605875696095eb40c25ec54df1f74b
Reviewed-on: http://gerrit.openafs.org/10561 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
Marc Dionne [Mon, 5 May 2014 17:33:10 +0000 (13:33 -0400)]
Linux: Drop PageReclaim AOP_WRITEPAGE_ACTIVATE case
The exit case here seems to have been added to avoid recursion into
the writeback code and eventual deadlock (see RT #15239). One issue
is that the PageReclaim check can trigger in code paths that don't
deal with the AOP_WRITEPAGE_ACTIVATE code correctly, leading to EIO
errors when multiple threads are doing large mmap writes and memory
pressure is sufficient to trigger reclaim.
The check could be improved to check wbc.for_reclaim which seems to
indicate more reliably when it is safe to return ACTIVATE, but given
that the CPageWrite flag already provides more targeted recursion
prevention, it seems safer to just drop this special case.
Note that many kernel filesystems used to have a similar check mainly
to prevent excessive stack usage, but as more recent kernels have
moved away from doing any writeback during direct reclaim this is a
case that should no longer occur. Partly as a result of this there
are very few users of AOP_WRITEPAGE_ACTIVATE left in the kernel,
which may be a motivation to find a better mechanism for OpenAFS
eventually.
This has been shown to help avoid EIO errors with multiple processes
doing intensive mmap writing.
Thanks to Yadav Yadavendra for identifying the issue and providing
extensive analysis and testing.
Michael Meffie [Tue, 18 Feb 2014 18:59:59 +0000 (13:59 -0500)]
volser: log message for cross-device link errors
Add a log entry to the volume server to help diagnose those pesky
'Invalid cross-link device' errors returned by vos, which occur when
a clone volume is located in a different partition than the parent
read-write volume, or when a read-only volume is on the incorrect
partition on the server.
With this change, a new log entry is added when the volume server
fails to create a clone or a read-write volume because a volume with
the target volume id already exists on a different partition. For a
clone volume, this would be a different partition than the
read-write volume. For a read-only volume, this would be a different
partition than indicated in the vldb.
Examples:
Volume foobar is on /vicepb, but foobar.backup is incorrectly on
partition /vicepa.
$ vos backup foobar
Failed to clone the volume 536870934
: Invalid cross-device link
VolserLog:
VCreateVolume: volume 536870936 for parent 536870934 found on /vicepa; unable to create volume on /vicepb.
1 Volser: Clone: Couldn't create new volume 536870936 for parent 536870934; clone aborted
...
The vldb indicates a read-only volume should be on /vicepa on a
remote site, but the actual volume is on /vicepb.
$ vos release xyzzy
Failed to create the ro volume: : Input/output error
The volume 536870921 could not be released to the following 1 sites:
mantis /vicepa
VOLSER: release could not be completed
...
VolserLog on mantis:
VCreateVolume: volume 536870922 for parent 536870921 found on /vicepb; unable to create volume on /vicepa.
...
Change-Id: Iaa471c46059d598a5095d59580e3b0b8ac6e1992
Reviewed-on: http://gerrit.openafs.org/10849 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Perry Ruiter <pruiter@sinenomine.net> Reviewed-by: D Brashear <shadow@your-file-system.com>
Marc Dionne [Wed, 28 May 2014 13:53:58 +0000 (09:53 -0400)]
vol: Fix gcc 4.9 warnings
gcc 4.9 complains here because the trailing 0 in these macros
has no effect, the value having already been set to NULL.
Just remove the offending 0s, nothing uses the return value
anyway, even if there were platforms where 0 != NULL.
Change-Id: Ic9a79d51419726c0c823a9228c21c13dea918dc8
Reviewed-on: http://gerrit.openafs.org/11176 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: D Brashear <shadow@your-file-system.com>
Stephan Wiesand [Fri, 30 May 2014 13:05:28 +0000 (15:05 +0200)]
libadmin: Remove redundant memset call
Commit bf78bf2c115659b78c34d3bc9d1934bcff21c8cc added initialisation
of the nbulkentries structure to 0, to avoid freeing garbage due to a
goto fail_... before the structure is initialised. As pointed out by
Andrew Deason, there already is an equivalent memset call later in the
code which is now redundant. Remove it.
Perry Ruiter [Fri, 30 May 2014 21:28:53 +0000 (14:28 -0700)]
audit: Delete va_copy kludge
When I developed fix c3d4c109305b2db8a63b754c1894ad37326dc340 I used
va_copy. I was nervous because it required C99, but I had no
problem with any of the buildbots, nor did any reviewer comment.
audit/audit.c contains a local hack to simulate va_copy in the
pre C99 days. There are no uses of va_copy in audit.c but
presumably at some point there was. Delete the local va_copy.
Change-Id: I5e30c7e3052aeffe56e366888c5a3db3a705fd00
Reviewed-on: http://gerrit.openafs.org/11184 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Perry Ruiter [Tue, 27 May 2014 08:16:26 +0000 (01:16 -0700)]
Delete several unused memory management constants
Change 412854593cf368006c18e6c0dc607a9ecd76a0e0, removed from
the code base the last usage of:
AFS_SALLOC_LOW_WATER (defined in afs/afs.h)
AFS_MALLOC_LOW_WATER (defined in config/afs_args.h)
AFS_MDALLOCSIZ (defined in config/afs_args.h)
This patch deletes these constants.
Change-Id: I1333aed508875e9b13dc3f36f3ff0d5eadfb2cfd
Reviewed-on: http://gerrit.openafs.org/11173 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Ben Kaduk [Wed, 8 May 2013 16:51:31 +0000 (12:51 -0400)]
Suppress nonliteral format string warning/error
Clang doesn't like a nonliteral format string, and some kernel
builds (e.g., freebsd) are done with -Werror. Use the standard
workaround for FreeBSD and UKERNEL builds by calling vsnprintf()
into a fixed buffer.
Remove the !defined(AFS_LINUX26_ENV) check, as it duplicates a
conditional around the entirety of osi_Panic().
Michael Meffie [Sun, 19 Jan 2014 22:04:08 +0000 (17:04 -0500)]
libafs: separate source and header compile_et rules
Use the new compile_et -emit flag to generate source and header
files separately to support parallel make.
Export afs_trace.h since it is required to build libafs. Before the
compile_et -emit flag was available, The afs_trace.h file was
generated as a side-effect of creating afszcm.cat.
Change-Id: I4e93691dda34ddc8600d6a818503e0c9e75e618a
Reviewed-on: http://gerrit.openafs.org/10729 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com>
Michael Meffie [Sun, 30 Mar 2014 09:53:16 +0000 (11:53 +0200)]
doxygen: make dox
Add an optional make target (make dox) and doxygen configuration to
generate doxygen output files. Auto-detect when the doxygen and
graphviz dot tools are available. When dot is present, configure
doxygen to create dependency graphs.
Since the graph generation can take a very long time, a new
configure option has been added to override the dot tool
auto-detection. To disable the graph generation (even if dot is
installed), run configure with the option: --without-dot
When graph generation is desired, but graphviz dot is not present in
the PATH, specify the path to dot with the configure option
--with-dot=<path-to-dot>.
The configure summary has been updated to show when doxygen document
and graph generation is configured.
Thank you Jason Edgecombe for providing the doxygen configuration
for OpenAFS.
Benjamin Kaduk [Fri, 25 Apr 2014 19:23:16 +0000 (15:23 -0400)]
rxgen: use unsigned type for max array length
Plain '0' is of type int, i.e., signed, and therefore so is '~0'.
The length of an XDR array is unsigned, so this constant should
be of an unsigned type.
Change-Id: I13f5f94b2f54bc0adcdf2ded1696b797b5205057
Reviewed-on: http://gerrit.openafs.org/11107 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: Perry Ruiter <pruiter@sinenomine.net> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Benjamin Kaduk [Fri, 25 Apr 2014 19:24:22 +0000 (15:24 -0400)]
Some rx type cleanup for signedness
The epoch, Cid, and security header/trailer sizes are all fundamentally
unsigned quantities. Change the types exposed in some API signatures
to match this reality, and also change the global variables for the
epoch and Cid to match. (Per-connection variables were already of
an unsigned type.)
Change-Id: I4a56736ef7d78028d1d0b980cda0b4c37d694388
Reviewed-on: http://gerrit.openafs.org/11106 Reviewed-by: Perry Ruiter <pruiter@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
This does not change the current (normal) behaviour, but allows
logrotation via "copy and truncate" as offered by logrotate.
Otherwise the processes will remember the offset of the last write
and a truncated file is filled with '\0' until the current offset.
The mrafsStyleLogs are untouched, since they can be rotated by a
kill -HUP and are deprecated anyway.
Change-Id: I09437aac63205fee3d97850507531e6833fed14f
Reviewed-on: http://gerrit.openafs.org/11092 Reviewed-by: Nathaniel Filardo <nwfilardo@gmail.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: D Brashear <shadow@your-file-system.com> Tested-by: D Brashear <shadow@your-file-system.com>
This is to be used by the (coming next) vos-foreach utility, but it seemed
sufficiently general and useful to break out into its own free-standing
component.
Stephan Wiesand [Wed, 7 May 2014 13:20:51 +0000 (15:20 +0200)]
redhat: Use the right path to depmod
As of Fedora 17 and RHEL 7, depmod has moved from /sbin to /usr/sbin.
The full path to depmod is used in package scripts and as a dependency.
This hasn't caused problems in most cases because on an installed
system a link /sbin -> /usr/sbin is present and during ordinary package
installations yum/rpm correctly then figure out that /sbin/depmod is
actually provided. But in other situations, the dependency check is not
that clever and (incorrectly) fails.
Add a macro to the spec defining the full path to depmod, use the macro
rather than plain /sbin/depmod throughout the spec, and also pass it to
kmodtool when required to generate the kmod package scripts and
requirements.
FIXES 131860
Change-Id: I1f2e4f7100d244477c2cb9087d2f48bbcea27fdc
Reviewed-on: http://gerrit.openafs.org/11128 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Perry Ruiter <pruiter@sinenomine.net> Reviewed-by: D Brashear <shadow@your-file-system.com>
Perry Ruiter [Sat, 22 Mar 2014 07:52:32 +0000 (00:52 -0700)]
afs: Define afs_warnall routine
In a Linux environment afs_warn and afs_warnuser both go to
the same spot, resulting in duplicated messages if both are
invoked back to back. Define a new function afs_warnall
for use when identical messages are directed to both warn
and warnuser. In a Linux environment it will do the right
thing and present only one copy of the message.
Change-Id: I1abdc63adc74fe5b08d3872d48698ec9dcc7a40c
Reviewed-on: http://gerrit.openafs.org/10943 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Perry Ruiter [Sat, 22 Mar 2014 06:31:21 +0000 (23:31 -0700)]
afs: restructure afs_warn and afs_warnuser
Restructure afs_warn.c to provide an afs_vwarn and afs_vwarnuser
that accepts a va_list rather than a variadic parameter
specification. afs_warn and afs_warnuser continue to be
variadic functions but now call afs_vwarn and afs_vwarnuser.
This is a preparatory change. A subsequent update will
further exploit afs_vwarn and afs_vwarnuser.
Change-Id: I8e740c4db311582bda6422e6600f1503dfbd0f5a
Reviewed-on: http://gerrit.openafs.org/10942 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Michael Meffie [Fri, 1 Feb 2013 22:46:45 +0000 (17:46 -0500)]
vos: vos release -force-reclone option
Add a new vos release option called -force-reclone to force the
reclone of the release clone and a release to all of the remote
sites, regardless of the state of the VLDB flags on the remote
sites, but does not force full volume dumps when distributing the
volume.
Provide an alias -f for -force for compatibility with the original
IBM vos, in case scripts were written to use the old '-f' option,
and for users with muscle memory.
Change-Id: I0ebebc5e8099299781e8da57579d91848bb2ad19
Reviewed-on: http://gerrit.openafs.org/9020 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com> Reviewed-by: D Brashear <shadow@your-file-system.com>
Gergely Risko [Wed, 19 Mar 2014 09:56:26 +0000 (10:56 +0100)]
RestrictedQuery feature
Make vlserver and volserver suppport a new command line parameter,
"-restricted_query admin". When this is on, the query RPCs that
are not needed for normal cache manager operations are restricted
to administrators listed in UserList. This is off by default.
Andrew Deason [Tue, 15 Apr 2014 17:30:19 +0000 (12:30 -0500)]
doc: Clarify some BosConfig.new text
It is not always clear to users whether BosConfig.new is noticed
during an automatic restart, or if it requires stopping and starting
the bosserver. Slightly reword the relevant text and add a small note
that a "general restart" does cause BosConfig.new to be noticed, so
this is explicitly clear.
Marc Dionne [Fri, 2 May 2014 18:10:06 +0000 (14:10 -0400)]
Linux: Prevent some fakestat data inconsistencies
When fakestat is enabled for a mount point, the parent vcache
entry is not the right place to find the DataVersion of
the target volume root directory. This can lead to data
inconsistency since the revalidation checks rely on the parent's
DataVersion to determine if a file entry is still valid. If the
file was replaced or deleted remotely, the only callback we
get is for the parent directory, and in that case the client
will think the file entry is still valid and give back stale
data to the user.
If fakestat is enabled and we have a mountpoint, always use
the parent vcache pointer returned by FakeStat before using it
to either store (in the lookup and create ops) or compare
(in the revalidate op) the DataVersion.
FIXES 131855
Change-Id: I03c05c1dab39e663b74635700e80ba70861b1c2e
Reviewed-on: http://gerrit.openafs.org/11118 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com>
Jeffrey Altman [Thu, 8 May 2014 13:06:07 +0000 (09:06 -0400)]
Windows: cm_Analyze retries vs CM_REQ_NORETRY (2)
Commit a1b5a1d42280753de13094006dcc130fede978a1 left out a critical
part of the patch. The check for "retry < 2" when determining whether
retries should be skipped due to CM_REQ_NORETRY.
Michael Meffie [Thu, 24 Apr 2014 17:40:06 +0000 (13:40 -0400)]
libafs: fix lock leak during shutdown
afs_getattr returns EIO when afs is in the process of shutting
down. Be sure to unlock the locks taken before returning.
The bozon lock leak has been present since IBM AFS.
Rod Widdowson [Sun, 4 May 2014 18:33:11 +0000 (14:33 -0400)]
Windows: Adjust Last Write time handling for -1
The "what date/time gets changed when and by whom" in Windows is badly
defined, but all filesystems support the semantic that if a date is set
using a specific file object (or the timestamp is set to the magic number
-1)
then other changes provoked by that file object will be ignored.
AFS redirector timestamp handling does not support this behavior.
For the LastWrite timestamp (other timestamps are pretty much advisory and
maintained on a best effort basis) the timestamp would be updated by a
write operation even after -1 is set via the file handle.
This patchset implements the -1 behavior for LastWrite. It also follows
the standard Windows practice of setting the LastWrite timestamp to be the
time of close of the handle that performed the write, not the time of the
write itself.
Finally, it should be noted that since RX*FS_StoreXXX operations update
the last write time on the server the client must restore the LastWrite
timestamp at handle close if -1 was specified.
The 'ComponentName' parameter to AFSSubstituteName() is a UNICODE_STRING
pointer. Its address should not be passed to AFSDbgTrace when used
in conjunction with a %wZ format.
Anders Kaseorg [Sun, 4 May 2014 09:30:25 +0000 (05:30 -0400)]
Fix buffer length validation in ktc_GetToken and knfs
The signed int tktLen is checked against a maximum size, then passed
as the unsigned size_t argument to memcpy. So we need to make sure it
isn’t negative.
This doesn’t appear to be exploitable: tktLen comes from the kernel,
which should have previously validated the length within the SETTOK
pioctl.
This bug was found with STACK <http://css.csail.mit.edu/stack/>.
Ken Dreyer [Wed, 6 Mar 2013 20:53:29 +0000 (13:53 -0700)]
doc: recommend cleanup steps in "vos convertROtoRW" man page
vos convertROtoRW leaves the older RW copy on the original fileserver,
although it is no longer in the VLDB. Provide the user with some hints
regarding clean up.
Change-Id: I5f6fcf7d5a516b59438d84e60f163a567d3a64fd
Reviewed-on: http://gerrit.openafs.org/9408 Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com> Tested-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Benjamin Kaduk [Mon, 7 Apr 2014 21:55:09 +0000 (17:55 -0400)]
vol: Fix build with separate objdir
The volscan-main and volinfo-main source files are in the source
tree, not the object tree; refer to the objects in the Makefile
as dependencies, so that they will be picked up properly. The
objects will be made just fine by the implicit .c.o rule.
Change-Id: Ieec4b32cfbe5d260e1560a08d4ed8162720f9222
Reviewed-on: http://gerrit.openafs.org/10988 Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Tested-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: Deny writes/truncation to files w RO attr
If the readonly file attribute is set on a file, refuse to process
writes, truncations or overwrites. The afsd_service will do so
and this can lead to data corruption.
At the same time, writes from the redirector to afsd_service must
not be denied because of the readonly attribute. That check was
performed during the CreateFile. Otherwise, a new file can be
created with the readonly attribute and then not be writable.
Jeffrey Altman [Wed, 12 Mar 2014 16:49:40 +0000 (12:49 -0400)]
Windows: NP Fail requests if AFSGetAuthenticationId fails
If during the processing of a network provider request the Logon
Session AuthenticationId is zero and the AFSGetAuthenticationId()
function is unable to obtain the current thread's AuthenticationId,
then fail the request.
The prior behavior of AFSSetBasicInfo() was to let the caller
set whatever it wanted as the new file attributes regardless of
the attributes that are supported by AFS. In doing so, reparse
point and directory attributes could be cleared, and other values
could be set even though they would be lost as soon as the
DirectoryCB object was garbage collected.
New behavior:
1. return STATUS_INVALID_PARAMETER if reparse point attribute
would be altered
2. return STATUS_INVALID_PARAMETER if directory attribute would
be altered.
Rod Widdowson [Mon, 14 Apr 2014 20:50:36 +0000 (16:50 -0400)]
Windows: Pin write position prior to defer
If we extend the file prior to defrring the write *and* the write
is set up FILE_WRITE_TO_END_OF_FILE then we have to convert the
FILE_WRITE_TO_END_OF_FILE to an absolute position since we have
already moved the FCB->Header.FileSize.
Rod Widdowson [Mon, 14 Apr 2014 20:45:37 +0000 (16:45 -0400)]
Windows: Do not defer Synchronous operations
There is nothing to be gained by posting a synchronous write.
Let it hang out in CcCopyWrite until there is enough memory
unless the write became synchronous after a deferral in which
case it can be deferred again.
Introduce bWait variable which is set to the result of
IoIsSynchronousWrite( Irp).
This change is being introduced after further analysis of the
FastFat example.
Andrew Deason [Thu, 30 Jan 2014 19:50:11 +0000 (13:50 -0600)]
Fix rx_EndCall error precedence
Callers of rx_EndCall in various parts of the code handle errors a bit
differently from each other. The correct way to use rx_EndCall is
almost always some form of:
code = rx_EndCall(call, code);
This will cause the call to abort with 'code' if the call is not
already aborted, and will return the abort code for the call (or 0 if
the call ended successfully). It is thus impossible for 'code' to
start out with a non-zero value in the code snippet above, and end up
with a value of 0 after the code snippet.
Most code follows this pattern, because this is how the
rxgen-generated client RPC wrappers are written. So for any non-split
Rx call, this is how the error precedence works.
However, some code (mostly for Rx split calls), needs to handle
calling rx_EndCall itself, and some code appears to think it is
possible for rx_EndCall to return 0 when we already had a non-zero
error. Such code tries to ensure that we don't ignore an error we
already got by doing something like this:
However, this is not correct. If a call gets killed with an abort code
partway through executing an RPC, and the client tries to end the RPC
with e.g. EndRXAFS_FetchData, the client will get an error code of
-451 (RXGEN_CC_UNMARSHAL). The actual error code is in the abort code
for the call, but with the above 'code2' snippet, we can easily return
an error of -451 instead, which will usually get interpreted as some
unknown network-related error.
This can manifest as a problem in the unix client, where if a
FetchData call fails due to, for example, an "idle dead" timeout, we
should result with an error code of RX_CALL_TIMEOUT. But because of
the above issue, we'll instead yield an error of -451, causing the
server to be marked down with the following message:
afs: Lost contact with file server ... (code -451) ...
So, fix most rx_EndCall callers to follow the 'code = rx_EndCall(call,
code);' pattern. Not all of the changes here are to "wrong" code, but
try to make all of the rx_EndCall call sites look more consistent.
There are a few exceptions to this pattern, which warrant some
variations:
- A few instances in src/WINNT/afsd/cm_dcache.c do seem to want to
record the original error before we ran rx_EndCall, instead of
seeing the rx abort code. We still return the rx_EndCall-returned
value to the caller, though.
- Any caller of RXAFS_FetchData* needs to read a 'length' raw from
the rx split stream. If this fails, we need to abort the call, but
we don't really have an error code to give to rx_EndCall. Failure
to read a length indicates that the server is not following
protocol properly, so give rx_EndCall RX_PROTOCOL_ERROR in these
instances. The call should already be aborted by this point, so
most of the time this code will be ignored; it will only make a
difference if the server tries to end the call successfully without
sending a length, which is indeed a protocol error.
- Some Rx clients can encounter a local error they don't want to send
to the server via an abort, so they just end the call successfully,
and only use the rx abort code if they don't already have a local
error. This is in a few places like src/butc/dump.c and
src/volser/vsprocs.c.
- Several places don't care what the error from rx_EndCall is, such
as various call sites in server-side code.
The behavior of the Windows client w.r.t rx_EndCall was changed a bit
into its current behavior in commit a50fa631cad6919d15721ac2c234ebbdda2b4031 (ticket 125018), which just
appears to be wrong. This was partially reverted by commit ae7ef5f5b963a5c8ce4110a7352e0010cb6cdbc1 (ticket 125351), but some of
the other call sites were unchanged. The Unix client appears to have
been doing this incorrectly for at least FetchData calls since OpenAFS
1.0.
To make it hopefully more clear that rx_EndCall cannot return 0 if
given a non-zero error code, add an assert to rx_EndCall that asserts
that fact.
Andrew Deason [Wed, 27 Mar 2013 23:12:41 +0000 (18:12 -0500)]
afs: Raise fake free space reporting
We report 'fake' values for free space, free file nodes, etc for the
'AFS' filesystem, since these values are not meaningful for AFS
itself. Currently we report about 9G of free space for most platforms,
and a few different values for a few others. Raise all of these to
2^32-1, so that trying to copy over 9G of data into AFS does not fail
for those applications that check the destination free space with
statfs(2). Note that one such application is KDE 4.8.x.
Consolidate all places that do this, and put the 'fake' value in one
place, AFS_VFS_FAKEFREE, along with the relevant comments.
Related issues reported by Lars Schimmer, Richard Brittain, and
others.
Change-Id: Ia15175da32744e11f62489c29bedfe1f5560d2b4
Reviewed-on: http://gerrit.openafs.org/9688 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Markus Koeberl <markus.koeberl@tugraz.at> Tested-by: Markus Koeberl <markus.koeberl@tugraz.at> Reviewed-by: D Brashear <shadow@your-file-system.com>
ptserver: Optionally restrict anonymous access to the ptserver
Currently, one could simply query from 0 to 'pts listmax' to determine
all the usernames in a cell. The -restrict_anonymous option will block
access to almost all of the unauthenticated RPC's. PR_NameToID is still
open since aklog still needs access to this RPC. An "attack" against
this RPC would have to scan a much larger key space to determine valid
usernames in a cell.
Change-Id: I7e475bc004f08d28d195c199804befa89f0ceb0c
Reviewed-on: http://gerrit.openafs.org/10951 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Gergely Risko <gergely@risko.hu> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: D Brashear <shadow@your-file-system.com>
Michael Meffie [Sat, 15 Feb 2014 17:03:43 +0000 (12:03 -0500)]
viced: fix get-statistics64 buffer overflow
Range check the statsVersion argument of the GetStatisitics64 RPC to
avoid a buffer overflow in the fileserver, or a huge memory allocation,
by a rogue client.
Andrew Deason [Fri, 21 Feb 2014 21:30:49 +0000 (15:30 -0600)]
rx: Avoid rxi_Delay on RXS_CheckResponse failure
Currently we rxi_Delay whenever RXS_CheckResponse fails for any
reason. This can result in disastrous performance degradations if a
client keeps sending "bad" responses, since rxi_Delay'ing here will
delay the Rx listener thread. This means we cannot receive any packets
for about a second, which can easily cause us to drop a lot of
incoming packets.
Instead, send the abort after 1 second by scheduling an event. This
will retain existing behavior from the point of view of the client
(it will get the abort after 1 second), but avoids hanging the Rx
listener thread.
Andrew Deason [Fri, 21 Feb 2014 21:26:35 +0000 (15:26 -0600)]
rx: Split out rxi_SendConnectionAbortLater
Take the functionality in rxi_SendConnectionAbort that schedules a
delayed abort, and split it out into a new function,
rxi_SendConnectionAbortLater. This allows callers an easy interface to
send such a delayed abort with their own delay.
This commit should incur no change in behavior; it is just code
reorganization.