]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/delegation.c
[PATCH] x86/x86_64: mark rodata section read-only: make some datastructures const
[linux-2.6-omap-h63xx.git] / fs / nfs / delegation.c
index 4a36839f0bbdc7adb31dfdae9d8a739bc6a1b0ab..618a327027b3a1215e6d0cfd720d7d1813e18c88 100644 (file)
@@ -31,11 +31,42 @@ static void nfs_free_delegation(struct nfs_delegation *delegation)
        kfree(delegation);
 }
 
+static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state)
+{
+       struct inode *inode = state->inode;
+       struct file_lock *fl;
+       int status;
+
+       for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) {
+               if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
+                       continue;
+               if ((struct nfs_open_context *)fl->fl_file->private_data != ctx)
+                       continue;
+               status = nfs4_lock_delegation_recall(state, fl);
+               if (status >= 0)
+                       continue;
+               switch (status) {
+                       default:
+                               printk(KERN_ERR "%s: unhandled error %d.\n",
+                                               __FUNCTION__, status);
+                       case -NFS4ERR_EXPIRED:
+                               /* kill_proc(fl->fl_pid, SIGLOST, 1); */
+                       case -NFS4ERR_STALE_CLIENTID:
+                               nfs4_schedule_state_recovery(NFS_SERVER(inode)->nfs4_state);
+                               goto out_err;
+               }
+       }
+       return 0;
+out_err:
+       return status;
+}
+
 static void nfs_delegation_claim_opens(struct inode *inode)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
        struct nfs_open_context *ctx;
        struct nfs4_state *state;
+       int err;
 
 again:
        spin_lock(&inode->i_lock);
@@ -47,9 +78,12 @@ again:
                        continue;
                get_nfs_open_context(ctx);
                spin_unlock(&inode->i_lock);
-               if (nfs4_open_delegation_recall(ctx->dentry, state) < 0)
-                       return;
+               err = nfs4_open_delegation_recall(ctx->dentry, state);
+               if (err >= 0)
+                       err = nfs_delegation_claim_locks(ctx, state);
                put_nfs_open_context(ctx);
+               if (err != 0)
+                       return;
                goto again;
        }
        spin_unlock(&inode->i_lock);
@@ -115,8 +149,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
                }
        }
        spin_unlock(&clp->cl_lock);
-       if (delegation != NULL)
-               kfree(delegation);
+       kfree(delegation);
        return status;
 }
 
@@ -142,7 +175,7 @@ static void nfs_msync_inode(struct inode *inode)
 /*
  * Basic procedure for returning a delegation to the server
  */
-int nfs_inode_return_delegation(struct inode *inode)
+int __nfs_inode_return_delegation(struct inode *inode)
 {
        struct nfs4_client *clp = NFS_SERVER(inode)->nfs4_state;
        struct nfs_inode *nfsi = NFS_I(inode);