Skip to content

Commit c1488c9

Browse files
committed
Merge tag 'nfsd-5.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd fixes from Chuck Lever: - Fix a write performance regression - Fix crashes during request deferral on RDMA transports * tag 'nfsd-5.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: SUNRPC: Fix the svc_deferred_event trace class SUNRPC: Fix NFSD's request deferral on RDMA transports nfsd: Clean up nfsd_file_put() nfsd: Fix a write performance regression SUNRPC: Return true/false (not 1/0) from bool functions
2 parents 453096e + 4d50044 commit c1488c9

6 files changed

Lines changed: 36 additions & 26 deletions

File tree

fs/nfsd/filecache.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ nfsd_file_check_write_error(struct nfsd_file *nf)
236236
return filemap_check_wb_err(file->f_mapping, READ_ONCE(file->f_wb_err));
237237
}
238238

239+
static void
240+
nfsd_file_flush(struct nfsd_file *nf)
241+
{
242+
if (nf->nf_file && vfs_fsync(nf->nf_file, 1) != 0)
243+
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
244+
}
245+
239246
static void
240247
nfsd_file_do_unhash(struct nfsd_file *nf)
241248
{
@@ -295,19 +302,15 @@ nfsd_file_put_noref(struct nfsd_file *nf)
295302
void
296303
nfsd_file_put(struct nfsd_file *nf)
297304
{
298-
bool is_hashed;
299-
300305
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
301-
if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
306+
if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
307+
nfsd_file_flush(nf);
302308
nfsd_file_put_noref(nf);
303-
return;
309+
} else {
310+
nfsd_file_put_noref(nf);
311+
if (nf->nf_file)
312+
nfsd_file_schedule_laundrette();
304313
}
305-
306-
filemap_flush(nf->nf_file->f_mapping);
307-
is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
308-
nfsd_file_put_noref(nf);
309-
if (is_hashed)
310-
nfsd_file_schedule_laundrette();
311314
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
312315
nfsd_file_gc();
313316
}
@@ -328,6 +331,7 @@ nfsd_file_dispose_list(struct list_head *dispose)
328331
while(!list_empty(dispose)) {
329332
nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
330333
list_del(&nf->nf_lru);
334+
nfsd_file_flush(nf);
331335
nfsd_file_put_noref(nf);
332336
}
333337
}
@@ -341,6 +345,7 @@ nfsd_file_dispose_list_sync(struct list_head *dispose)
341345
while(!list_empty(dispose)) {
342346
nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
343347
list_del(&nf->nf_lru);
348+
nfsd_file_flush(nf);
344349
if (!refcount_dec_and_test(&nf->nf_ref))
345350
continue;
346351
if (nfsd_file_free(nf))

fs/nfsd/nfs2acl.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,34 +249,34 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
249249
int w;
250250

251251
if (!svcxdr_encode_stat(xdr, resp->status))
252-
return 0;
252+
return false;
253253

254254
if (dentry == NULL || d_really_is_negative(dentry))
255-
return 1;
255+
return true;
256256
inode = d_inode(dentry);
257257

258258
if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
259-
return 0;
259+
return false;
260260
if (xdr_stream_encode_u32(xdr, resp->mask) < 0)
261-
return 0;
261+
return false;
262262

263263
rqstp->rq_res.page_len = w = nfsacl_size(
264264
(resp->mask & NFS_ACL) ? resp->acl_access : NULL,
265265
(resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
266266
while (w > 0) {
267267
if (!*(rqstp->rq_next_page++))
268-
return 1;
268+
return true;
269269
w -= PAGE_SIZE;
270270
}
271271

272272
if (!nfs_stream_encode_acl(xdr, inode, resp->acl_access,
273273
resp->mask & NFS_ACL, 0))
274-
return 0;
274+
return false;
275275
if (!nfs_stream_encode_acl(xdr, inode, resp->acl_default,
276276
resp->mask & NFS_DFACL, NFS_ACL_DEFAULT))
277-
return 0;
277+
return false;
278278

279-
return 1;
279+
return true;
280280
}
281281

282282
/* ACCESS */
@@ -286,17 +286,17 @@ nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
286286
struct nfsd3_accessres *resp = rqstp->rq_resp;
287287

288288
if (!svcxdr_encode_stat(xdr, resp->status))
289-
return 0;
289+
return false;
290290
switch (resp->status) {
291291
case nfs_ok:
292292
if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
293-
return 0;
293+
return false;
294294
if (xdr_stream_encode_u32(xdr, resp->access) < 0)
295-
return 0;
295+
return false;
296296
break;
297297
}
298298

299-
return 1;
299+
return true;
300300
}
301301

302302
/*

include/linux/sunrpc/svc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ struct svc_deferred_req {
395395
size_t addrlen;
396396
struct sockaddr_storage daddr; /* where reply must come from */
397397
size_t daddrlen;
398+
void *xprt_ctxt;
398399
struct cache_deferred_req handle;
399400
size_t xprt_hlen;
400401
int argslen;

include/trace/events/sunrpc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,17 +2015,18 @@ DECLARE_EVENT_CLASS(svc_deferred_event,
20152015
TP_STRUCT__entry(
20162016
__field(const void *, dr)
20172017
__field(u32, xid)
2018-
__string(addr, dr->xprt->xpt_remotebuf)
2018+
__array(__u8, addr, INET6_ADDRSTRLEN + 10)
20192019
),
20202020

20212021
TP_fast_assign(
20222022
__entry->dr = dr;
20232023
__entry->xid = be32_to_cpu(*(__be32 *)(dr->args +
20242024
(dr->xprt_hlen>>2)));
2025-
__assign_str(addr, dr->xprt->xpt_remotebuf);
2025+
snprintf(__entry->addr, sizeof(__entry->addr) - 1,
2026+
"%pISpc", (struct sockaddr *)&dr->addr);
20262027
),
20272028

2028-
TP_printk("addr=%s dr=%p xid=0x%08x", __get_str(addr), __entry->dr,
2029+
TP_printk("addr=%s dr=%p xid=0x%08x", __entry->addr, __entry->dr,
20292030
__entry->xid)
20302031
);
20312032

net/sunrpc/svc_xprt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req)
12311231
dr->daddr = rqstp->rq_daddr;
12321232
dr->argslen = rqstp->rq_arg.len >> 2;
12331233
dr->xprt_hlen = rqstp->rq_xprt_hlen;
1234+
dr->xprt_ctxt = rqstp->rq_xprt_ctxt;
1235+
rqstp->rq_xprt_ctxt = NULL;
12341236

12351237
/* back up head to the start of the buffer and copy */
12361238
skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len;
@@ -1269,6 +1271,7 @@ static noinline int svc_deferred_recv(struct svc_rqst *rqstp)
12691271
rqstp->rq_xprt_hlen = dr->xprt_hlen;
12701272
rqstp->rq_daddr = dr->daddr;
12711273
rqstp->rq_respages = rqstp->rq_pages;
1274+
rqstp->rq_xprt_ctxt = dr->xprt_ctxt;
12721275
svc_xprt_received(rqstp->rq_xprt);
12731276
return (dr->argslen<<2) - dr->xprt_hlen;
12741277
}

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
831831
goto out_err;
832832
if (ret == 0)
833833
goto out_drop;
834-
rqstp->rq_xprt_hlen = ret;
834+
rqstp->rq_xprt_hlen = 0;
835835

836836
if (svc_rdma_is_reverse_direction_reply(xprt, ctxt))
837837
goto out_backchannel;

0 commit comments

Comments
 (0)