Skip to content

Commit 8f03cf5

Browse files
committed
Merge tag 'nfs-for-4.11-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "Highlights include: Stable bugfixes: - NFSv4: Fix memory and state leak in _nfs4_open_and_get_state - xprtrdma: Fix Read chunk padding - xprtrdma: Per-connection pad optimization - xprtrdma: Disable pad optimization by default - xprtrdma: Reduce required number of send SGEs - nlm: Ensure callback code also checks that the files match - pNFS/flexfiles: If the layout is invalid, it must be updated before retrying - NFSv4: Fix reboot recovery in copy offload - Revert "NFSv4.1: Handle NFS4ERR_BADSESSION/NFS4ERR_DEADSESSION replies to OP_SEQUENCE" - NFSv4: fix getacl head length estimation - NFSv4: fix getacl ERANGE for sum ACL buffer sizes Features: - Add and use dprintk_cont macros - Various cleanups to NFS v4.x to reduce code duplication and complexity - Remove unused cr_magic related code - Improvements to sunrpc "read from buffer" code - Clean up sunrpc timeout code and allow changing TCP timeout parameters - Remove duplicate mw_list management code in xprtrdma - Add generic functions for encoding and decoding xdr streams Bugfixes: - Clean up nfs_show_mountd_netid - Make layoutreturn_ops static and use NULL instead of 0 to fix sparse warnings - Properly handle -ERESTARTSYS in nfs_rename() - Check if register_shrinker() failed during rpcauth_init() - Properly clean up procfs/pipefs entries - Various NFS over RDMA related fixes - Silence unititialized variable warning in sunrpc" * tag 'nfs-for-4.11-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (64 commits) NFSv4: fix getacl ERANGE for some ACL buffer sizes NFSv4: fix getacl head length estimation Revert "NFSv4.1: Handle NFS4ERR_BADSESSION/NFS4ERR_DEADSESSION replies to OP_SEQUENCE" NFSv4: Fix reboot recovery in copy offload pNFS/flexfiles: If the layout is invalid, it must be updated before retrying NFSv4: Clean up owner/group attribute decode SUNRPC: Add a helper function xdr_stream_decode_string_dup() NFSv4: Remove bogus "struct nfs_client" argument from decode_ace() NFSv4: Fix the underestimation of delegation XDR space reservation NFSv4: Replace callback string decode function with a generic NFSv4: Replace the open coded decode_opaque_inline() with the new generic NFSv4: Replace ad-hoc xdr encode/decode helpers with xdr_stream_* generics SUNRPC: Add generic helpers for xdr_stream encode/decode sunrpc: silence uninitialized variable warning nlm: Ensure callback code also checks that the files match sunrpc: Allow xprt->ops->timer method to sleep xprtrdma: Refactor management of mw_list field xprtrdma: Handle stale connection rejection xprtrdma: Properly recover FRWRs with in-flight FASTREG WRs xprtrdma: Shrink send SGEs array ...
2 parents 25c4e6c + ed92d8c commit 8f03cf5

39 files changed

+902
-832
lines changed

fs/nfs/cache_lib.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd)
141141

142142
void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd)
143143
{
144-
if (cd->u.pipefs.dir)
145-
sunrpc_cache_unregister_pipefs(cd);
144+
sunrpc_cache_unregister_pipefs(cd);
146145
}
147146

148147
void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd)

fs/nfs/callback_xdr.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,15 @@ static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes)
8383
return p;
8484
}
8585

86-
static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str)
86+
static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,
87+
const char **str, size_t maxlen)
8788
{
88-
__be32 *p;
89-
90-
p = read_buf(xdr, 4);
91-
if (unlikely(p == NULL))
92-
return htonl(NFS4ERR_RESOURCE);
93-
*len = ntohl(*p);
94-
95-
if (*len != 0) {
96-
p = read_buf(xdr, *len);
97-
if (unlikely(p == NULL))
98-
return htonl(NFS4ERR_RESOURCE);
99-
*str = (const char *)p;
100-
} else
101-
*str = NULL;
89+
ssize_t err;
10290

91+
err = xdr_stream_decode_opaque_inline(xdr, (void **)str, maxlen);
92+
if (err < 0)
93+
return cpu_to_be32(NFS4ERR_RESOURCE);
94+
*len = err;
10395
return 0;
10496
}
10597

@@ -162,15 +154,9 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
162154
__be32 *p;
163155
__be32 status;
164156

165-
status = decode_string(xdr, &hdr->taglen, &hdr->tag);
157+
status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ);
166158
if (unlikely(status != 0))
167159
return status;
168-
/* We do not like overly long tags! */
169-
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ) {
170-
printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n",
171-
__func__, hdr->taglen);
172-
return htonl(NFS4ERR_RESOURCE);
173-
}
174160
p = read_buf(xdr, 12);
175161
if (unlikely(p == NULL))
176162
return htonl(NFS4ERR_RESOURCE);
@@ -582,12 +568,8 @@ static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, struct xdr_stream
582568

583569
static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
584570
{
585-
__be32 *p;
586-
587-
p = xdr_reserve_space(xdr, 4 + len);
588-
if (unlikely(p == NULL))
589-
return htonl(NFS4ERR_RESOURCE);
590-
xdr_encode_opaque(p, str, len);
571+
if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0))
572+
return cpu_to_be32(NFS4ERR_RESOURCE);
591573
return 0;
592574
}
593575

fs/nfs/dir.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,29 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
20022002
}
20032003
EXPORT_SYMBOL_GPL(nfs_link);
20042004

2005+
static void
2006+
nfs_complete_rename(struct rpc_task *task, struct nfs_renamedata *data)
2007+
{
2008+
struct dentry *old_dentry = data->old_dentry;
2009+
struct dentry *new_dentry = data->new_dentry;
2010+
struct inode *old_inode = d_inode(old_dentry);
2011+
struct inode *new_inode = d_inode(new_dentry);
2012+
2013+
nfs_mark_for_revalidate(old_inode);
2014+
2015+
switch (task->tk_status) {
2016+
case 0:
2017+
if (new_inode != NULL)
2018+
nfs_drop_nlink(new_inode);
2019+
d_move(old_dentry, new_dentry);
2020+
nfs_set_verifier(new_dentry,
2021+
nfs_save_change_attribute(data->new_dir));
2022+
break;
2023+
case -ENOENT:
2024+
nfs_dentry_handle_enoent(old_dentry);
2025+
}
2026+
}
2027+
20052028
/*
20062029
* RENAME
20072030
* FIXME: Some nfsds, like the Linux user space nfsd, may generate a
@@ -2084,7 +2107,8 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
20842107
if (new_inode != NULL)
20852108
NFS_PROTO(new_inode)->return_delegation(new_inode);
20862109

2087-
task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, NULL);
2110+
task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry,
2111+
nfs_complete_rename);
20882112
if (IS_ERR(task)) {
20892113
error = PTR_ERR(task);
20902114
goto out;
@@ -2094,21 +2118,11 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
20942118
if (error == 0)
20952119
error = task->tk_status;
20962120
rpc_put_task(task);
2097-
nfs_mark_for_revalidate(old_inode);
20982121
out:
20992122
if (rehash)
21002123
d_rehash(rehash);
21012124
trace_nfs_rename_exit(old_dir, old_dentry,
21022125
new_dir, new_dentry, error);
2103-
if (!error) {
2104-
if (new_inode != NULL)
2105-
nfs_drop_nlink(new_inode);
2106-
d_move(old_dentry, new_dentry);
2107-
nfs_set_verifier(new_dentry,
2108-
nfs_save_change_attribute(new_dir));
2109-
} else if (error == -ENOENT)
2110-
nfs_dentry_handle_enoent(old_dentry);
2111-
21122126
/* new dentry created? */
21132127
if (dentry)
21142128
dput(dentry);

fs/nfs/filelayout/filelayout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)
305305
}
306306
hdr->pgio_done_cb = filelayout_read_done_cb;
307307

308-
if (nfs41_setup_sequence(hdr->ds_clp->cl_session,
308+
if (nfs4_setup_sequence(hdr->ds_clp,
309309
&hdr->args.seq_args,
310310
&hdr->res.seq_res,
311311
task))
@@ -403,7 +403,7 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)
403403
rpc_exit(task, 0);
404404
return;
405405
}
406-
if (nfs41_setup_sequence(hdr->ds_clp->cl_session,
406+
if (nfs4_setup_sequence(hdr->ds_clp,
407407
&hdr->args.seq_args,
408408
&hdr->res.seq_res,
409409
task))
@@ -438,7 +438,7 @@ static void filelayout_commit_prepare(struct rpc_task *task, void *data)
438438
{
439439
struct nfs_commit_data *wdata = data;
440440

441-
nfs41_setup_sequence(wdata->ds_clp->cl_session,
441+
nfs4_setup_sequence(wdata->ds_clp,
442442
&wdata->args.seq_args,
443443
&wdata->res.seq_res,
444444
task);

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,6 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
10531053
struct nfs_client *mds_client = mds_server->nfs_client;
10541054
struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table;
10551055

1056-
if (task->tk_status >= 0)
1057-
return 0;
1058-
10591056
switch (task->tk_status) {
10601057
/* MDS state errors */
10611058
case -NFS4ERR_DELEG_REVOKED:
@@ -1157,9 +1154,6 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task,
11571154
{
11581155
struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx);
11591156

1160-
if (task->tk_status >= 0)
1161-
return 0;
1162-
11631157
switch (task->tk_status) {
11641158
/* File access problems. Don't mark the device as unavailable */
11651159
case -EACCES:
@@ -1195,6 +1189,13 @@ static int ff_layout_async_handle_error(struct rpc_task *task,
11951189
{
11961190
int vers = clp->cl_nfs_mod->rpc_vers->number;
11971191

1192+
if (task->tk_status >= 0)
1193+
return 0;
1194+
1195+
/* Handle the case of an invalid layout segment */
1196+
if (!pnfs_is_valid_lseg(lseg))
1197+
return -NFS4ERR_RESET_TO_PNFS;
1198+
11981199
switch (vers) {
11991200
case 3:
12001201
return ff_layout_async_handle_error_v3(task, lseg, idx);
@@ -1384,30 +1385,14 @@ static void ff_layout_read_prepare_v3(struct rpc_task *task, void *data)
13841385
rpc_call_start(task);
13851386
}
13861387

1387-
static int ff_layout_setup_sequence(struct nfs_client *ds_clp,
1388-
struct nfs4_sequence_args *args,
1389-
struct nfs4_sequence_res *res,
1390-
struct rpc_task *task)
1391-
{
1392-
if (ds_clp->cl_session)
1393-
return nfs41_setup_sequence(ds_clp->cl_session,
1394-
args,
1395-
res,
1396-
task);
1397-
return nfs40_setup_sequence(ds_clp->cl_slot_tbl,
1398-
args,
1399-
res,
1400-
task);
1401-
}
1402-
14031388
static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data)
14041389
{
14051390
struct nfs_pgio_header *hdr = data;
14061391

1407-
if (ff_layout_setup_sequence(hdr->ds_clp,
1408-
&hdr->args.seq_args,
1409-
&hdr->res.seq_res,
1410-
task))
1392+
if (nfs4_setup_sequence(hdr->ds_clp,
1393+
&hdr->args.seq_args,
1394+
&hdr->res.seq_res,
1395+
task))
14111396
return;
14121397

14131398
if (ff_layout_read_prepare_common(task, hdr))
@@ -1578,10 +1563,10 @@ static void ff_layout_write_prepare_v4(struct rpc_task *task, void *data)
15781563
{
15791564
struct nfs_pgio_header *hdr = data;
15801565

1581-
if (ff_layout_setup_sequence(hdr->ds_clp,
1582-
&hdr->args.seq_args,
1583-
&hdr->res.seq_res,
1584-
task))
1566+
if (nfs4_setup_sequence(hdr->ds_clp,
1567+
&hdr->args.seq_args,
1568+
&hdr->res.seq_res,
1569+
task))
15851570
return;
15861571

15871572
if (ff_layout_write_prepare_common(task, hdr))
@@ -1667,10 +1652,10 @@ static void ff_layout_commit_prepare_v4(struct rpc_task *task, void *data)
16671652
{
16681653
struct nfs_commit_data *wdata = data;
16691654

1670-
if (ff_layout_setup_sequence(wdata->ds_clp,
1671-
&wdata->args.seq_args,
1672-
&wdata->res.seq_res,
1673-
task))
1655+
if (nfs4_setup_sequence(wdata->ds_clp,
1656+
&wdata->args.seq_args,
1657+
&wdata->res.seq_res,
1658+
task))
16741659
return;
16751660
ff_layout_commit_prepare_common(task, data);
16761661
}
@@ -1965,10 +1950,7 @@ static int ff_layout_encode_ioerr(struct xdr_stream *xdr,
19651950
static void
19661951
encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
19671952
{
1968-
__be32 *p;
1969-
1970-
p = xdr_reserve_space(xdr, len);
1971-
xdr_encode_opaque_fixed(p, buf, len);
1953+
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
19721954
}
19731955

19741956
static void
@@ -2092,7 +2074,7 @@ ff_layout_free_layoutreturn(struct nfs4_xdr_opaque_data *args)
20922074
kfree(ff_args);
20932075
}
20942076

2095-
const struct nfs4_xdr_opaque_ops layoutreturn_ops = {
2077+
static const struct nfs4_xdr_opaque_ops layoutreturn_ops = {
20962078
.encode = ff_layout_encode_layoutreturn,
20972079
.free = ff_layout_free_layoutreturn,
20982080
};

0 commit comments

Comments
 (0)