OSDN Git Service

NFSv4: Return NFS4ERR_DELAY when a delegation recall fails due to igrab()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 7 Jun 2018 18:22:00 +0000 (14:22 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 8 Jun 2018 20:36:10 +0000 (16:36 -0400)
If the attempt to recall the delegation fails because the inode is
in the process of being evicted from cache, then use NFS4ERR_DELAY
to ask the server to retry later.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/callback_proc.c
fs/nfs/delegation.c

index d561161..eacd09d 100644 (file)
@@ -40,7 +40,9 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
                rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
 
        inode = nfs_delegation_find_inode(cps->clp, &args->fh);
-       if (inode == NULL) {
+       if (IS_ERR(inode)) {
+               if (inode == ERR_PTR(-EAGAIN))
+                       res->status = htonl(NFS4ERR_DELAY);
                trace_nfs4_cb_getattr(cps->clp, &args->fh, NULL,
                                -ntohl(res->status));
                goto out;
@@ -86,7 +88,9 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
 
        res = htonl(NFS4ERR_BADHANDLE);
        inode = nfs_delegation_find_inode(cps->clp, &args->fh);
-       if (inode == NULL) {
+       if (IS_ERR(inode)) {
+               if (inode == ERR_PTR(-EAGAIN))
+                       res = htonl(NFS4ERR_DELAY);
                trace_nfs4_cb_recall(cps->clp, &args->fh, NULL,
                                &args->stateid, -ntohl(res));
                goto out;
index 91c3737..bbd0465 100644 (file)
@@ -856,12 +856,14 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
                if (delegation->inode != NULL &&
                    nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
                        res = igrab(delegation->inode);
+                       spin_unlock(&delegation->lock);
+                       if (res != NULL)
+                               return res;
+                       return ERR_PTR(-EAGAIN);
                }
                spin_unlock(&delegation->lock);
-               if (res != NULL)
-                       break;
        }
-       return res;
+       return ERR_PTR(-ENOENT);
 }
 
 /**
@@ -876,16 +878,16 @@ struct inode *nfs_delegation_find_inode(struct nfs_client *clp,
                                        const struct nfs_fh *fhandle)
 {
        struct nfs_server *server;
-       struct inode *res = NULL;
+       struct inode *res;
 
        rcu_read_lock();
        list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
                res = nfs_delegation_find_inode_server(server, fhandle);
-               if (res != NULL)
-                       break;
+               if (res != ERR_PTR(-ENOENT))
+                       return res;
        }
        rcu_read_unlock();
-       return res;
+       return ERR_PTR(-ENOENT);
 }
 
 static void nfs_delegation_mark_reclaim_server(struct nfs_server *server)