Commit Graph

3022 Commits

Author SHA1 Message Date
Asanka Herath
14408c7e88 windows-byte-range-locks-20050816
Byte range locks:

   The OpenAFS Windows client has to fake byte range locks given no
   server side support for such locks.  This is implemented as keyed
   byte range locks on the cache manager.

   Keyed byte range locks:

   Each cm_scache_t structure keeps track of a list of keyed locks.
   The key for a lock is essentially a token which identifies an owner
   of a set of locks (referred to as a client).  The set of keys used
   within a specific cm_scache_t structure form a namespace that has a
   scope of just that cm_scache_t structure.  The same key value can
   be used with another cm_scache_t structure and correspond to a
   completely different client.  However it is advantageous for the
   SMB or IFS layer to make sure that there is a 1-1 mapping between
   client and keys irrespective of the cm_scache_t.

   Assume a client C has key Key(C) (although, since the scope of the
   key is a cm_scache_t, the key can be Key(C,S), where S is the
   cm_scache_t.  But assume a 1-1 relation between keys and clients).
   A byte range (O,+L) denotes byte addresses (O) through (O+L-1)
   inclusive (a.k.a. [O,O+L-1]).  The function Key(x) is implemented
   through cm_generateKey() function for both SMB and IFS.

   The cache manager will set a lock on the AFS file server in order
   to assert the locks in S->fileLocks.  If only shared locks are in
   place for S, then the cache manager will obtain a LockRead lock,
   while if there are any exclusive locks, it will obtain a LockWrite
   lock.  If the exclusive locks are all released while the shared
   locks remain, then the cache manager will downgrade the lock from
   LockWrite to LockRead.

   Lock states:

   A lock exists iff it is in S->fileLocks for some cm_scache_t
   S. Existing locks are in one of the following states: ACTIVE,
   WAITLOCK, WAITUNLOCK, LOST, DELETED.

   The following sections describe each lock and the associated
   transitions.

   1. ACTIVE: A lock L is ACTIVE iff the cache manager has asserted
      the lock with the AFS file server.  This type of lock can be
      exercised by a client to read or write to the locked region (as
      the lock allows).

      1.1 ACTIVE->LOST: When the AFS file server fails to extend a
        server lock that was required to assert the lock.

      1.2 ACTIVE->DELETED: Lock is released.

   2. WAITLOCK: A lock is in a WAITLOCK state if the cache manager
      grants the lock but the lock is yet to be asserted with the AFS
      file server.  Once the file server grants the lock, the state
      will transition to an ACTIVE lock.

      2.1 WAITLOCK->ACTIVE: The server granted the lock.

      2.2 WAITLOCK->DELETED: Lock is abandoned, or timed out during
        waiting.

      2.3 WAITLOCK->LOST: One or more locks from this client were
        marked as LOST.  No further locks will be granted to this
        client until al lost locks are removed.

   3. WAITUNLOCK: A lock is in a WAITUNLOCK state if the cache manager
      receives a request for a lock that conflicts with an existing
      ACTIVE or WAITLOCK lock.  The lock will be placed in the queue
      and will be granted at such time the conflicting locks are
      removed, at which point the state will transition to either
      WAITLOCK or ACTIVE.

      3.1 WAITUNLOCK->ACTIVE: The conflicting lock was removed.  The
        current serverLock is sufficient to assert this lock, or a
        sufficient serverLock is obtained.

      3.2 WAITUNLOCK->WAITLOCK: The conflicting lock was removed,
        however the required serverLock is yet to be asserted with the
        server.

      3.3 WAITUNLOCK->DELETED: The lock is abandoned or timed out.

      3.5 WAITUNLOCK->LOST: One or more locks from this client were
        marked as LOST.  No further locks will be granted to this
        client until all lost locks are removed.

   4. LOST: A lock L is LOST if the server lock that was required to
      assert the lock could not be obtained or if it could not be
      extended, or if other locks by the same client were LOST.
      Effectively, once a lock is LOST, the contract between the cache
      manager and that specific client is no longer valid.

      The cache manager rechecks the server lock once every minute and
      extends it as appropriate.  If this is not done for 5 minutes,
      the AFS file server will release the lock.  Once released, the
      lock cannot be re-obtained without verifying that the contents
      of the file hasn't been modified since the time the lock was
      released.  Doing so may cause data corruption.

      4.1 LOST->DELETED: The lock is released.

      4.2 LOST->ACTIVE: The lock is reassertd.  This requires
        verifying that the file was not modified in between.

      4.3 LOST->WAITLOCK: All LOST ACTIVE locks from this client were
        reasserted.  The cache manager can reinstate this waiting
        lock.

      4.4 LOST->WAITUNLOCK: All LOST ACTIVE locks from this client
        were reasserted.  The cache manager can reinstate this waiting
        lock.

   5. DELETED: The lock is no longer relevant.  Eventually, it will
      get removed from the cm_scache_t. In the meantime, it will be
      treated as if it does not exist.

      5.1 DELETED->not exist: The lock is removed from the
        cm_scache_t.

   6* A lock L is ACCEPTED if it is ACTIVE or WAITLOCK.
      These locks have been accepted by the cache manager, but may or
      may not have been granted back to the client.

   7* A lock L is QUEUED if it is ACTIVE, WAITLOCK or WAITUNLOCK.

   8* A lock L is EFFECTIVE if it is ACTIVE or LOST.

   9* A lock L is WAITING if it is WAITLOCK or WAITUNLOCK.

   Lock operation:

   A client C can READ range (Offset,+Length) of cm_scache_t S iff:

   1. for all _a_ in (Offset,+Length), one of the following is true:

       1.1 There does NOT exist an ACTIVE lock L in S->fileLocks such
         that _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_ of S is
         unowned)

         AND

         For each LOST lock M in S->fileLocks such that
         _a_ in (M->LOffset,+M->LLength), M->LockType is shared AND
         M->key != Key(C).

         (Note: If this is a different client from one whose shared
         lock was LOST, then the contract between this client and the
         cache manager is indistinguishable from that where no lock
         was lost.  If an exclusive lock was lost, then the range is
         considered unsafe for consumption.)

       1.3 There is an ACTIVE lock L in S->fileLocks such that: L->key
         == Key(C) && _a_ in (L->LOffset,+L->LLength) (IOW: byte _a_
         of S is owned by C under lock L)

       1.4 There is an ACTIVE lock L in S->fileLocks such that _a_ in
         (L->LOffset,L->+LLength) && L->LockType is shared (IOW: byte
         _a_ of S is shared) AND there is no LOST lock M such that _a_
         in (M->LOffset,+M->LLength) and M->key == Key(C)

   A client C can WRITE range (Offset,+Length) of cm_scache_t S iff:

   2. for all _a_ in (Offset,+Length), one of the following is true:

       2.1 Byte _a_ of S is unowned (as above) AND for each LOST lock
         L in S->fileLocks _a_ NOT in (L->LOffset,+L->LLength).

       2.2 Byte _a_ of S is owned by C under lock L (as above) AND
         L->LockType is exclusive.

   A client C can OBTAIN a lock L on cm_scache_t S iff:

   3. for all _a_ in (L->LOffset,+L->LLength), ALL of the following is
      true:

       3.1 L->LockType is exclusive IMPLIES there does NOT exist a QUEUED lock
         M in S->fileLocks such that _a_ in (M->LOffset,+M->LLength).

         (Note: If we count all QUEUED locks then we hit cases such as
         cascading waiting locks where the locks later on in the queue
         can be granted without compromising file integrity.  On the
         other hand if only ACCEPTED locks are considered, then locks
         that were received earlier may end up waiting for locks that
         were received later to be unlocked. The choice of QUEUED
         locks were made so that large locks don't consistently get
         trumped by smaller locks which were requested later.)

       3.2 L->LockType is shared IMPLIES for each QUEUED lock M in
         S->fileLocks, if _a_ in (M->LOffset,+M->LLength) then
         M->LockType is shared.

   4. For each LOST lock M in S->fileLocks, M->key != Key(C)

         (Note: If a client loses a lock, it loses all locks.
         Subsequently, it will not be allowed to obtain any more locks
         until all existing LOST locks that belong to the client are
         released.  Once all locks are released by a single client,
         there exists no further contract between the client and AFS
         about the contents of the file, hence the client can then
         proceed to obtain new locks and establish a new contract.)

   A client C can only unlock locks L in S->fileLocks which have
   L->key == Key(C).

   The representation and invariants are as follows:

   - Each cm_scache_t structure keeps:

       - A queue of byte-range locks (cm_scache_t::fileLocks) which
         are of type cm_file_lock_t.

       - A record of the highest server-side lock that has been
         obtained for this object (cm_scache_t::serverLock), which is
         one of (-1), LockRead, LockWrite.

       - A count of ACCEPTED exclusive and shared locks that are in the
         queue (cm_scache_t::sharedLocks and
         cm_scache_t::exclusiveLocks)

   - Each cm_file_lock_t structure keeps:

       - The type of lock (cm_file_lock_t::LockType)

       - The key associated with the lock (cm_file_lock_t::key)

       - The offset and length of the lock (cm_file_lock_t::LOffset
         and cm_file_lock_t::LLength)

       - The state of the lock.

       - Time of issuance or last successful extension

   Semantic invariants:

       I1. The number of ACCEPTED locks in S->fileLocks are
           (S->sharedLocks + S->exclusiveLocks)

   External invariants:

       I3. S->serverLock is the lock that we have asserted with the
           AFS file server for this cm_scache_t.

       I4. S->serverLock == LockRead iff there is at least one ACTIVE
           shared lock, but no ACTIVE exclusive locks.

       I5. S->serverLock == LockWrite iff there is at least one ACTIVE
           exclusive lock.

       I6. If a WAITUNLOCK lock L exists in S->fileLocks, then all
           locks that L is waiting on are ahead of L in S->fileLocks.

       I7. If L is a LOST lock, then for each lock M in S->fileLocks,
           M->key == L->key IMPLIES M is LOST or DELETED.

   --asanka

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

Byte range locks added to change list

====================

should improve error codes, and allow lock promotions and demotions
by releasing locks.

====================

More improvements to the byte range locking.  Handle errors caused
by a failure to have locking privs; report sharing violations when
opening files; lie about locks on read-only volumes; implement
shared read/write file creation in the smb layer.

====================

remove assertion

====================

must reference count local references to objects if the lock
is being released

====================

Do not use a variable until you assign it a value

====================

remove an unwanted assertion and move the resetting of scp->serverLock
to -1 into cm_LockMarkSCacheLost() so that others do not forget to set
it.  cm_LockMarkSCacheLost() is always called when the scp->mx is held
so it is ok to do so.
2005-08-16 17:17:13 +00:00
Jim Rees
a09b27d0a0 openbsd-pthread-20050815
Build pthread servers for OpenBSD.
There is some evidence they might even work.
2005-08-15 23:30:47 +00:00
Jim Rees
cdb51cf261 automate-freebsd-systype-20050815
Determine freebsd systype automatically too.
Thanks to "Todd T. Fries" <todd@fries.net>
2005-08-15 21:36:53 +00:00
Jeffrey Altman
fab147e843 afssyscalls-declarations-20050815
declare lsetpag() and lpioctl() since they are exported
2005-08-15 18:35:05 +00:00
Jeffrey Altman
eb00f91374 windows-smb-error-codes-20050815
Do not return error codes from the SMB/CIFS server that can be interpretted
by the SMB/CIFS client as meaning that the AFS Client Service is not
available.
2005-08-15 18:27:52 +00:00
Klas Lindfors
1b0b0945ca vos-format-cleanup-20050815
FIXES 20783

make sure partition name actually gets printed
2005-08-15 16:54:50 +00:00
Niklas Edmundsson
e4ca2e597c aix-afsdb-20050815
FIXES 20801

make afsdb work on aix.
use storage as thread-local when it is
2005-08-15 16:51:29 +00:00
Chas Williams
e0d9e434bb put-inode-speedup-20050815
FIXES 20820

don't bother with credp
2005-08-15 16:47:38 +00:00
Chas Williams
bbe7880568 large-cache-fix-20050815
FIXES 20821

make large caches actually work
2005-08-15 16:39:51 +00:00
Tom Keiser
45d144da14 aix-make-install-20050815
FIXES 20827

make install was broken on aix. fix it.
2005-08-15 16:04:12 +00:00
Jeffrey Altman
7c34c9b5c0 windows-afscreds-20050814
When tokens expire, do not display an obtain tokens dialog if there
is no network connectivity to the kdc for the realm associated with
the cell.

In the en_US build, stop displaying the expiration time of tokens
after the tokens expire.
2005-08-14 12:25:06 +00:00
Jeffrey Altman
50c5210a25 audit-fetchacl-20050813
Include the ACL value in the FetchACL logging.  This combined with
StoreACL can be used to compute ACL changes.
2005-08-14 03:10:07 +00:00
Todd Fries
8ea5ed2c2b auto-obsd-version-20050813
Determine openbsd version automatically.
2005-08-13 21:49:00 +00:00
Jim Rees
c8db31cc2b openbsd38-20050812
With thanks to "Todd T. Fries" <todd@fries.net>
OpenBSD 3.8.
Introduce HAVE_STRCASESTR.
2005-08-12 22:26:09 +00:00
Russ Allbery
467a85164c linux-pic-everywhere-20050811
FIXES 20781

Build shared libraries with -fPIC on all Linux platforms, not just the ones
that absolutely require it.
2005-08-11 18:55:50 +00:00
Chas Williams
c9b0955360 refrigerator-20050809
FIXES 20728

refrigerator takes void starting in 2.6.13
2005-08-10 20:21:27 +00:00
David Thompson
42e081360e vos-ctime-fix-20050809
FIXES 20748

fix larger than 4 byte ctime case
2005-08-09 19:39:26 +00:00
Chas Williams
0c931ef444 linux26-umount-force-doesnt-work-20050809
this was never finished, just revoke it for now
2005-08-09 14:41:13 +00:00
Derrick Brashear
5740865dce logthreadnum-libafsauthent-20050808
FIXES 20412

export LogThreadNum so hings can link our libraries again
2005-08-08 16:37:28 +00:00
Derrick Brashear
3e9c1b1f1a revert-linux-write-dirty-pages-once-20050802
this needs to be revisited
2005-08-08 16:04:10 +00:00
Chas Williams
9485ca85d3 linux-panic-20050727
FIXES 20392

just call panic() on linux

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================
FIXES 20392

call BUG() instead
2005-08-08 15:58:32 +00:00
Jeffrey Altman
7e95d1bc89 windows-notes-20050806
updates for 1.3.8700
2005-08-06 01:38:53 +00:00
Jeffrey Altman
520d3143e6 windows-version-20050806
1.3.8700
2005-08-06 01:37:13 +00:00
Jeffrey Altman
4d0a6e73bf windows-afscache-validate-20050806
Ensure that queues that have forward and reverse pointers are
consistent that either both are NULL or neither are.
2005-08-06 01:34:50 +00:00
Rainer Toebbicke
c264965a63 client-omit-zero-length-reads-20050804
The attached patch restores the behaviour of the 1.2.x client: writes
appending to a file do not trigger a 0-length read which at best updates the
current status. If another cache manager wrote to the same file in the
meantime, the file status is updated only after the StoreData RPC (and for
the changes the last one wins).
2005-08-04 21:44:57 +00:00
Horst Birthelmer
b607770bc5 checkservers-set-back-deadtime-correctly-20050804
the multirx version of this does this wrong. fix it.
2005-08-04 21:03:53 +00:00
Derrick Brashear
67f1537746 revert-cache-size-limit-upping-20050728
let's re-examine this
2005-08-04 20:53:30 +00:00
Rainer Toebbicke
1775474656 client-omit-zero-length-reads-20050804
The attached patch restores the behaviour of the 1.2.x client: writes
appending to a file do not trigger a 0-length read which at best updates the
current status. If another cache manager wrote to the same file in the
meantime, the file status is updated only after the StoreData RPC (and for
the changes the last one wins).
2005-08-04 20:31:33 +00:00
Eric Williams
fc0ca363da windows-afsifs-20050804
addresses:
byte-range locks work (mildly tested)
fixes a reference counting error
can shutdown/restart client
code formatting
major speed improvements
fixes delete operation problem
internal locking in more places

i have reviewed this patch myself carefully.  specifically, please review
the changes to cm_buf.c and cm_callback.c.  in cm_buf, i added the looping
code because i ran into the following assert once.  i am not sure why, and
my attempt to diagnose the problem was not successful.

apart from the byte-range locking code, the code has not change for quite
a bit.
2005-08-04 17:32:32 +00:00
Jeffrey Altman
81b0f9cf1d windows-pioctl-update-20050804
change "fs wscell" to report the registry configured cell name when
using freelance mode.

change "fs mkmount|rmmount" to require membership in AFS Client Admins
group when freelance mode is being used

change "symlink make|remove" to require membership in AFS Client Admins
group when freelance mode is being used

Move some smb init debug messages to afsd_init.log
2005-08-04 17:03:50 +00:00
Rainer Toebbicke
1bdc4cea4b viced-dont-crash-on-link-enospc-20050803
when symlink gets ENOSPC don't assert.
2005-08-03 05:45:53 +00:00
Chaskiel M Grundman
f6ff3f769a linux-vnode-aliases-20050802
FIXES 18613

you can end up hanging when you end up with multiple aliases for a single direct
ory (dentry) as a result of @sys or multiple mountpoints.

don't end up with multiple aliases, and avoid the situation
2005-08-02 19:59:46 +00:00
Derrick Brashear
7ad3929e3c linux-fix-refrigerator-calls-20050802
it's CONFIG_PF, not CONFIG_PM
2005-08-02 15:03:42 +00:00
Chas Williams
893849bdca linux-4gb-32bit-file-fix-20050802
FIXCES 20560

fix wrapping error on page offset
2005-08-02 14:46:28 +00:00
Chas Williams
82b010d26a linux-group-putback-20050802
FIXES 20562

put back reference before discarding group pointer
2005-08-02 06:15:54 +00:00
Chas Williams
c893cf0e3d linux-write-dirty-pages-once-20050802
FIXES 20561

also done in afs_linux_write
2005-08-02 06:11:38 +00:00
Chas Williams
4778f1fc15 linux-4gb-32bit-file-fix-20050802
FIXCES 20560

fix wrapping error on page offset
2005-08-02 06:08:45 +00:00
Jim Rees
7c5dcc5d43 tq-uq-scope-20050731
Move local vars tq and uq back into proper scope
2005-07-31 18:22:50 +00:00
Chas Williams
f7b6f3022d linux-osi-vfs-mkdir-20050729
FIXES 20479

mkdir so this works when building outside our tree
2005-07-29 15:49:31 +00:00
Stefaan De Roeck
57bb8e09a3 audit-use-va-arg-20050729
FIXES 20311

use va_arg instead of int
2005-07-29 15:24:05 +00:00
Jeffrey Altman
2da4a84732 windows-doc-updates-20050728
updates for 1.3.8600
2005-07-28 23:15:50 +00:00
Jeffrey Altman
3d43d87010 windows-version-update-20050728
version number to 1.3.8600
2005-07-28 23:09:20 +00:00
Chas Williams
4fc48af834 vc-hashing-be-less-expensive-20050728
use an afs_q so this is less expensive to deal with
2005-07-28 15:38:36 +00:00
Derrick Brashear
459636211c cache-size-limit-upping-20050728
based on work from wes chow

allow larger caches without variable overflows.

does not port to 1.4 as-is.
2005-07-28 15:17:47 +00:00
Stefaan De Roeck
456462b314 audit-use-va-arg-20050726
FIXES 20311

use va_arg instead of int
2005-07-26 19:14:14 +00:00
Chas Williams
b58c1f103e linux-mmap-cleanup-20050726
FIXES 20391

avoid the vma close business, we don't need to do this to track maps
2005-07-26 18:39:00 +00:00
Chas Williams
a21fc56daf linux-reduce-stack-use-20050726
FIXES 20337

don't do pointless work in osi_NetSend, and save some stack
2005-07-26 18:34:05 +00:00
Jim Rees
575cbd4a2f openafs-sleep-20050726
tsleep on "afsslp" in afs_osi_Sleep
2005-07-26 16:25:43 +00:00
Chas Williams
eff25c1899 linux-largefile-fix-20050726
FIXES 20396

use the generic read/write functions, but set the superblock up correctly.

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================
FIXES 20396

make old 2.4 happy
2005-07-26 14:34:31 +00:00
Derrick Brashear
969a49f6d9 amd64-no-red-zone-20050725
why are we not -mno-red-zone here?
2005-07-28 22:50:01 +00:00