• David Howells's avatar
    afs: Further fix file locking · 4be5975a
    David Howells authored
    Further fix the file locking in the afs filesystem client in a number of
    ways, including:
    
     (1) Don't submit the operation to obtain a lock from the server in a work
         queue context, but rather do it in the process context of whoever
         issued the requesting system call.
    
     (2) The owner of the file_lock struct at the front of the pending_locks
         queue now owns right to talk to the server.
    
     (3) Write locks can be instantly granted if they don't overlap with any
         other locks *and* we have a write lock on the server.
    
     (4) In the event of an authentication/permission error, all other matching
         pending locks requests are also immediately aborted.
    
     (5) Properly use VFS core locks_lock_file_wait() to distribute the server
         lock amongst local client locks, including waiting for the lock to
         become available.
    
    Test with:
    
    	sqlite3 /afs/.../scratch/billings.sqlite <<EOF
    	CREATE TABLE hosts (
    	    hostname varchar(80),
    	    shorthost varchar(80),
    	    room varchar(30),
    	    building varchar(30),
    	    PRIMARY KEY(shorthost)
    	    );
    	EOF
    
    With the version of sqlite3 that I have, this should fail consistently with
    EAGAIN, whether or not the program is straced (which introduces some delays
    between lock syscalls).
    
    Fixes: 0fafdc9f ("afs: Fix file locking")
    Reported-by: default avatarJonathan Billings <jsbillin@umich.edu>
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    4be5975a
flock.c 19.2 KB