openafs.git
7 years agorx: Make rxevent_Put NULL the event ptr being put
Simon Wilkinson [Sun, 4 Nov 2012 17:06:41 +0000]
rx: Make rxevent_Put NULL the event ptr being put

Change rxevent_Put so that it takes a pointer to the event being
put, and NULLs that pointer. This removes a lot of duplicate code
in callers, as well as making it harder to reuse a discarded event.

Change-Id: Ib7a51f01687e08ea3dced5932ec9ec27797a784a
Reviewed-on: http://gerrit.openafs.org/8540
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agorx: Return success value when cancelling an event
Simon Wilkinson [Thu, 22 Nov 2012 08:41:51 +0000]
rx: Return success value when cancelling an event

When cancelling an event that holds reference counts, we need
to know whether the attempt to cancel the event was successful
or not, otherwise references can be double put when the
cancellation races with the event firing. Take the follwing

Thread A Event Thread
========= ============

... event fired ...
MUTEX_ENTER(&obj->lock);
if (obj->event) {
    rxevent_Cancel(&obj->event);
    obj_put(&obj->refcnt);
}
MUTEX_EXIT(&obj->lock)
MUTEX_ENTER(&obj->lock);
if (event == obj->event)
    rxevent_Put(&obj->event);
...
MUTEX_EXIT(&obj->lock);
obj_put(&obj->refcnt);

Holding obj->lock doesn't control whether the event is fired or
not. Only putting the reference if the event being fired matches
that in obj doesn't help - it just leaks a reference in a different
race.

So, make rxevent_Cancel return true if it did actually cancel the
event, and false if the event has already been fired. This means
that Thread A can become

MUTEX_ENTER(&obj->lock);
if (rxevent_Cancel(&obj->event)
    obj_put(&obj->refcnt);
MUTEX_EXIT(&obj->lock)

In the example above, rxevent_Cancel would return false.

Change-Id: I48e012774c97c9d9588b00687428a32795be2b37
Reviewed-on: http://gerrit.openafs.org/8539
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agorx: Don't treat calls specially in event package
Simon Wilkinson [Sat, 3 Nov 2012 23:15:50 +0000]
rx: Don't treat calls specially in event package

Many different structures can be passed to the rxevent package as
data. Don't give calls special treatment by making rxevent aware of
how to release their reference counts when an event is cancelled.

Update all of the callers of rxevent_Cancel to use the new arguments,
and where they were cancelling functions with calls as parameters add
the appropriate CALL_RELE directives. In many cases, this has led to
new helper functions to cancel particular call-based events.

Change-Id: Ic02778e48fd950e8850b77bd3c076c235453274d
Reviewed-on: http://gerrit.openafs.org/8538
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agorx: Remove unused origPeer parameter to FindPeer
Simon Wilkinson [Thu, 1 Nov 2012 17:44:07 +0000]
rx: Remove unused origPeer parameter to FindPeer

rxi_FindPeer took an 'origPeer' parameter, which was originally
there as an optimisation to decrement a reference count when replacing
a peer on a connection structure. However, we don't do that any more,
and the origPeer parameter is never used.

Just remove it to simplify this bit of code.

Change-Id: I49127f25dd151082f4e508a28e8cab232e251ed1
Reviewed-on: http://gerrit.openafs.org/8537
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: Remove unused timeoutEvent
Simon Wilkinson [Thu, 15 Nov 2012 18:21:27 +0000]
rx: Remove unused timeoutEvent

The timeoutEvent pointer in the rx_call structure is unused. Remove
it to reduce confusion about which events can hold call reference
counts.

Change-Id: Ide625fe0af608cc434c33188e642750979a8db21
Reviewed-on: http://gerrit.openafs.org/8536
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: CheckBusy doesn't drop conn_call_lock
Simon Wilkinson [Fri, 9 Nov 2012 23:20:42 +0000]
rx: CheckBusy doesn't drop conn_call_lock

As rxi_CheckBusy doesn't drop the conn_call_lock when it checks for
busy call slots, it doesn't need to deal with someone replacing a
call behind its back.

Change-Id: I7cc64150e32e29b0a497cded55cd187b5bb78ad1
Reviewed-on: http://gerrit.openafs.org/8535
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: RefCounts, Asserts, and Trace Logging
Jeffrey Altman [Mon, 26 Nov 2012 16:25:43 +0000]
Windows: RefCounts, Asserts, and Trace Logging

Rename DirectoryCB.OpenReferenceCount to DirOpenReferenceCount
to distinguish it from the FCB.OpenReferenceCount.  This makes
it easier to search for instances within an editor or debugger.

Ensure that all InterlockedIncrement and InterlockedDecrement
calls on a reference count field assign their value to a local
'lCount' variable.  Ensure that 'lCount' is used within any
trace log messages and conditionals.

Add ASSERT( lCount >= 0) after all reference count decrements
in order to catch underflows.

Change conditionals from (RefCount == 0) to (RefCount <= 0) so
that object destruction can occur when there has been an underflow.
This is important in release builds for which ASSERT() is a no-op.

Change-Id: I1d10076464c68745ede117eef2f728f70a0003c1
Reviewed-on: http://gerrit.openafs.org/8522
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: AFSClose File FCB/CCB cleanup before DirCB
Jeffrey Altman [Mon, 26 Nov 2012 16:16:56 +0000]
Windows: AFSClose File FCB/CCB cleanup before DirCB

Move the processing of FCB and CCB cleanup ahead of the
DirectoryCB cleanup.  It is not safe to dereference the
Ccb->DirectoryCB until after the CCB has been destroyed.

Change-Id: I74ec824ea523fe1d575169472c65da6ffe87ce5e
Reviewed-on: http://gerrit.openafs.org/8521
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: AFSDeleteObjectInfo not on volume roots
Jeffrey Altman [Sun, 25 Nov 2012 23:13:53 +0000]
Windows: AFSDeleteObjectInfo not on volume roots

The VolumeCB embeds an ObjectInformationCB structure which must
not be freed by calling AFSDeleteObjectInfo().  Add an assert
in the checked build and return without destroying the object
in the free build.

Change-Id: I77c92fbe0d10252785f4796153d9d824ff074d4c
Reviewed-on: http://gerrit.openafs.org/8520
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Missing DirEntry Ref incr AFSLocateName
Jeffrey Altman [Mon, 26 Nov 2012 12:10:05 +0000]
Windows: Missing DirEntry Ref incr AFSLocateName

In the STATUS_NAME_COLLISION error path the DirEntry refcnt must
be incremented because it will be decremented before exit from
AFSLocateName().

Change-Id: I7cf976afa8e62d0d9803549b64a5d0dae27cd9b1
Reviewed-on: http://gerrit.openafs.org/8518
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: AFSLocateNameEntry move InsertNextEntry
Jeffrey Altman [Mon, 26 Nov 2012 06:18:19 +0000]
Windows: AFSLocateNameEntry move InsertNextEntry

In AFSLocateNameEntry, move the InsertNextEntry to name array
call from before the directory entry DirOpenReferenceCount is
incremented to afterwards.  This permits InsertNextEntry() to
consistently assert based upon the DirOpenReferenceCount value.

Change-Id: I3c65f5360650739f6d75b7e657ae5cdea4c14aa4
Reviewed-on: http://gerrit.openafs.org/8517
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: AFSInvalidateCache volume refcounts
Jeffrey Altman [Sun, 25 Nov 2012 23:06:17 +0000]
Windows: AFSInvalidateCache volume refcounts

AFSInvalidateCache failed to release the volume reference count
when FileId is the volume root.   In the non-root case it released
it too early permitting a race with AFSPrimaryVolumeWorkerThread
calling AFSRemoveVolume().

Change-Id: I12b756e5a543a2ef791d716f660df1f4a7ae2327
Reviewed-on: http://gerrit.openafs.org/8516
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Fail RX_INVALID_OPERATION errors
Jeffrey Altman [Sat, 24 Nov 2012 19:36:46 +0000]
Windows: Fail RX_INVALID_OPERATION errors

RX_INVALID_OPERATION errors were not resulting in an eventual
failure and the RPC was being repeated indefinitely.  There were
three subtle problems:

 1. RX_INVALID_OPERATION was being processed by cm_Analyze()
    resulting in a retry in all cases.  Even those where no
    connp was passed in as NULL.  connp == NULL implies that
    no server could be obtained so the RPC was not issued on
    this pass.  As a result there should be no retry.

 2. RX_INVALID_OPERATION was mapped to CM_ERROR_UNKNOWN which
    is not an error that is reported to the AFS redirector.

 3. RDR_BkgFetch was setting CM_REQ_NORETRY and permitting
    the retries to be handled by the cm_daemon threads.  However,
    CM_ERROR_UNKNOWN was not treated as a fatal error by cm_Daemon.

Address the failures in the following ways:

 A. cm_Analyze no longer retries calls which did not take place.

 B. Create a new CM_ERROR_INVAL_NET_RESP error for RX_INVALID_OPERATION
    which is translated to the Win32 STATUS_INVALID_NETWORK_RESPONSE
    error.  This is now returned to the AFS redirector and treated
    as a fatal error.

 C. RDR_BkgFetch no longer queues tasks to cm_Daemon with the
    CM_REQ_NORETRY flag set.

Change-Id: I1eba0e83fbbe5726f43f667ddb67ced8c011853d
Reviewed-on: http://gerrit.openafs.org/8510
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agovol: Let non-usable volumes attach for non-DAFS
Andrew Deason [Wed, 28 Nov 2012 23:22:21 +0000]
vol: Let non-usable volumes attach for non-DAFS

Before DAFS, volumes that were not inService/blessed were not
accessible by normal clients, but were still allowed to attach. That
is, access to clients was prevented at VGetVolume-time, rather than at
attach-time. Commit 939382c5 tried to short-circuit this by detecting
this volume state at attach-time. However, volume utilities (e.g.
volserver) can give us back a volume over FSSYNC when they are done
with the volume, and for non-DAFS, we then try to attach the volume.
So, with 939382c5 that attachment will fail when volserver gives us
back a volume that is not inService/blessed (which can happen for some
normal volume operations).

This situation is not terrible, since either way the volume is not
usable by clients (since the volume didn't attach), and the volume is
still usable by volserver (since volserver is allowed to check out
nonexistent volumes). But it is a deviation from pre-DAFS behavior and
it can result in confusing error messages, so revert the 939382c5
behavior for non-DAFS.

For DAFS, this behavior is fine, since the fileserver does not attach
a volume unless it is trying to service a client request. So, leave it
for DAFS.

FIXES 131505

Change-Id: I8cf47640ceb068762eb42f1b70eb88aa9c4a060a
Reviewed-on: http://gerrit.openafs.org/8557
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: Add a no-op afs_kcondvar_t for LWP
Simon Wilkinson [Fri, 9 Nov 2012 23:11:16 +0000]
rx: Add a no-op afs_kcondvar_t for LWP

Remove the need to protect afs_kcondvar_t with RX_ENABLE_LOCKS, by
typedefing it as an int in rx_lwp.c. This is identical to what we
already do with afs_kmutex_t, and should let us get rid of some more
preprocessor spaghetti.

Change-Id: Ica6114585a68abde691ceee47d92d7f4e230a9bc
Reviewed-on: http://gerrit.openafs.org/8534
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agorx: Lock call for KeepAliveOn/KeepAliveOff
Andrew Deason [Wed, 14 Nov 2012 05:30:41 +0000]
rx: Lock call for KeepAliveOn/KeepAliveOff

rxi_KeepAliveOn/Off expect the call lock to be held after the call has
been initialized. So, hold it in the rx_KeepAliveOn/Off callers.

Change-Id: Ic2e96853bc9553e97f62e4502a5c92bbb28c63a2
Reviewed-on: http://gerrit.openafs.org/8463
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Handle VNOSERVICE as a timeout
Andrew Deason [Wed, 14 Nov 2012 00:27:11 +0000]
afs: Handle VNOSERVICE as a timeout

For whatever reason, the fileserver uses VNOSERVICE to indicate that
an Rx call was killed due to an idledead timeout. It is not used for
any volume errors, so treat it like the idle dead error codes.

Change-Id: I432cbb8ae011d5269ac8df31261d11204687fcf6
Reviewed-on: http://gerrit.openafs.org/8462
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: cm_LookupInternal obtain type of target
Jeffrey Altman [Tue, 27 Nov 2012 05:16:58 +0000]
Windows: cm_LookupInternal obtain type of target

cm_LookupInternal needs to return the target of a mount point
if the matching directory entry is a mount point.  Therefore, if
the target type is unknown the status information must be queried.

Change-Id: Ifc37897531766f59e2517650ed7050cba50d6819
Reviewed-on: http://gerrit.openafs.org/8528
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: cm_GetNewSCache init mpDV to BAD
Jeffrey Altman [Tue, 27 Nov 2012 05:08:30 +0000]
Windows: cm_GetNewSCache init mpDV to BAD

when allocatiing a new cm_scache_t object the mpDataVersion
field must be initialized to CM_SCACHE_BAD_VERSION.  Zero is
a valid data version for a mount point or symlink.

Change-Id: If455b35cf01454ddf4a5b0a8adcc6e39d71b33d0
Reviewed-on: http://gerrit.openafs.org/8527
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoafs: Slight restructuring in afs_Analyze
Andrew Deason [Wed, 14 Nov 2012 00:15:21 +0000]
afs: Slight restructuring in afs_Analyze

We test for acode < 0 && acode != VRESTARTING, but then immediately
test for specific values for acode. Move this conditional down, and
remove a level of indentation for the next couple of acode checks.

This commit should introduce no functional change.

Change-Id: I2ca3a00d5f6d620fcb042d8007f18dd8b5cfaf24
Reviewed-on: http://gerrit.openafs.org/8461
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: Generate BUSY packets for error call channels
Andrew Deason [Wed, 14 Nov 2012 04:46:34 +0000]
rx: Generate BUSY packets for error call channels

Currently, if a call is error'd out but still active, we won't
generate BUSY packets if another call comes in on the same channel.
This is because we bail out earlier, here, before we get to the BUSY
processing.

The comments suggest that this is for if we enter an error state while
waiting for TQ to clear. So, only do this if our error has changed.

Change-Id: I070f2af16bc79b1ebc7d19b7cb761fdbca78344b
Reviewed-on: http://gerrit.openafs.org/8460
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: AFSValidateEntry Symlink TargetName
Jeffrey Altman [Sun, 25 Nov 2012 19:30:07 +0000]
Windows: AFSValidateEntry Symlink TargetName

During an AFSValidateEntry if the data version of the symlink
object has not changed, do not discard or rebuild the target
name if already assisgned.

Change-Id: If37af308ee48ec761283ff6e831ffa5e06dacf58
Reviewed-on: http://gerrit.openafs.org/8515
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Panic if RDR_Initialize SERVICE_DISABLED
Jeffrey Altman [Mon, 26 Nov 2012 04:56:47 +0000]
Windows: Panic if RDR_Initialize SERVICE_DISABLED

If RDR_Initialize() fails with ERROR_SERVICE_DISABLED it means that
the AFSRedir.sys driver loaded but the AFSRedirLib.sys driver library
cannot be loaded.  In this situation neither the RDR nor SMB interfaces
can successfully be used.  Panic!

Change-Id: I09d30a86b9d72b9077d4c7578dab52314cce559a
Reviewed-on: http://gerrit.openafs.org/8514
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: GetResourceInformation print path earlier
Jeffrey Altman [Fri, 16 Nov 2012 22:20:33 +0000]
Windows: GetResourceInformation print path earlier

In the network provider, GetResourceInformation was logging the
input resource path after the afs redirector chopped it up.  Log
it before the DeviceIoControl call.

Change-Id: Icefcf65583b95fd46c8e28bd0e2c53258b5094fa
Reviewed-on: http://gerrit.openafs.org/8509
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoLINUX: Dir follow_link should set LAST_BIND
Andrew Deason [Wed, 21 Nov 2012 16:39:51 +0000]
LINUX: Dir follow_link should set LAST_BIND

For our faux-symlink directory follow_link operation, we leave the
given nameidata struct with an invalid 'last' component. That is,
nd->last is not changed or set to anything meaningful.

Usually the callers of our follow_link op do not care about the last
component of the nameidata. However, at least one caller does: the
caller near the do_link label in open_namei(). This is called during
processing for O_CREAT operations on symlinks, and since our
directories look like symlinks, it gets called. It tries to use
nd->last to look up the last component of the dereferenced path (so it
can try to create it, as necessary), but since our nd->last is not
set, this will not work.

Specifically, our nd->last.name is not pointing into the names cache,
so the subsequent putname/__putname on it will corrupt the names
cache. However, even if this were not a problem, the actual contents
of the last component do not seem meaningful so this would probably
result in incorrect behavior anyway.

To avoid all of this, set nd->last_type to LAST_BIND, so any callers
know that the last component of the given nd is not valid, and we are
pointing directly to the target component with a dentry.

Change-Id: I9cebc3b63ae7a2410295392a08aa8fc738549234
Reviewed-on: http://gerrit.openafs.org/8489
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoDo not call afs_MarinerLog when afs_mariner is not set
Hans-Werner Paulsen [Mon, 26 Nov 2012 14:46:26 +0000]
Do not call afs_MarinerLog when afs_mariner is not set

When mariner log is not set up (afs_mariner=0), do not call afs_MarinerLog,
otherwise a osi_NetSend() to hostaddress=0 is tried, which will give you
ICMP messages in the socket error queue.
Do not call afs_AddMarinerName, when afs_mariner is not set.

Change-Id: I1ed6369fb0eea130348f4f6fd37bb0d021c4c791
Reviewed-on: http://gerrit.openafs.org/8519
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: Add Hard Link support to Service
Jeffrey Altman [Sat, 17 Nov 2012 05:43:00 +0000]
Windows: Add Hard Link support to Service

Implement Hard Link support to the redirector interface in the
service.  It is implemented to support hard links across directories
even though AFS does not currently support it.  cm_Link() will
check before issuing an RPC to the file server.   ReplaceIfExists
functionality is implemented by cm_Unlink() followed by cm_Link()
if required.

Change-Id: Icb4e7eeaed1ae57719c487fe3bf29efea1902246
Reviewed-on: http://gerrit.openafs.org/8482
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Add Hard Link support to AFS Redirector
Jeffrey Altman [Sat, 17 Nov 2012 03:27:02 +0000]
Windows: Add Hard Link support to AFS Redirector

Both Windows and AFS support the notion of hard links to files.
Add an implementation to the AFS redirector.  The body of the
functionality and the IOCTL to the service permits the specification
of hard links to files across directory boundaries.  There is a
restriction within AFSSetFileLinkInfo() which prevents cross-directory
requests.  However, this can be taken out if AFS ever permits them.

Decrement object information link counts on directory entry
deletions.  Do not delete object information context blocks if the
link count is greater than 0.  Increment link counts when hard
links are added.

A subsequent patchset will implement the afsd_service support.

Change-Id: Iffabf480c0b43ab76feb5bdf3464a0bf1324e642
Reviewed-on: http://gerrit.openafs.org/8481
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Trend Micro QueryDirectory deadlock
Jeffrey Altman [Thu, 22 Nov 2012 16:52:11 +0000]
Windows: Trend Micro QueryDirectory deadlock

Trend Micro will deadlock both itself and the AFS redirector by
calling a worker thread to generate a temporary file name during
an active FindFirst Directory Query.  The Trend Micro worker will
also attempt to enumerate the directory.   If the directory contains
an entry for which the data version as reported by the service is
different than the data version in the ObjectInformationCB a deadlock
will occur on the matching FileCB Resource.

To avoid this deadlock, prevent AFSValidateEntry from purging or
updating the ObjectInformationCB and FileObject information when
called from AFSQueryDirectory.

Change-Id: I8f2f7136796759eb91dadfea34a89513c1a1fff4
Reviewed-on: http://gerrit.openafs.org/8492
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Missing lock in AFSNotifyRename
Jeffrey Altman [Mon, 19 Nov 2012 20:33:33 +0000]
Windows: Missing lock in AFSNotifyRename

If the ParentObjectInformation and TargetParentObjectInformation
are different, the TreeLock for each must be held.

Change-Id: Iac9910d838f8f35b286e4e40009cfd547ed8a438
Reviewed-on: http://gerrit.openafs.org/8479
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: AFSSetRenameInfo always set pRenameInfo
Jeffrey Altman [Mon, 19 Nov 2012 20:30:09 +0000]
Windows: AFSSetRenameInfo always set pRenameInfo

Make it easier to debug AFSSetRenameInfo by setting pRenameInfo
so that the FILE_RENAME_INFORMATION structure is visible within
the debugger on all code paths.

Change-Id: I6e47c417e2468eeb4f56a680ddcbe75cb8753916
Reviewed-on: http://gerrit.openafs.org/8478
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: SetFileRenameInfo Improve Error Handling
Jeffrey Altman [Fri, 16 Nov 2012 04:13:17 +0000]
Windows: SetFileRenameInfo Improve Error Handling

If a Target FileObject is not provided by the IOManager and
a Target RootDirectory Handle is provided something has gone
wrong.  Return STATUS_INVALID_PARAMETER to indicate the
invalid state.

If the target directory is not specified by FileObject and a full
target path is provided return STATUS_NOT_SAME_DEVICE to force
an object Move instead of Rename.

Change-Id: I54c3c978c0b9fcc3d4b61fb9f7b7d0771e38f714
Reviewed-on: http://gerrit.openafs.org/8477
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: smb_ReceiveTran2QFileInfo Pioctl support
Jeffrey Altman [Wed, 21 Nov 2012 23:08:35 +0000]
Windows: smb_ReceiveTran2QFileInfo Pioctl support

Similar to the QueryPathInfo support for _._AFS_IOCTL_._ the
QueryFileInfo interface must respond to pioctl queries.  When
GetFileAttributes() on XP is called from the afslogon.dll the
QFileInfo path is used instead of the QPathInfo path.

Change-Id: I119fbefbf933e868cac57eb508ef30a45277a50f
Reviewed-on: http://gerrit.openafs.org/8491
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: afslogon do not specify smbName for tokens
Jeffrey Altman [Wed, 21 Nov 2012 23:03:10 +0000]
Windows: afslogon do not specify smbName for tokens

The smbName was added to the Windows ktc_SetTokens() interface
to provide a mechanism for passing the Windows account name
that the tokens should be associated with via Integrated Logon.
This was only required when the Authentication Provider did not
impersonate the user context prior to calling ktc_SetTokens().
Now that impersonation is used, the ktc_SetTokens() call will
do the right thing without the smbName.  In fact, when impersonation
is used setting the smbName does the wrong thing by specifying
the AFS_PIOCTL_LOGON flag which is only valid if the SYSTEM account
is issuing the ktc_SetToken() call.

Change-Id: I6d04b56b815571f6e9fe3557544bd93a5b9ca735
Reviewed-on: http://gerrit.openafs.org/8490
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Fix smb_ReceiveTran2QPathInfo Pioctl support
Jeffrey Altman [Wed, 21 Nov 2012 06:13:49 +0000]
Windows: Fix smb_ReceiveTran2QPathInfo Pioctl support

The path check should needs to include the root directory slash
when comparing to the \_._AFS_IOCTL_._ path to detect a pioctl
request.

Change-Id: I1d2c620fdcff55a0c90d8be3f3de6a1bd1137b8f
Reviewed-on: http://gerrit.openafs.org/8488
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: QuerySecurity deny access to SACL
Jeffrey Altman [Tue, 20 Nov 2012 06:23:08 +0000]
Windows: QuerySecurity deny access to SACL

The SACL requires System Access Level.  Requests for SACL by
end user applications must be denied.  Permit access to Owner,
Group, DACL and Label but not SACL.

This change permits executables to be initiated from drive
letter mappings.

Change-Id: Ibf847261f0c36dc7b6175b0536657161158cd44f
Reviewed-on: http://gerrit.openafs.org/8483
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Fix Redir link counting
Jeffrey Altman [Mon, 19 Nov 2012 20:06:47 +0000]
Windows: Fix Redir link counting

Each object in AFS has a link count which tracks the number of
directory entries that refer to the FileId.  In the redirector
there is one ObjectInformationCB per FileId and one AFSDirectoryCB
for each directory entry.  When a directory entry is deleted perhaps
by delete on close it is important to ensure that the matching
ObjectInformationCB is not deleted unless the Link count drops to 0.

Change-Id: I2c7906d5881f93ed60697d40a0ea462f4567d443
Reviewed-on: http://gerrit.openafs.org/8480
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: buf_CleanLocked protect against NULL bp->userp
Jeffrey Altman [Sun, 18 Nov 2012 02:44:52 +0000]
Windows: buf_CleanLocked protect against NULL bp->userp

The cm_buf_t.userp field should never be NULL if the CM_BUF_DIRTY
flag is set but apparently it sometimes is.  cm_BufWrite() requires
that the userp parameter be non-NULL.  Otherwise, an assertion fails
and afsd_service.exe panics.  If bp->userp is NULL, use cm_rootUserp.
The worst that will happen is the write will fail due to an access
denied error.

Change-Id: I6cc650dcffe2b0fb50ac2ce91b74e8afbdfc40ca
Reviewed-on: http://gerrit.openafs.org/8475
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: do not adjust deleted scache LRU ordering
Jeffrey Altman [Sun, 18 Nov 2012 02:39:50 +0000]
Windows: do not adjust deleted scache LRU ordering

Instead of moving deleted scache objects so that they are next
in line to be recycled, do not move them at all.  Making them
next to be recycled results in the CM_SCACHEFLAG_DELETED flag
value being lost.

Change-Id: I3839053066cca304454e445b2f4e4abea6e08dda
Reviewed-on: http://gerrit.openafs.org/8474
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: buf_CleanLocked validate cm_scache_t
Jeffrey Altman [Sun, 18 Nov 2012 02:32:44 +0000]
Windows: buf_CleanLocked validate cm_scache_t

If the cm_scache_t object is not passed in by the caller ensure
that the cm_scache_t has a valid callback.  If the cm_scache_t
has the CM_SCACHEFLAG_DELETED flag set, clear the dirty flag on
the cm_buf_t and do not bother contacting the file server.

Change-Id: If85be550b59765f64aadea4e1882af9430cebcb4
Reviewed-on: http://gerrit.openafs.org/8473
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: buf_SetDirty add assertion
Jeffrey Altman [Sat, 17 Nov 2012 22:11:42 +0000]
Windows: buf_SetDirty add assertion

the userp parameter must never be NULL.

Change-Id: Id785ac417bc869f708990f0bfe53809e3e5c71e5
Reviewed-on: http://gerrit.openafs.org/8472
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoopr: Don't confuse isLast and isEnd
Simon Wilkinson [Wed, 21 Nov 2012 16:46:29 +0000]
opr: Don't confuse isLast and isEnd

opr_queue_IsEnd's implementation was incorrect - it would return
true when the element was the last item in the list, not when it
was the end of the list (equal to the head record)

Correct the implementation of isEnd, and add an implementation for
isLast.

This fixes a bug in RX, wher we would never notice that the last
packet in the transmit queue was acknowledged, because the loop that
iterates over the queue uses isEnd to detect when its work is done.

Change-Id: I8966e05c479c18d025bb5cc4cf77514ce002be95
Reviewed-on: http://gerrit.openafs.org/8493
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Do not skip flushing pages for dv-0 files
Andrew Deason [Thu, 15 Nov 2012 00:29:35 +0000]
afs: Do not skip flushing pages for dv-0 files

If the dv for a file is 0, we know the file is empty. Currently we
skip flushing pages for such files, presumably the idea being there is
no data in the file, so there should be no pages to flush.

However, Linux seems to keep empty pages around for empty files. So, a
future read can result in the application reading a page full of
zeroes, unless we flush the page here. While this has only been found
to happen on Linux 2.6.22 and later (and distribution-specific
backports, like RHEL 2.6.18-128), other platforms could in theory also
choose to do this. It would be difficult to find out when another
platform started to behave like this, so just remove this skip for
everyone so we never have to deal with this again.

Replace this code with a comment with a quick explanation, in case
anyone tries to add a similar optimization here in the future.

Thanks to Richard Brittain.

Change-Id: I68c51bb7612a98a5c75112bb8f4bb1edd949fda1
Reviewed-on: http://gerrit.openafs.org/8465
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoLinux 3.7: key instantiate API change
Marc Dionne [Fri, 16 Nov 2012 01:58:03 +0000]
Linux 3.7: key instantiate API change

Adapt to the new parameters for the instantiate key operation.

Change-Id: I25dea3489b68cad662e962a4973ee98ec7228cd3
Reviewed-on: http://gerrit.openafs.org/8470
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Hans-Werner Paulsen <hans@MPA-Garching.MPG.DE>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoLinux 3.7: remove use of param.h and ioctl.h
Marc Dionne [Thu, 15 Nov 2012 22:49:53 +0000]
Linux 3.7: remove use of param.h and ioctl.h

Header files param.h and ioctl.h have moved as part of the userspace
API restructuring of header files.  Nothing in those files is
currently needed by the source, so just drop the includes.

Change-Id: Icbbf7038ca1bf23edbde42aaf48f5108626d0040
Reviewed-on: http://gerrit.openafs.org/8469
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoLinux: change test for new putname API
Marc Dionne [Thu, 15 Nov 2012 03:12:13 +0000]
Linux: change test for new putname API

Replace the existing test with a more robust one that checks for
the existence of the new filename structure.  Since older kernels
are expected to fail this test, we'll get the correct result even
if there is unrelated failure, for instance a missing/different
header file.

Change-Id: Ie50abce37580eab803e9b07e636a1538f4a91a81
Reviewed-on: http://gerrit.openafs.org/8466
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: Hold ProcessTreeLock across AFSValidateProcessEntry
Jeffrey Altman [Wed, 14 Nov 2012 12:02:01 +0000]
Windows: Hold ProcessTreeLock across AFSValidateProcessEntry

AFSValidateProcessEntry() is called from AFSProcessCreate() which
holds the ProcessTree.TreeLock exclusive across the call and from
AFSCreate() and AFSRetrieveAuthGroup() where it is not held at all.

Add a parameter to AFSValidateProcessEntry() that indicates whether
or not the ProcessTree.TreeLock is held.  If it is held, it must be
held exclusive.  If it is not held, the lock must be acquired within
AFSValidateProcessEntry() and it must be held for the entire lifetime
of the pParentProcessCB reference.  Failure to hold the TreeLock
for the lifetime of the reference permits a race with AFSProcessDestroy()
that can result in the parent ProcessCB being destroyed while its
Resource is held.

Change-Id: I7cf0dff6bd541b0588a060d677a8e3d724858b96
Reviewed-on: http://gerrit.openafs.org/8455
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Do not reset cm_buf.offset on error
Jeffrey Altman [Tue, 13 Nov 2012 22:59:06 +0000]
Windows: Do not reset cm_buf.offset on error

When an error occurs the cm_buf_t is not removed from the
hash tables.  Since the scacheHashTable hash is built from
the fid and the offset it is not safe to reset the offset field.
Resetting the offset field results in an assertion failure
during buffer recycling.

Change-Id: Id33ec048f8ecfd7f715feafadfa4ea618cdbac0d
Reviewed-on: http://gerrit.openafs.org/8452
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoinclude roken.h in yacc parsers
Jeffrey Altman [Tue, 13 Nov 2012 14:14:39 +0000]
include roken.h in yacc parsers

Change-Id: Ic6f2dba3ee5bbfdb2794fd9ecc8e1ab2eb3de828
Reviewed-on: http://gerrit.openafs.org/8450
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoafs: Add some comments on GetValidDSlot panics
Andrew Deason [Thu, 1 Nov 2012 21:46:13 +0000]
afs: Add some comments on GetValidDSlot panics

A couple of call sites for afs_GetValidDSlot currently panic if an
error is returned, but no explanation is given. Add a few comments
helping explain why there is a panic there, instead of graceful error
handling.

Change-Id: Ic1c9808c427fe7524ea7dc1b7dbab8e9ac665b91
Reviewed-on: http://gerrit.openafs.org/8407
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs_FreeDiscardedDCache: Avoid assert on error
Andrew Deason [Thu, 1 Nov 2012 21:33:31 +0000]
afs_FreeDiscardedDCache: Avoid assert on error

Currently afs_FreeDiscardedDCache will assert if it cannot read in any
discarded dcache entry to free. Return an error instead of asserting,
so the caller can figure out what to do about the error.

Adjust the callers to handle the error, or panic.
afs_MaybeFreeDiscardedDCache still just panics anyway, as making it
handle the error gracefully is beyond the scope of this commit, and is
work for another day.

This changes afs_FreeDiscardedDCache to return an int.

Change-Id: Id1e77af18461c9804b655c6f91ac90038621a394
Reviewed-on: http://gerrit.openafs.org/8406
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Handle afs_AllocDCache errors
Andrew Deason [Thu, 1 Nov 2012 20:43:09 +0000]
afs: Handle afs_AllocDCache errors

Do not panic if afs_AllocDCache encounters an error and returns NULL.
Instead, go into the normal retry loop that occurs if we couldn't free
up any more free/discard dcache entries.

Change-Id: Ia165e0b5f5ef37e05942c795955d75f26e4ea7d3
Reviewed-on: http://gerrit.openafs.org/8405
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs_AllocDCache: return NULL instead of panic
Andrew Deason [Thu, 1 Nov 2012 20:32:31 +0000]
afs_AllocDCache: return NULL instead of panic

Currently afs_AllocDCache will panic if we cannot get a valid dcache
from the free/discard lists. Instead, return NULL, so the caller can
decide how to handle the error.

Currently the caller will just panic anyway, but that will be
addressed in a future commit.

Change-Id: Iafb539bbda9ef20907ef575699185f111ca39c2b
Reviewed-on: http://gerrit.openafs.org/8377
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Traverse discard/free dslot list if errors
Andrew Deason [Thu, 1 Nov 2012 18:41:06 +0000]
afs: Traverse discard/free dslot list if errors

Currently, when we pull a dslot off of the discard or free list, we
just try to get the first entry from the list, and panic if we cannot
get it. Instead, traverse through the whole list, trying to find an
entry we can successfully get. This introduces the helper function
afs_GetDSlotFromList to do this traversal.

This does not yet address the case where we cannot get any entry on
the relevant list.

Change-Id: Iedbcffcbeb5dda61fde8e1d526e793f68c3200b3
Reviewed-on: http://gerrit.openafs.org/8376
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Handle easy GetValidDSlot errors
Andrew Deason [Thu, 1 Nov 2012 16:51:42 +0000]
afs: Handle easy GetValidDSlot errors

Many callers of GetValidDSlot currently assume they will always get
back a valid dcache, and will panic on getting NULL. However, for many
of these callers, handling the NULL case is quite easy, since the
failure to get a dcache can just result in an error directly, or
obtaining the dcache is best-effort or just an optimization.

This commit just handles the "easy" cases; some other callers require
more complex handling.

Change-Id: I622908de7004ba4cb18ccb26bda0e75b879f65ca
Reviewed-on: http://gerrit.openafs.org/8375
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoafs: Never use GetNewDSlot after init
Andrew Deason [Wed, 31 Oct 2012 20:55:35 +0000]
afs: Never use GetNewDSlot after init

Currently there are two ways to get a dcache via a slot number:
afs_GetNewDSot and afs_GetValidDSlot. afs_GetValidDSlot assumes that
the given slot number refers to a dcache entry that is valid on disk;
with afs_GetNewDSlot, the given slot may not be valid, and if it is
not, an empty 'template' dcache is returned.

afs_GetNewDSlot is useful for initializing cache files, since if a
given dcache slot exists on disk and contains valid data, we use the
dcache like normal. If it does not already exist or does not contain
valid data, we fill in the missing data after afs_GetNewDSlot returns.

However, for all other uses, afs_GetNewDSlot is incorrect, and causes
various serious problems. After we have initialized our dcache
entries, any attempt to read a dcache by slot number should succeed,
since the number of dcache entries never changes after we are started,
and we initialized all of them during client startup.

Some code outside of afs_InitCacheFile was still using
afs_GetNewDSlot; code that reads in a dslot from the free or discard
list. In these cases, if there is any error reading the dcache slot
from disk, we will be given a dcache that has some of its fields not
filled in properly. Notably, we assume that the entry is not on the
global hash table (we set tdc->f.fid.Fid.Volume to 0), and the
tdc->f.inode field is not initialized at all, leaving it set to
whatever was in memory for that tdc before we tried to read the slot
from disk.

This can cause cache corruption, since tdc->f.inode can point to the
inoder for a different existing cache file, so writing to that dcache
modifies the data for another cached file.

To avoid this, modify the non-afs_InitCacheFile callers of
afs_GetNewDSlot to avoid afs_GetNewDSlot. Since these callers read
from the free/discard list, the contents of the dcache entries are not
valid (the cell, volume, dv, etc are not valid), though they must
exist on disk (we have a valid inode number for them). So, create a
new function, afs_GetUnusedDSlot, to get a dcache that must exist on
disk, but does not represent any valid data. Use this for callers that
must get a dslot from the free/discard list.

Add some comments to try and help explain what is going on.

Change-Id: I5b1b7ef4886102a9e145320932b2fd650b5c6f2f
Reviewed-on: http://gerrit.openafs.org/8370
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoWindows: SYMSTORE the entire WINNT/afsrdr tree
Jeffrey Altman [Mon, 12 Nov 2012 23:54:54 +0000]
Windows: SYMSTORE the entire WINNT/afsrdr tree

The tools directories need to be imported into the symstore
one directory at a time.

The "build.exe" output files afsredir.sys, afsredirlib.sys and
afsrdfsprovider.dll must be imported from within the kernel
build environment script.

Change-Id: Ida7d84deecfb1ec4f508c5c40fc5576e2cb7b3e4
Reviewed-on: http://gerrit.openafs.org/8445
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Add AFSRedir binaries to Symbol Store
Jeffrey Altman [Mon, 12 Nov 2012 16:47:50 +0000]
Windows: Add AFSRedir binaries to Symbol Store

Change-Id: I1b4f2d5fcd4243e9a8a931a223bced33631206b0
Reviewed-on: http://gerrit.openafs.org/8441
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: torture should not reference roken.h
Jeffrey Altman [Mon, 12 Nov 2012 12:13:07 +0000]
Windows: torture should not reference roken.h

Do not include roken.h in torture tests.  The torture test
should not be linked to afsroken.dll.

Change-Id: I14d67c2e2f9980906854e0ab72c040eb9437a931
Reviewed-on: http://gerrit.openafs.org/8431
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoafsio: process windows file paths consistently
Jeffrey Altman [Mon, 12 Nov 2012 03:00:07 +0000]
afsio: process windows file paths consistently

Windows file paths can use either '\' or '/' as a path
separator.  libafscp on the other hand requires '/' and argv[0]
will always use '\'.

Introduce a new function ConvertAFSPath() which converts the
input path to '/' and converts \\afs to /afs.  A future commit
should access the registry and make use of the NetbiosName and
MountRoot values to perform the conversion correctly.

Change-Id: I14f5f45234ec4beab58751783a25206b3e7eff45
Reviewed-on: http://gerrit.openafs.org/8430
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agolibafscp: Windows TellMeAboutYourSelf response
Jeffrey Altman [Mon, 12 Nov 2012 02:53:13 +0000]
libafscp: Windows TellMeAboutYourSelf response

The address list and uuid are computed in init_afs_cb().  There
is no need for special Windows processing within TellMeAboutYourSelf.

Change-Id: Ica4d2edb69ac9000713b016996a2c58e8b65ee9c
Reviewed-on: http://gerrit.openafs.org/8429
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agolibafscp: build as pthreaded for windows
Jeffrey Altman [Mon, 12 Nov 2012 02:52:27 +0000]
libafscp: build as pthreaded for windows

Change-Id: Iaa9515e572178f44deb670a83daba358c2d4dc74
Reviewed-on: http://gerrit.openafs.org/8428
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: afsrpc.dll MAKEDEBUGCALL
Jeffrey Altman [Sun, 11 Nov 2012 04:41:21 +0000]
Windows: afsrpc.dll MAKEDEBUGCALL

Enable debug calls from the pthreaded RX library.

Change-Id: Ie5e98d4408a3eb259e7f5f298f0776931f0d488a
Reviewed-on: http://gerrit.openafs.org/8427
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoafs: Pass rx connection to print_internet_address
Andrew Deason [Tue, 30 Oct 2012 18:30:27 +0000]
afs: Pass rx connection to print_internet_address

Make print_internet_address take an rx_connection, so it can print out
more information based on rx info. Currently it does not use the
connection; this commit is just for adding the connection to the
interface, and adjusting all of the callers to cope. There should be
no behavior change.

Change-Id: I410ffe43b7b6fc4d5c82666529c9263969820185
Reviewed-on: http://gerrit.openafs.org/8409
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agofix stale volume info from vos examine (non-dafs)
Michael Meffie [Tue, 30 Oct 2012 14:41:12 +0000]
fix stale volume info from vos examine (non-dafs)

A volume examine on a non-dafs volume server/fileserver can show old
information, including old volume update time, for up to about 20
minutes. The non-dafs volume server reads the volume information
from the volume headers, which are updated by the fileserver only
periodically to avoid excessive i/o.

Before dafs, when the volume server performed a volume examine, the
volume server would send a fssync command to the fileserver with the
request FSYNC_NEEDVOLUME and mode V_READONLY. The fileserver writes
the current memory contents to disk on this fssync command. The
volume server would then attach the volume, reading the current
volume data.

The dafs volume/fileserver avoids this extra i/o by using a new set
of fssync commands to retrieve the volume information from the
fileserver. However, the non-dafs volume server does not use the new
fssync commands and reads the volume headers from disk.

Revert the volume attachment processing for the non-dafs volume
server to request the volume with the V_READONLY mode. This causes
the fileserver to update the volume headers, allowing the volume
server to read the up to date volume header data.

Sadly, this adds another dafs ifdef to the already twisty maze of
passages that all look alike.

This changes the volserver to use the V_READONLY attachment mode
only for the case of getting a single volume, as that what was
done in 1.4.x.

Change-Id: Ibee25bfcfb087e73ccbc17e181a99da49a7751ae
Reviewed-on: http://gerrit.openafs.org/8327
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agovol: allow non-dafs volume utils to attach with V_READONLY again
Michael Meffie [Tue, 30 Oct 2012 14:22:40 +0000]
vol: allow non-dafs volume utils to attach with V_READONLY again

Allow non-fileserver, non-dafs, programs to attach volumes with the
V_READONLY mode again. This was lost during the code changes for
dafs.

The caller sends a fssync request to the fileserver, which updates the
on-disk contents of the volume headers, before the caller reads the
volume headers, allowing the caller to have the most recent info about
the volume. The fileserver still has the volume in use.

Later in the attachment process, the inUse check is skipped for the case
of a non-fileserver process which is attaching the volume using the
V_READONLY mode, otherwise the attachment would incorrectly mark the
volume as needing to be salvaged.

Note: The mode checks in VMustCheckOutVolume() are correct. We must
checkout the volume when attaching with the V_READONLY mode. This
fix updates the VShouldCheckInUse(), in which an additional
exception was added to cover the case for V_READONLY mode from a non-
fileserver process.

Note: A check is added in the dafs version of attach to avoid overwriting the
inUse field when a volume utility is attaching a volume in V_READONLY mode.
Currently, V_READONLY is not used by dafs, but this was done to avoid future
errors.

Change-Id: I09d3af1e74087d0627399392e662e5075d41cdeb
Reviewed-on: http://gerrit.openafs.org/8339
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agofileserver: check value of -cb argument
Hans-Werner Paulsen [Fri, 9 Nov 2012 12:48:45 +0000]
fileserver: check value of -cb argument

The value of the -cb argument for the fileserver was not checked correctly.
The fileserver refused to start for any number of callbacks.

Change-Id: I25fe9d81ba20d286f36999a554c94fda4ef7fb2f
Reviewed-on: http://gerrit.openafs.org/8420
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: use hKUserMap to read afslogon username
Jeffrey Altman [Thu, 8 Nov 2012 18:26:36 +0000]
Windows: use hKUserMap to read afslogon username

hkTemp is not the correct registry handle.  Use hkUserMap

Change-Id: I44776b6dd46bb0ecac0c729bf80ed9261ddf7a67
Reviewed-on: http://gerrit.openafs.org/8412
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Prevent SMB unitialized variable access
Jeffrey Altman [Thu, 8 Nov 2012 17:20:30 +0000]
Windows: Prevent SMB unitialized variable access

smb_ReceiveNTTranCreate would make use of 'fidp' before it was
allocated.

Change-Id: Ib4a7262ba09f15049f1855535250638c2e5d17a4
Reviewed-on: http://gerrit.openafs.org/8411
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Treat invalid AFSFetchStatus as VBUSY
Jeffrey Altman [Thu, 8 Nov 2012 16:29:20 +0000]
Windows: Treat invalid AFSFetchStatus as VBUSY

Modify cm_Analyze() to accept an AFSFetchStatus parameter which
when set is verified for validity.  If the status info is invalid,
then consider the response equivalent to VBUSY and attempt to
query an alternate file server (if any.)   Log the invalid status
info to the Windows Application Event Log as a Warning.

When cm_Analyze() is processing the response of an RPC that returns
multiple AFSFetchStatus structures, pass in the one that corresponds
with the source object.

Change-Id: I84be22f332ff6fd7bc9620347f958538a3412380
Reviewed-on: http://gerrit.openafs.org/8404
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: cm_IsStatusValid
Jeffrey Altman [Thu, 8 Nov 2012 15:39:43 +0000]
Windows: cm_IsStatusValid

Break out validity checking for AFSFetchStatus responses into
a new function.

Change-Id: I15d2ed12ed2d9ca9a24d6f717243d823db22d30c
Reviewed-on: http://gerrit.openafs.org/8403
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: cm_MergeStatus now returns an error code
Jeffrey Altman [Thu, 8 Nov 2012 05:24:14 +0000]
Windows: cm_MergeStatus now returns an error code

cm_MergeStatus() can fail if the AFSFetchStatus InterfaceVersion
field does not have the value 0x1 as that is the only version that
is defined by the protocol.  The return code will be CM_ERROR_INVAL.
cm_MergeStatus() returns 0 on success.

Update all of the call sites.

Change-Id: Iddf56f68dfa26b0f11744b905a70d7d39ad853d1
Reviewed-on: http://gerrit.openafs.org/8402
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoafs: Make last_error always useful
Andrew Deason [Wed, 31 Oct 2012 20:04:55 +0000]
afs: Make last_error always useful

Currently we record last_error as the last getuerror() we got when
failing to read in a slot in UFSGetDSlot. For kernels that do not have
getuerror(), this variable is currently useless, and we do not record
anywhere what the last error received was (besides logging it via
afs_warn).

So, for non-uerror, just record what 'code' we got, so we at least
have something.

Change-Id: Iede39bbeee48ea48f380b788f2968886a831a918
Reviewed-on: http://gerrit.openafs.org/8369
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoafs: Log slot for GetDSlot read errors
Andrew Deason [Wed, 31 Oct 2012 20:02:09 +0000]
afs: Log slot for GetDSlot read errors

When we log that a disk read error occurred during GetDSlot, log which
slot we were trying to read for convenience.

Change-Id: I35ffa94ff31cee735e85542ed9697b5f14180226
Reviewed-on: http://gerrit.openafs.org/8368
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agorx: Fix non-TSFPQ rxi_FreePackets
Andrew Deason [Thu, 8 Nov 2012 00:46:24 +0000]
rx: Fix non-TSFPQ rxi_FreePackets

Actually count the number of packets we're given, so we don't bail out
early because num_pkts is 0. Without this, we effectively do not free
most packets for non-pthreads Rx, so e.g. the unix kernel module will
leak memory quite quickly and be very slow.

This was introduced by 170dbb3c.

Change-Id: Id781e37170683c422b40079fdda018be1caddaf3
Reviewed-on: http://gerrit.openafs.org/8401
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: RDR_CleanupFileEntry protect lock release
Jeffrey Altman [Wed, 7 Nov 2012 21:34:23 +0000]
Windows: RDR_CleanupFileEntry protect lock release

Prevent lock release of scp->rw when not held.

Change-Id: I9ed3ca464a7881cd365ebe3560d5a6da22e21c86
Reviewed-on: http://gerrit.openafs.org/8372
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: call MIDL_user_allocate instead of calloc
Jeffrey Altman [Tue, 6 Nov 2012 11:39:39 +0000]
Windows: call MIDL_user_allocate instead of calloc

In the RPC service routines do not call calloc() directly.
All memory will be deallocated by a call to MIDL_user_free()
so use MIDL_user_allocate() to perform the allocation.

Modify MIDL_user_allocate() to call calloc() instead of malloc()
to ensure that the memory is initialized to NUL bytes.

Change-Id: I4d458bb5d8888c63040f213550d04f481e98175b
Reviewed-on: http://gerrit.openafs.org/8365
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: no more _wcsdup; use wcsdup
Jeffrey Altman [Tue, 6 Nov 2012 11:38:14 +0000]
Windows: no more _wcsdup; use wcsdup

_wcsdup is not mapped by roken.h.  Use wcsdup which is.

Change-Id: I0f6bb3f5465c74ad52f992892fcbc9837c276c0c
Reviewed-on: http://gerrit.openafs.org/8364
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoCatch up to FreeBSD non-MPSAFE deorbit
Ben Kaduk [Wed, 7 Nov 2012 15:08:33 +0000]
Catch up to FreeBSD non-MPSAFE deorbit

All filesystems must have their own locking now.
We have been MPSAFE for quite some time, but the preprocessor macro
"MPSAFE" has been removed and we must catch up in order to compile.

The MNTK_MPSAFE macro has not yet been removed, but it is toothless
now, so we can preemptively stop using it.

Change-Id: I9d9090fd1afc020670a0cf874baacf483fd34915
Reviewed-on: http://gerrit.openafs.org/8366
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoopr: Add Windows stuff for dict.c/h
Simon Wilkinson [Thu, 1 Nov 2012 20:42:58 +0000]
opr: Add Windows stuff for dict.c/h

The NTMakefile changes were omitted from the patch which added
opr/dict.h for Unix. Add them here.

Change-Id: I240b40116aed83dcf232a1d741d0ef7b442bf6f7
Reviewed-on: http://gerrit.openafs.org/8358
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Use MountRoot for Absolute Symlinks
Jeffrey Altman [Thu, 1 Nov 2012 00:59:30 +0000]
Windows: Use MountRoot for Absolute Symlinks

Replace the absolute symlink processing in AFSLocateName().
Implement AFSIsAbsoluteAFSName() to test whether or not the
path is in fact an absolute /afs path by comparing the input
string to the registry MountRoot value which specifies the
case sensitive root path for all absolute symlinks stored
in the AFS cell.

If a symlink target path begins with a directory separator
and is not an absolute afs path name, return an error.

Construct the substitution string using the target path
without the MountRoot prefix.

Add functionality to AFSRedir.sys to read the MountRoot
from the registry and pass it on to AFSRedirLib.sys.

Change-Id: Ie1df24da1e6de257c73dc34c80a75288bad47d29
Reviewed-on: http://gerrit.openafs.org/8353
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoconfigure: check for poll()
Derrick Brashear [Thu, 1 Nov 2012 18:15:27 +0000]
configure: check for poll()

if we have code which uses HAVE_POLL, check for poll().

Change-Id: I1baf61541b243f82b3acca112db2cbbca813182b
Reviewed-on: http://gerrit.openafs.org/8357
Reviewed-by: Chaskiel Grundman <cg2v@andrew.cmu.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoopr: Add dictionary implementation
Simon Wilkinson [Tue, 30 Oct 2012 11:25:02 +0000]
opr: Add dictionary implementation

Add a simple implementation of a dictionary/hash structure based around
opr queues and the jhash hashing function.

Change-Id: I4ae5cafcef377b05c8caa7c455737a992b1d36cd
Reviewed-on: http://gerrit.openafs.org/8355
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoopr: Add opr_jhash_int2 function
Simon Wilkinson [Mon, 29 Oct 2012 19:02:03 +0000]
opr: Add opr_jhash_int2 function

Add a function to jhash that can be used to hash a pair of unsigned
integers (or other stuff that can cast to them) without having to build
up an array.

Provide a couple of tests for the new function

Change-Id: I594848f64316fb459eff565933691f560512ca79
Reviewed-on: http://gerrit.openafs.org/8354
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agotests: Fix fallout from cleanup change
Simon Wilkinson [Thu, 1 Nov 2012 17:38:45 +0000]
tests: Fix fallout from cleanup change

The change to cleanup temporary files after tests
(0c3670914a05c7aa33f0b1239ba9cc25f430ed04) broke all attempts
to run the tests using libwrap, as it would cause libwrap to run
the binary named "MAKECHECK=1"

Move the variable defintion before the libwrap invocation to fix this.

Change-Id: I330267c9b53483abccf43d60a7dc8f8d973c3959
Reviewed-on: http://gerrit.openafs.org/8356
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoWindows: cm_ConnByServer increment under lock
Jeffrey Altman [Wed, 31 Oct 2012 16:04:50 +0000]
Windows: cm_ConnByServer increment under lock

Incrementing the cm_conn.refCount must be performed while holding
the cm_connLock in order to prevent cm_GCConnections() from
seeing an in-use object as having a zero count.

Change-Id: Ifaa755ef0f04f3bf64223434dfc518bc73d01d4d
Reviewed-on: http://gerrit.openafs.org/8347
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: cm_FindVolumeByName refactoring
Jeffrey Altman [Wed, 31 Oct 2012 13:53:57 +0000]
Windows: cm_FindVolumeByName refactoring

The cm_volume allocation within cm_FindVolumeByName() was racy.
Given how locks were obtained and dropped it was possible for two
threads to both determine that a cm_volume_t object needed to be
allocated.  It might even have been possible for two threads to
attempt to allocate the same object.

This refactoring ensures that if a volume cannot be found under
a read lock that a second search is performed under the write lock
in case the object had in fact been allocated during the transition.

Once it is determined that an allocation is required, the cm_volumeLock
is not dropped until the object has been built and inserted into the
name hash table.   This ensures that two threads cannot attempt to
allocate a cm_volume object for the same volume group.

InterlockedIncrement is used to manage the cm_data volume count.

Change-Id: I64c07cbc0f7968c5580478ff33214f67088072f8
Reviewed-on: http://gerrit.openafs.org/8346
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: use cm_GetVolume / cm_PutVolume
Jeffrey Altman [Wed, 31 Oct 2012 13:52:23 +0000]
Windows: use cm_GetVolume / cm_PutVolume

Instead of locally incrementing and decrementing the cm_volume
refCount field use cm_GetVolume and cm_PutVolume.  Doing so makes
it easier to see if there is an imbalance.

Change-Id: Id62e42a74a9b1d9865a00dae177550a93e6e0f08
Reviewed-on: http://gerrit.openafs.org/8345
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Interlocked ops for cell and scache allocation
Jeffrey Altman [Wed, 31 Oct 2012 13:50:34 +0000]
Windows: Interlocked ops for cell and scache allocation

Replace foo++ with InterlockedIncrement for cm_data cell and scache
counters which are used for allocating objects.

Change-Id: I09d2a536ef559d6d5873a3fdead4c8580bc93a0c
Reviewed-on: http://gerrit.openafs.org/8344
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agoWindows: Do not flush dirty bufs to deleted FID
Jeffrey Altman [Wed, 31 Oct 2012 01:54:20 +0000]
Windows: Do not flush dirty bufs to deleted FID

If the FID is known to have been deleted, drop all dirty data
returned from the redirector on the floor.

Change-Id: I8b9a1a69d632d7243bdbcfedb5329558e0004d2e
Reviewed-on: http://gerrit.openafs.org/8343
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

7 years agolinux: bypass readpages should update nocache read parms
Hartmut Reuter [Thu, 18 Oct 2012 13:38:50 +0000]
linux: bypass readpages should update nocache read parms

the nocache read parms need to have the offset updated during a bypass
readpages request

Change-Id: Iced321e6eeab7fd784c5ccb871fcda7ff9c7493d
Reviewed-on: http://gerrit.openafs.org/8254
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>

7 years agoptserver: Avoid inet_ntoa
Andrew Deason [Tue, 23 Oct 2012 20:47:06 +0000]
ptserver: Avoid inet_ntoa

The ptserver uses inet_ntoa in a few places, such as for calculating
host CPS. This isn't safe in pthreaded environments, so use
afs_inet_ntoa_r instead.

Change-Id: I84cdf606ffd44d2d87c0db509af0950a6547364e
Reviewed-on: http://gerrit.openafs.org/8287
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoFix mutex assertion
Simon Wilkinson [Sun, 21 Oct 2012 19:07:44 +0000]
Fix mutex assertion

RX mutexes have two mechanisms for asserting ownership of a mutex:
MUTEX_ISMINE, which returns true if the caller is the owner of the
mutex in question, and osirx_AssertMutex which fires an assertion if
the calling thread doesn't own a specified mutex.

Neither of these work with pthread mutexes on all platforms, and the
kernel support for MUTEX_ISMINE is dubious in places. Because in some
implementations, MUTEX_ISMINE tries to lock the mutex in question, a
failing call to MUTEX_ISMINE can lead to the process holding an
additional, unexpected, lock.

This patch reworks all of this, and uses the new opr mutex framework
so that we can do mutex assertions in userspace, too. We remove the
unsafe MUTEX_ISMINE macro, and replace it with MUTEX_ASSERT which
simply asserts if the specified mutex is not held by the current
thread. osirx_AssertMutex is removed as it is now redundant.
MUTEX_ASSERT will always work in kernel code.

For userspace, we provide opr_mutex_assert, which is implemented using
POSIX error checking mutexes. As error checking mutexes have a runtime
overhead, this is only available when configured with
--enable-debug-locks, the rest of the time calls to opr_mutex_assert are
no-ops.

Change-Id: I285ee2b558389fa3d63b786e4bc4420fa2126c80
Reviewed-on: http://gerrit.openafs.org/8282
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: Move kernel assertion macros
Simon Wilkinson [Sun, 21 Oct 2012 20:19:40 +0000]
rx: Move kernel assertion macros

Move the kernel assertion macros out of rx_prototypes.h and into
rx_kernel.h. This solves an ordering problem if these macros are to
be used from src/rx/<arch>/*.h

Change-Id: I5f11e0802b3d25c1c32a2c646a35c0b59422ab3d
Reviewed-on: http://gerrit.openafs.org/8283
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agotests: cleanup temporary files
Marc Dionne [Wed, 19 Sep 2012 23:14:31 +0000]
tests: cleanup temporary files

Call the configuration directory cleanup function before exiting
so there are no files left behind, even in case of error.

Add KeyFileExt to the list of files that are removed.

Change-Id: Ie795bef0d44609b36950970244c02a6c6da1a843
Reviewed-on: http://gerrit.openafs.org/8142
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agolinux: fix cache bypass applicability function
Hartmut Reuter [Thu, 18 Oct 2012 11:00:18 +0000]
linux: fix cache bypass applicability function

don't allow cache bypass if execsOrWriters is true

don't trigger cache bypass based on being larger than the
"disabled" value of -1.

Change-Id: Ic174b133e5da3e9215465c9c2705c25e81a8beca
Reviewed-on: http://gerrit.openafs.org/8248
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoLinux: remove unused afs_set_name inline functions
Marc Dionne [Mon, 29 Oct 2012 23:11:23 +0000]
Linux: remove unused afs_set_name inline functions

These were used in an earlier version of the patch that got merged.

Change-Id: Ifc5ba94392a394d0fb55c31051b4b74211cfc1f0
Reviewed-on: http://gerrit.openafs.org/8332
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agoAdd opr/lock.h and tidy locking macros
Simon Wilkinson [Sat, 20 Oct 2012 22:14:41 +0000]
Add opr/lock.h and tidy locking macros

The MUTEX_* and CV_* macros leaked from RX a while ago - they mean
that most of the pthreaded tree has a dependency on RX, as well as
further confusing the difference between userspace and kernel.

Tidy all of this up so that we have opr_mutex_* and opr_cv_* macros
to handle portable locking, and use these throughout the userspace
tree. Only kernel code should now use MUTEX_* and CV_*.

Provide opr/lockstub.h as a header that can be used by non-pthreaded
code to easily stub out these functions.

Change-Id: I24be525c7667641134d50561ce7f1e2d752cdf1f
Reviewed-on: http://gerrit.openafs.org/8280
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

7 years agorx: Move transmit queue clearing
Simon Wilkinson [Fri, 26 Oct 2012 14:37:52 +0000]
rx: Move transmit queue clearing

When the client receives a data packet from the server, it means that
the server has completed processing the client's request. This, in turn,
implies that the transmit queue can be cleared. However, we were doing
this with every incoming data packet.

Move the transmit queue clearing to the code which handles the rest of
the data packet, and make the function only run if the transmit queue
is non-empty.

Now that there's no client specific logic in the ReceiveCall section,
clean up this code to reduce duplication.

Change-Id: Ia4f9024720c676cbcc6d8426d4b94a0acded20bc
Reviewed-on: http://gerrit.openafs.org/8301
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agorx: Refactor code to acknowledge a whole TX queue
Simon Wilkinson [Fri, 26 Oct 2012 14:23:48 +0000]
rx: Refactor code to acknowledge a whole TX queue

We acknowledge a whole transmit queue whenever an ACKALL packet is
received, or whenever the call changes direction. As the same logic
is used in both locations, pull it out into a common helper function.

Change-Id: Ia91b037c73cc0dd612ebbd0bd38ec171ec7c96a5
Reviewed-on: http://gerrit.openafs.org/8300
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>