]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFSv4: Return the delegation if the server returns NFS4ERR_OPENMODE
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 7 Mar 2012 21:39:06 +0000 (16:39 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Apr 2012 16:52:50 +0000 (09:52 -0700)
commit 3114ea7a24d3264c090556a2444fc6d2c06176d4 upstream.

If a setattr() fails because of an NFS4ERR_OPENMODE error, it is
probably due to us holding a read delegation. Ensure that the
recovery routines return that delegation in this case.

Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/nfs4_fs.h
fs/nfs/nfs4proc.c

index d6ba137f185b14b0a486a3324c8aeba5c8e44f5b..0983b2581ea35d0e0f6bc6b27722c7f9e7496e83 100644 (file)
@@ -191,6 +191,7 @@ struct nfs4_exception {
        long timeout;
        int retry;
        struct nfs4_state *state;
+       struct inode *inode;
 };
 
 struct nfs4_state_recovery_ops {
index a51e1ddb0a23821209290bd3e5ced60f73c948df..758e8096caa7cd89fa72788046f9050c30fa700b 100644 (file)
@@ -257,18 +257,28 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
 {
        struct nfs_client *clp = server->nfs_client;
        struct nfs4_state *state = exception->state;
+       struct inode *inode = exception->inode;
        int ret = errorcode;
 
        exception->retry = 0;
        switch(errorcode) {
                case 0:
                        return 0;
+               case -NFS4ERR_OPENMODE:
+                       if (nfs_have_delegation(inode, FMODE_READ)) {
+                               nfs_inode_return_delegation(inode);
+                               exception->retry = 1;
+                               return 0;
+                       }
+                       if (state == NULL)
+                               break;
+                       nfs4_schedule_stateid_recovery(server, state);
+                       goto wait_on_recovery;
                case -NFS4ERR_DELEG_REVOKED:
                case -NFS4ERR_ADMIN_REVOKED:
                case -NFS4ERR_BAD_STATEID:
                        if (state != NULL)
                                nfs_remove_bad_delegation(state->inode);
-               case -NFS4ERR_OPENMODE:
                        if (state == NULL)
                                break;
                        nfs4_schedule_stateid_recovery(server, state);
@@ -1901,6 +1911,7 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs4_exception exception = {
                .state = state,
+               .inode = inode,
        };
        int err;
        do {