Skip to content

Commit 6c34265

Browse files
author
Trond Myklebust
committed
NFSv4: Return NFS4ERR_DELAY when a delegation recall fails due to igrab()
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>
1 parent 025bb9f commit 6c34265

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

fs/nfs/callback_proc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
4040
rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
4141

4242
inode = nfs_delegation_find_inode(cps->clp, &args->fh);
43-
if (inode == NULL) {
43+
if (IS_ERR(inode)) {
44+
if (inode == ERR_PTR(-EAGAIN))
45+
res->status = htonl(NFS4ERR_DELAY);
4446
trace_nfs4_cb_getattr(cps->clp, &args->fh, NULL,
4547
-ntohl(res->status));
4648
goto out;
@@ -86,7 +88,9 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
8688

8789
res = htonl(NFS4ERR_BADHANDLE);
8890
inode = nfs_delegation_find_inode(cps->clp, &args->fh);
89-
if (inode == NULL) {
91+
if (IS_ERR(inode)) {
92+
if (inode == ERR_PTR(-EAGAIN))
93+
res = htonl(NFS4ERR_DELAY);
9094
trace_nfs4_cb_recall(cps->clp, &args->fh, NULL,
9195
&args->stateid, -ntohl(res));
9296
goto out;

fs/nfs/delegation.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -856,12 +856,14 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
856856
if (delegation->inode != NULL &&
857857
nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
858858
res = igrab(delegation->inode);
859+
spin_unlock(&delegation->lock);
860+
if (res != NULL)
861+
return res;
862+
return ERR_PTR(-EAGAIN);
859863
}
860864
spin_unlock(&delegation->lock);
861-
if (res != NULL)
862-
break;
863865
}
864-
return res;
866+
return ERR_PTR(-ENOENT);
865867
}
866868

867869
/**
@@ -876,16 +878,16 @@ struct inode *nfs_delegation_find_inode(struct nfs_client *clp,
876878
const struct nfs_fh *fhandle)
877879
{
878880
struct nfs_server *server;
879-
struct inode *res = NULL;
881+
struct inode *res;
880882

881883
rcu_read_lock();
882884
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
883885
res = nfs_delegation_find_inode_server(server, fhandle);
884-
if (res != NULL)
885-
break;
886+
if (res != ERR_PTR(-ENOENT))
887+
return res;
886888
}
887889
rcu_read_unlock();
888-
return res;
890+
return ERR_PTR(-ENOENT);
889891
}
890892

891893
static void nfs_delegation_mark_reclaim_server(struct nfs_server *server)

0 commit comments

Comments
 (0)