Simon Wilkinson [Sun, 24 Feb 2013 10:43:52 +0000 (10:43 +0000)]
budb: Fail if afsconf_GetExtendedCellInfo does
Rather than silently ignoring the failure of
afsconf_GetExtendedCellInfo, and then using garbage cell
configuration, just fail to start if afsconf can't parse the
config directory.
Jeffrey Altman [Mon, 25 Feb 2013 05:17:46 +0000 (00:17 -0500)]
Windows: Test NameArrayReferenceCount before deletion
In commit c753d398f2005c886932f20b49af15efc489a829 the
AFSDirectoryCB.DirOpenReferenceCount was split and the
NameArrayReferenceCount field was added. However, it failed to modify all
of the DirOpenReferenceCount checks prior to calling AFSDeleteDirEntry()
to include a check on the NameArrayReferenceCount. This patchset corrects
that oversight.
Simon Wilkinson [Tue, 19 Feb 2013 15:25:12 +0000 (15:25 +0000)]
kauth: realm can't be NULL when calling CellToRealm
Despite what the static analyzer thinks, ka_CellToRealm can't be
called with a NULL realm. Just add an assert to close down that
code path, and stop it from producing an error.
Simon Wilkinson [Fri, 22 Feb 2013 10:23:43 +0000 (10:23 +0000)]
viced: Allow GetCapabilities to return an error
At the moment, the GetCapabilities RPC handler ignors errors from
CallPreamble or CallPostamble. Instead of silently swallowing these,
and potentially reutnring a bogus capabilities structure, make
it possible for the RPC to return failure to the caller.
Simon Wilkinson [Fri, 22 Feb 2013 10:16:10 +0000 (10:16 +0000)]
viced: Don't store rc from IH_DEC on error path
If CopyOnWrite has already failed, and is taking the volume offline
for salvage we can't (and don't) do anything with further errors from
IH_DEC. Instead of assigning these to 'rc', just ignore them.
Simon Wilkinson [Fri, 22 Feb 2013 10:30:56 +0000 (10:30 +0000)]
afsmonitor: Allow CBSTATS collection to work
The switch which selects the collection number was missing a
'break', so selecting the CBSTATS collection would always fall
through to the default, error, case.
Simon Wilkinson [Thu, 21 Feb 2013 20:36:19 +0000 (20:36 +0000)]
libadmin: Fix a lot of dead assignments in vsprocs
Tidy up a lot of places where we initialise a variable, then
immediately assign a proper value to it, or store a return value
that we don't actually care about.
Simon Wilkinson [Wed, 20 Feb 2013 11:17:41 +0000 (11:17 +0000)]
volser: Don't assign code when we don't care
When we're cleaning up temporary volumes, we don't care whether
it succeeds or not. Don't assign code to the results of these
volume deletions, only to then discard it.
Simon Wilkinson [Tue, 19 Feb 2013 17:22:08 +0000 (17:22 +0000)]
fs: Free parent_dir later in lsmount and flushmount
If lsmount or flushmount encounter an error, then they may include
the contents of parent_dir in their error message. However, in both
cases, this was freed a couple of lines earlier.
Just move the free() later, so that the contents of this variable
are still available.
Simon Wilkinson [Tue, 19 Feb 2013 17:15:42 +0000 (17:15 +0000)]
fstrace: Avoid accessing icl log after zapping it
The for loop in icl_EnumerateLogs looks up the next pointer in the
current entry after zapping it. Depending on reference counts, this
may result in us looking up freed memory.
Take a copy of the next point before zapping the current entry, just
in case.
Simon Wilkinson [Fri, 22 Feb 2013 16:54:17 +0000 (16:54 +0000)]
Unix CM: Fix byte accounting for storebehind
In the current version of CacheStoreDCaches, the stored variable is
maintained within the for loop that iterates over the chunk list. This
means that it is reset to 0 each time we handle a new chunk.
However, this means that our progress is no longer accurately tracked,
as (bytes - stored) no longer gives the number of bytes which remain to
be transfered. In fact, as stored is zeroed with each loop iteration,
(bytes - stored) == bytes. This means that store behind is no longer
activated according to the users settings.
Prior to commit 334114ac58b0039ae90d7e29fa2f019fe068bd79, the
stored variable was maintained within the outer, function, scope.
Just move it back there to restore the previous behaviour.
Simon Wilkinson [Thu, 21 Feb 2013 22:15:11 +0000 (22:15 +0000)]
Unix CM: Don't zero args on dcache failure
Even if allocating the dcache fails, there's no point zeroing the
parameters to the allocation function, as those changes aren't
visible outside of that function.
Jeffrey Altman [Sun, 16 Dec 2012 17:42:17 +0000 (12:42 -0500)]
Windows: Direct IO Support for Service
This patchset implements and enables by default the new
Direct IO pathway between the AFS redirector and the afsd_service.exe.
When Direct IO is enabled all reads and writes are performed by the
AFS redirector locking memory allocated by the kernel and mapping it into
the service's memory address space.
The service supports cache bypass in this mode when the
AFS_REQUEST_FLAG_CACHE_BYPASS flag is set in the request from the
redirector. When cache bypass is active, the AFSCache file is ignored and
data is either directly fetched from or stored to the file server. Cache
bypass is enabled by IIS and other applications that request no
intermediate buffering when opening file handles. This is often done
because the application implements its own data caching. All cache bypass
store operations are synchronous.
When cache bypass is not enabled, the memory region provided by the AFS
redirector is either used to populate the cm_buf_t objects or is populated
by them. When cache bypass is not enabled, one outstanding store
operation can be in flight asynchronously to improve performance.
Direct IO is enabled by default and can be disabled by creating the
registry value.
Peter Scott [Fri, 25 Jan 2013 05:46:37 +0000 (00:46 -0500)]
Windows: Direct IO for AFS Redirector
Implement a new IO processing model in which extents are not passed between
afsredirlib.sys and afsd_service.exe. Instead the AFSCache file is
maintained exclusively by the service and the redirector locks kernel
memory, maps it into the service's address space, and permits the service
to manage all IO directly.
This interface adds an AFS Cache Bypass option to the AFS Redirector which
is activated when the file handle has been opened with the no intermediate
buffering option.
This patchset implements the kernel interface. A subsequent
patchset will implement the service component.
Assisted by Jeffrey Altman <jaltman@your-file-system.com>
Change-Id: I25a4764db060b3b3f2b0de4006479dd3a220c6eb
Reviewed-on: http://gerrit.openafs.org/9210 Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Fri, 25 Jan 2013 07:21:27 +0000 (02:21 -0500)]
Windows: Add flag BUF_GET_FLAG_BUFCREATE_LOCKED
Modify the buf_Get() and buf_GetNewLocked() interfaces to
permit the cm_scache.bufCreateLocked lock to be held prior to
calling to buf_Get(). Holding the cm_scache.bufCreateLocked lock
before the buf_Get() call prevents a race with another thread
that attempts to set the file size.
Peter Scott [Fri, 15 Feb 2013 13:44:06 +0000 (08:44 -0500)]
Windows: Permit direct to service non-wildcard lookups
The AFS redirector has required that directories be fully enumerated
when the directory object is opened. This is a very expensive
operation involving large numbers of file server RPC round trips for
directories with tens of thousands of objects and those containing
symlinks.
This patchset delays directory enumeration for the last component
in a path until such time as dirctory data is requested by the
application. If the request is for a non-wildcard pattern, the
service will be asked to provide the details for just the one required
object.
Delaying the directory enumeration improves performance for
GetFileAttributes[Ex], GetDiskFreeSpace[Ex], GetVolumeInformation,
and GetNamedSecurityInfo Win32 API calls. In those cases it is
no longer necessary to enumerate the target directory at all.
Change-Id: I7ef2fbafff925697d8b40e56837ef53bfcc78542
Reviewed-on: http://gerrit.openafs.org/9118 Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Tue, 19 Feb 2013 04:11:27 +0000 (23:11 -0500)]
Windows: EvalByName pass LastComponent flag
Add AFS_REQUEST_FLAG_LAST_COMPONENT flag for use with
AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME requests to the service.
When set the service will perform cm_Lookup calls without the
CM_FLAG_CHECKPATH flag set.
Change-Id: I47ec2fb8b1e2699f2d87a6625b1db549ecb4e03d
Reviewed-on: http://gerrit.openafs.org/9133 Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Tue, 19 Feb 2013 02:26:23 +0000 (21:26 -0500)]
Windows: EvaluateByName support case-insensitive lookups
Directory lookups in AFS should favor case-sensivite matches
but permit case-insensitive matches otherwise. The service
should not follow mount points. The redirector exposes mount
points as junctions.
Rod Widdowson [Tue, 19 Feb 2013 16:12:26 +0000 (16:12 +0000)]
Windows: Move work item queues over to the Control Device
Currently, when the library is unloaded it stops all worker
threands and then evaporates the work item queues. Thus
any work items which are pending will disappear.
Whilst it is OK that the threads going away, any work items need to
remain queued so that when the library is restarted the work
can continue. This checkin does this by moving the work item
queues and their synchronization primitives into the FS maintained
Control Device Object Extension. The list of worker threads
remains in the Library Device Object Extension.
Change-Id: If5c7cd3bdfea1a368c8df69649e627bac3a9585f
Reviewed-on: http://gerrit.openafs.org/9139 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Rod Widdowson [Mon, 18 Feb 2013 15:33:29 +0000 (10:33 -0500)]
Windows: Call CcDeferWrite rather than loop
If we are about to write into the cache and we do not have enough
memory we call CcDeferWrite and return STATUS_PENDING. This allows
the cache to call us back when there is memory.
The write is performed on the IO queue which is shared wth paging
writes. However this does not cause paging writes to block in a
memory shortage situation since the request will either be deferred
again (releasing a thread to service a paging write) or will complete
quickly. Further we allocate all our resources upfront so we fail
fast and in the appropriate place.
Change-Id: I4efbc14a97d3b34236643973f1f8f85c7ea194a6
Reviewed-on: http://gerrit.openafs.org/9127 Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
We never get non cached and yet paging IO. Even if we did it would
be inappropriate to call CcCanIWrite. Therefore, collapse two if
statements into one.
Change-Id: I95c9030836e4f7dc4f7867a8b8b09b97bf57b429
Reviewed-on: http://gerrit.openafs.org/9125 Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Simon Wilkinson [Tue, 19 Feb 2013 17:09:15 +0000 (17:09 +0000)]
afsio: Don't leak memory on GetVenusFidBy* failure
The GetVenusFid functions all allocate the fid structure immediately
upon entry to the function. When we return with an error, that structure
is never freed.
Update the call sites so that we don't leak this memory.
Simon Wilkinson [Tue, 19 Feb 2013 17:53:11 +0000 (17:53 +0000)]
libafscp: Actually return callback from FindCallback
Fix FindCallback so that it actually returns the callback that it
found. This requires changing the function prototype so that the
third parameter is passed by reference, and updating the single
call site.
Simon Wilkinson [Tue, 19 Feb 2013 17:30:14 +0000 (17:30 +0000)]
libafscp: Don't free bogus ptr in ResolvPathFromVol
afscp_ResolvPathFromVol makes a copy of the path passed to it using
strdup. It then iterates across that, removing initial '/' characters.
However, this iteration means that 'p' no longer points to the start
of the allocated memory - when we free 'p', we may actually be freeing
an offset into the block, which will make malloc unhappy.
Make a copy of the result from strdup, and use that to free the block.
Simon Wilkinson [Tue, 19 Feb 2013 15:46:52 +0000 (15:46 +0000)]
ptserver: Tidy malloc handling in readpwd
Tidy up the malloc handling in readpwd, so that we don't leak memory
if the user specifies multiple -c arguments. Also avoid assuming that
free(NULL) will always work.
Simon Wilkinson [Tue, 19 Feb 2013 14:44:14 +0000 (14:44 +0000)]
vos: aserver is private
The server specified on the command line is used directly to
initialise the attributes structure. Move the variable so it's
local to the block which uses it, and remove the function-wide
initialiser.
Simon Wilkinson [Tue, 12 Feb 2013 12:59:08 +0000 (12:59 +0000)]
auth: Avoid double free in key parsing
There was an error path whilst reading an extended key file which could
result in a key being freed using free(key), and then freed again
through the afsconf_typedKey_put() mechanism. Remove this double free.
Simon Wilkinson [Fri, 15 Feb 2013 16:35:08 +0000 (16:35 +0000)]
rxgen: Remove pointless assignment
The value we assign to defp is never used (it's almost immediately
overwritten), and it is guaranteed to be the same as the existing
value. So, just remove the assignment.
Simon Wilkinson [Fri, 15 Feb 2013 16:05:33 +0000 (16:05 +0000)]
rxgen: Fix NULL pointer dereference
Avoid a NULL pointer dereference if strchr doesn't find any occurence
of '*' in the string. Whilst we handle the not found case when inserting
a mid string terminator, we don't handle it when restoring the string to
its previous value.
Simon Wilkinson [Fri, 15 Feb 2013 11:55:37 +0000 (11:55 +0000)]
Fix incorrect sizeof() arguments in allocations
In a number of places we have
struct X *val;
val = malloc(sizeof(struct Y));
If sizeof(struct Y) < sizeof(struct X) this is obviously dangerous,
but it is incorrect regardless of the relative sizes of the
structures. Fix all of the occurences of this that clang points out
to us.
Simon Wilkinson [Fri, 15 Feb 2013 16:23:16 +0000 (16:23 +0000)]
aklog: Don't reference freed node whilst deleting
Because deletion is implemented using a for loop, the step of the
loop that moves us to the next node references freed memory when
we've deleted an element. Fix this by just shortcircuiting the
return from the function so we immediately exit.
Simon Wilkinson [Tue, 19 Feb 2013 14:41:26 +0000 (14:41 +0000)]
vos: Remove unused 'done' loop variable
In SendFile we break at the same time as setting the done flag,
so its value is never checked. Just remove it as it is redundant
with the current loop logic.
Simon Wilkinson [Fri, 15 Feb 2013 22:34:36 +0000 (22:34 +0000)]
libadmin: Don't try to release garbage connection
In bos_ServerOpen, initalise the contents of bos_server structure
to 0 using calloc, so that if we jump to the error handling stuff
before they are assigned real values we don't end up trying to
release garbage.
Simon Wilkinson [Tue, 12 Feb 2013 14:07:10 +0000 (14:07 +0000)]
usd: Can't call usd_FileStandard* with NULL
It doesn't make sense to call usd_FileStandard{Input,Output} with
a NULL usd_handle_t (and doing so would crash later in the
function), so don't check for attempts to do so.
Simon Wilkinson [Tue, 12 Feb 2013 13:15:16 +0000 (13:15 +0000)]
vlserver: bulkaddrs are unsigned ints
bulkaddrs_val is a pointer to an array of unsigned ints, not to
an array of ints. Fix the sizeof() used in the call to malloc to silence
a clang warning.
Simon Wilkinson [Tue, 12 Feb 2013 13:12:47 +0000 (13:12 +0000)]
ptserver: Simplify malloc assignment to shut up clang
Using a temporary variable of type (char *) to store the results
of malloc and realloc, and then casting the tmp variable to the
real type causes clang-analyzer to complain. Just simplify this
code by always using the real type in order to shut it up.