13 Aug, 2008

1 commit


26 Jul, 2008

2 commits

  • Use a special error value FILE_LOCK_DEFERRED to mean that a locking
    operation returned asynchronously. This is returned by

    posix_lock_file() for sleeping locks to mean that the lock has been
    queued on the block list, and will be woken up when it might become
    available and needs to be retried (either fl_lmops->fl_notify() is
    called or fl_wait is woken up).

    f_op->lock() to mean either the above, or that the filesystem will
    call back with fl_lmops->fl_grant() when the result of the locking
    operation is known. The filesystem can do this for sleeping as well
    as non-sleeping locks.

    This is to make sure, that return values of -EAGAIN and -EINPROGRESS by
    filesystems are not mistaken to mean an asynchronous locking.

    This also makes error handling in fs/locks.c and lockd/svclock.c slightly
    cleaner.

    Signed-off-by: Miklos Szeredi
    Cc: Trond Myklebust
    Cc: "J. Bruce Fields"
    Cc: Matthew Wilcox
    Cc: David Teigland
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Fix nlm_fopen() to return NLM_FAILED (or NLM_LCK_DENIED_NOLOCKS) instead
    of NLM_LCK_DENIED. The latter means the lock request failed because of a
    conflicting lock (i.e. a temporary error), which is wrong in this case.

    Also fix the client to return ENOLCK instead of EAGAIN if a blocking lock
    request returns with NLM_LOCK_DENIED.

    Signed-off-by: Miklos Szeredi
    Cc: Trond Myklebust
    Cc: "J. Bruce Fields"
    Cc: Matthew Wilcox
    Cc: David Teigland
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

23 Jul, 2008

1 commit

  • fs/lockd/svcproc.c:115:11: warning: incorrect type in initializer (different base types)
    fs/lockd/svcproc.c:115:11: expected int [signed] rc
    fs/lockd/svcproc.c:115:11: got restricted __be32 [usertype]
    ... and so on...

    Signed-off-by: Harvey Harrison
    Signed-off-by: Andrew Morton
    Signed-off-by: J. Bruce Fields

    Harvey Harrison
     

21 Jul, 2008

1 commit

  • * 'for-2.6.27' of git://linux-nfs.org/~bfields/linux: (51 commits)
    nfsd: nfs4xdr.c do-while is not a compound statement
    nfsd: Use C99 initializers in fs/nfsd/nfs4xdr.c
    lockd: Pass "struct sockaddr *" to new failover-by-IP function
    lockd: get host reference in nlmsvc_create_block() instead of callers
    lockd: minor svclock.c style fixes
    lockd: eliminate duplicate nlmsvc_lookup_host call from nlmsvc_lock
    lockd: eliminate duplicate nlmsvc_lookup_host call from nlmsvc_testlock
    lockd: nlm_release_host() checks for NULL, caller needn't
    file lock: reorder struct file_lock to save space on 64 bit builds
    nfsd: take file and mnt write in nfs4_upgrade_open
    nfsd: document open share bit tracking
    nfsd: tabulate nfs4 xdr encoding functions
    nfsd: dprint operation names
    svcrdma: Change WR context get/put to use the kmem cache
    svcrdma: Create a kmem cache for the WR contexts
    svcrdma: Add flush_scheduled_work to module exit function
    svcrdma: Limit ORD based on client's advertised IRD
    svcrdma: Remove unused wait q from svcrdma_xprt structure
    svcrdma: Remove unneeded spin locks from __svc_rdma_free
    svcrdma: Add dma map count and WARN_ON
    ...

    Linus Torvalds
     

16 Jul, 2008

8 commits

  • Push it into those callback functions that actually need it.

    Note that all the NFS operations use their own locking, so don't need the
    BKL. Ditto for the rpcbind client.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • fcntl(F_GETLK) on an nfs client incorrectly returns
    the values for the conflicting lock. fl_len value is
    always 1.
    If the conflicting lock is (0, 4095) the F_GETLK
    request for (1024, 10) returns (0, 1), which doesn't
    even cover the requested range, and is quite confusing.
    The fix is trivial, set fl_end from the fl_end value
    recieved from the nfs server.

    Signed-off-by: Felix Blyakher
    Signed-off-by: "J. Bruce Fields"
    Signed-off-by: Trond Myklebust

    Felix Blyakher
     
  • Pass a more generic socket address type to nlmsvc_unlock_all_by_ip() to
    allow for future support of IPv6. Also provide additional sanity
    checking in failover_unlock_ip() when constructing the server's IP
    address.

    As an added bonus, provide clean kerneldoc comments on related NLM
    interfaces which were recently added.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • It may not be obvious (till you look at the definition of
    nlm_alloc_call()) that a function like nlmsvc_create_block() should
    consume a reference on success or failure, so I find it clearer if it
    takes the reference it needs itself.

    And both callers already do this immediately before the call anyway.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • nlmsvc_lock calls nlmsvc_lookup_host to find a nlm_host struct. The
    callers of this function, however, call nlmsvc_retrieve_args or
    nlm4svc_retrieve_args, which also return a nlm_host struct.

    Change nlmsvc_lock to take a host arg instead of calling
    nlmsvc_lookup_host itself and change the callers to pass a pointer to
    the nlm_host they've already found.

    Since nlmsvc_testlock() now just uses the caller's reference, we no
    longer need to get or release it.

    Signed-off-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     
  • nlmsvc_testlock calls nlmsvc_lookup_host to find a nlm_host struct. The
    callers of this functions, however, call nlmsvc_retrieve_args or
    nlm4svc_retrieve_args, which also return a nlm_host struct.

    Change nlmsvc_testlock to take a host arg instead of calling
    nlmsvc_lookup_host itself and change the callers to pass a pointer to
    the nlm_host they've already found.

    We take a reference to host in the place where nlmsvc_testlock()
    previous did a new lookup, so the reference counting is unchanged from
    before.

    Signed-off-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     
  • No need to check for a NULL argument twice.

    Signed-off-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     

24 Jun, 2008

1 commit


30 Apr, 2008

1 commit


26 Apr, 2008

3 commits

  • The file_lock structure is used both as a heavy-weight representation of
    an active lock, with pointers to reference-counted structures, etc., and
    as a simple container for parameters that describe a file lock.

    The conflicting lock returned from __posix_lock_file is an example of
    the latter; so don't call the filesystem or lock manager callbacks when
    copying to it. This also saves the need for an unnecessary
    locks_init_lock in the nfsv4 server.

    Thanks to Trond for pointing out the error.

    Signed-off-by: J. Bruce Fields
    Cc: Trond Myklebust

    J. Bruce Fields
     
  • Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.:

    shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem

    so that a filesystem can be unmounted before allowing a peer nfsd to
    take over nfs service for the filesystem.

    Signed-off-by: S. Wendy Cheng
    Cc: Lon Hohberger
    Cc: Christoph Hellwig
    Signed-off-by: J. Bruce Fields

    fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++-----
    fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++
    include/linux/lockd/lockd.h | 7 ++++
    3 files changed, 131 insertions(+), 7 deletions(-)

    Wendy Cheng
     
  • For high-availability NFS service, we generally need to be able to drop
    file locks held on the exported filesystem before moving clients to a
    new server. Currently the only way to do that is by shutting down lockd
    entirely, which is often undesireable (for example, if you want to
    continue exporting other filesystems).

    This patch allows the administrator to release all locks held by clients
    accessing the client through a given server ip address, by echoing that
    address to a new file, /proc/fs/nfsd/unlock_ip, as in:

    shell> echo 10.1.1.2 > /proc/fs/nfsd/unlock_ip

    The expected sequence of events can be:
    1. Tear down the IP address
    2. Unexport the path
    3. Write IP to /proc/fs/nfsd/unlock_ip to unlock files
    4. Signal peer to begin take-over.

    For now we only support IPv4 addresses and NFSv2/v3 (NFSv4 locks are not
    affected).

    Also, if unmounting the filesystem is required, we assume at step 3 that
    clients using the given server ip are the only clients holding locks on
    the given filesystem; otherwise, an additional patch is required to
    allow revoking all locks held by lockd on a given filesystem.

    Signed-off-by: S. Wendy Cheng
    Cc: Lon Hohberger
    Cc: Christoph Hellwig
    Signed-off-by: J. Bruce Fields

    fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++-----
    fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++
    include/linux/lockd/lockd.h | 7 ++++
    3 files changed, 131 insertions(+), 7 deletions(-)

    Wendy Cheng
     

25 Apr, 2008

1 commit

  • * git://git.linux-nfs.org/projects/trondmy/nfs-2.6: (80 commits)
    SUNRPC: Invalidate the RPCSEC_GSS session if the server dropped the request
    make nfs_automount_list static
    NFS: remove duplicate flags assignment from nfs_validate_mount_data
    NFS - fix potential NULL pointer dereference v2
    SUNRPC: Don't change the RPCSEC_GSS context on a credential that is in use
    SUNRPC: Fix a race in gss_refresh_upcall()
    SUNRPC: Don't disconnect more than once if retransmitting NFSv4 requests
    SUNRPC: Remove the unused export of xprt_force_disconnect
    SUNRPC: remove XS_SENDMSG_RETRY
    SUNRPC: Protect creds against early garbage collection
    NFSv4: Attempt to use machine credentials in SETCLIENTID calls
    NFSv4: Reintroduce machine creds
    NFSv4: Don't use cred->cr_ops->cr_name in nfs4_proc_setclientid()
    nfs: fix printout of multiword bitfields
    nfs: return negative error value from nfs{,4}_stat_to_errno
    NLM/lockd: Ensure client locking calls use correct credentials
    NFS: Remove the buggy lock-if-signalled case from do_setlk()
    NLM/lockd: Fix a race when cancelling a blocking lock
    NLM/lockd: Ensure that nlmclnt_cancel() returns results of the CANCEL call
    NLM: Remove the signal masking in nlmclnt_proc/nlmclnt_cancel
    ...

    Linus Torvalds
     

24 Apr, 2008

8 commits

  • When svc_recv returns an unexpected error, lockd will print a warning
    and exit. This problematic for several reasons. In particular, it will
    cause the reference counts for the thread to be wrong, and can lead to a
    potential BUG() call.

    Rather than exiting on error from svc_recv, have the thread do a 1s
    sleep and then retry the loop. This is unlikely to cause any harm, and
    if the error turns out to be something temporary then it may be able to
    recover.

    Signed-off-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     
  • As of 5996a298da43a03081e9ba2116983d173001c862 ("NLM: don't unlock on
    cancel requests") we no longer unlock in this case, so the comment is no
    longer accurate.

    Thanks to Stuart Friedberg for pointing out the inconsistency.

    Cc: Stuart Friedberg
    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • There's no reason for a mutex here, except to allow an allocation under
    the lock, which we can avoid with the usual trick of preallocating
    memory for the new object and freeing it if it turns out to be
    unnecessary.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • Use list_for_each_entry(). Also, in keeping with kernel style, make the
    normal case (kzalloc succeeds) unindented and handle the abnormal case
    with a goto.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • The sm_count is decremented to zero but left on the nsm_handles list.
    So in the space between decrementing sm_count and acquiring nsm_mutex,
    it is possible for another task to find this nsm_handle, increment the
    use count and then enter nsm_release itself.

    Thus there's nothing to prevent the nsm being freed before we acquire
    nsm_mutex here.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • fs/lockd/svcshare.c:74:50: warning: Using plain integer as NULL pointer

    Signed-off-by: Harvey Harrison
    Cc: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: J. Bruce Fields

    Harvey Harrison
     
  • Have lockd_up start lockd using kthread_run. With this change,
    lockd_down now blocks until lockd actually exits, so there's no longer
    need for the waitqueue code at the end of lockd_down. This also means
    that only one lockd can be running at a time which simplifies the code
    within lockd's main loop.

    This also adds a check for kthread_should_stop in the main loop of
    nlmsvc_retry_blocked and after that function returns. There's no sense
    continuing to retry blocks if lockd is coming down anyway.

    Signed-off-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     
  • Lockd caches information about hosts that have recently held locks to
    expedite the taking of further locks.

    It periodically discards this information for hosts that have not been
    used for a few minutes.

    lockd currently has a value NLM_HOST_MAX, and changes the 'garbage
    collection' behaviour when the number of hosts exceeds this threshold.

    However its behaviour is strange, and likely not what was intended.
    When the number of hosts exceeds the max, it scans *less* often (every
    2 minutes vs every minute) and allows unused host information to
    remain around longer (5 minutes instead of 2).

    Having this limit is of dubious value anyway, and we have not
    suffered from the code not getting the limit right, so remove the
    limit altogether. We go with the larger values (discard 5 minute old
    hosts every 2 minutes) as they are probably safer.

    Maybe the periodic garbage collection should be replace to with
    'shrinker' handler so we just respond to memory pressure....

    Acked-by: Jeff Layton
    Signed-off-by: Neil Brown
    Signed-off-by: J. Bruce Fields

    NeilBrown
     

20 Apr, 2008

7 commits

  • Now that we've added the 'generic' credentials (that are independent of the
    rpc_client) to the nfs_open_context, we can use those in the NLM client to
    ensure that the lock/unlock requests are authenticated to whoever
    originally opened the file.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • We shouldn't remove the lock from the list of blocked locks until the
    CANCEL call has completed since we may be racing with a GRANTED callback.

    Also ensure that we send an UNLOCK if the CANCEL request failed. Normally
    that should only happen if the process gets hit with a fatal signal.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • Currently, it returns success as long as the RPC call was sent. We'd like
    to know if the CANCEL operation succeeded on the server.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • The signal masks have been rendered obsolete by the preceding patch.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • Peter Staubach comments:

    > In the course of investigating testing failures in the locking phase of
    > the Connectathon testsuite, I discovered a couple of things. One was
    > that one of the tests in the locking tests was racy when it didn't seem
    > to need to be and two, that the NFS client asynchronously releases locks
    > when a process is exiting.
    ...
    > The Single UNIX Specification Version 3 specifies that: "All locks
    > associated with a file for a given process shall be removed when a file
    > descriptor for that file is closed by that process or the process holding
    > that file descriptor terminates.".
    >
    > This does not specify whether those locks must be released prior to the
    > completion of the exit processing for the process or not. However,
    > general assumptions seem to be that those locks will be released. This
    > leads to more deterministic behavior under normal circumstances.

    The following patch converts the NFSv2/v3 locking code to use the same
    mechanism as NFSv4 for sending asynchronous RPC calls and then waiting for
    them to complete. This ensures that the UNLOCK and CANCEL RPC calls will
    complete even if the user interrupts the call, yet satisfies the
    above request for synchronous behaviour on process exit.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • When we replace the existing synchronous RPC calls with asynchronous calls,
    the reference count will be needed in order to allow us to examine the
    result of the RPC call.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     
  • Also fix up nlmclnt_lock() so that it doesn't pass modified versions of
    fl->fl_flags to nlmclnt_cancel() and other helpers.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

20 Mar, 2008

6 commits