Skip to content

Commit ce5624f

Browse files
author
Trond Myklebust
committed
NFSv4: Return NFS4ERR_DELAY when a layout recall fails due to igrab()
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 6c34265 commit ce5624f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

fs/nfs/callback_proc.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,27 @@ static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
128128
struct inode *inode;
129129
struct pnfs_layout_hdr *lo;
130130

131-
restart:
132131
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
133132
list_for_each_entry(lo, &server->layouts, plh_layouts) {
134133
if (stateid != NULL &&
135134
!nfs4_stateid_match_other(stateid, &lo->plh_stateid))
136135
continue;
137136
inode = igrab(lo->plh_inode);
138137
if (!inode)
139-
continue;
138+
return ERR_PTR(-EAGAIN);
140139
if (!nfs_sb_active(inode->i_sb)) {
141140
rcu_read_unlock();
142141
spin_unlock(&clp->cl_lock);
143142
iput(inode);
144143
spin_lock(&clp->cl_lock);
145144
rcu_read_lock();
146-
goto restart;
145+
return ERR_PTR(-EAGAIN);
147146
}
148147
return inode;
149148
}
150149
}
151150

152-
return NULL;
151+
return ERR_PTR(-ENOENT);
153152
}
154153

155154
/*
@@ -166,7 +165,6 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
166165
struct inode *inode;
167166
struct pnfs_layout_hdr *lo;
168167

169-
restart:
170168
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
171169
list_for_each_entry(lo, &server->layouts, plh_layouts) {
172170
nfsi = NFS_I(lo->plh_inode);
@@ -176,20 +174,20 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
176174
continue;
177175
inode = igrab(lo->plh_inode);
178176
if (!inode)
179-
continue;
177+
return ERR_PTR(-EAGAIN);
180178
if (!nfs_sb_active(inode->i_sb)) {
181179
rcu_read_unlock();
182180
spin_unlock(&clp->cl_lock);
183181
iput(inode);
184182
spin_lock(&clp->cl_lock);
185183
rcu_read_lock();
186-
goto restart;
184+
return ERR_PTR(-EAGAIN);
187185
}
188186
return inode;
189187
}
190188
}
191189

192-
return NULL;
190+
return ERR_PTR(-ENOENT);
193191
}
194192

195193
static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
@@ -201,7 +199,7 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
201199
spin_lock(&clp->cl_lock);
202200
rcu_read_lock();
203201
inode = nfs_layout_find_inode_by_stateid(clp, stateid);
204-
if (!inode)
202+
if (inode == ERR_PTR(-ENOENT))
205203
inode = nfs_layout_find_inode_by_fh(clp, fh);
206204
rcu_read_unlock();
207205
spin_unlock(&clp->cl_lock);
@@ -256,8 +254,11 @@ static u32 initiate_file_draining(struct nfs_client *clp,
256254
LIST_HEAD(free_me_list);
257255

258256
ino = nfs_layout_find_inode(clp, &args->cbl_fh, &args->cbl_stateid);
259-
if (!ino)
260-
goto out;
257+
if (IS_ERR(ino)) {
258+
if (ino == ERR_PTR(-EAGAIN))
259+
rv = NFS4ERR_DELAY;
260+
goto out_noput;
261+
}
261262

262263
pnfs_layoutcommit_inode(ino, false);
263264

@@ -303,9 +304,10 @@ static u32 initiate_file_draining(struct nfs_client *clp,
303304
nfs_commit_inode(ino, 0);
304305
pnfs_put_layout_hdr(lo);
305306
out:
307+
nfs_iput_and_deactive(ino);
308+
out_noput:
306309
trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, ino,
307310
&args->cbl_stateid, -rv);
308-
nfs_iput_and_deactive(ino);
309311
return rv;
310312
}
311313

0 commit comments

Comments
 (0)