Skip to content

Commit 1fbf3e4

Browse files
committed
Merge tag 'nfs-for-5.1-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Highlights include: Stable fixes: - Fixes for NFS I/O request leakages - Fix error handling paths in the NFS I/O recoalescing code - Reinitialise NFSv4.1 sequence results before retransmitting a request - Fix a soft lockup in the delegation recovery code - Bulk destroy of layouts needs to be safe w.r.t. umount - Prevent thundering herd issues when the SUNRPC socket is not connected - Respect RPC call timeouts when retrying transmission Features: - Convert rpc auth layer to use xdr_streams - Config option to disable insecure RPCSEC_GSS crypto types - Reduce size of RPC receive buffers - Readdirplus optimization by cache mechanism - Convert SUNRPC socket send code to use iov_iter() - SUNRPC micro-optimisations to avoid indirect calls - Add support for the pNFS LAYOUTERROR operation and use it with the pNFS/flexfiles driver - Add trace events to report non-zero NFS status codes - Various removals of unnecessary dprintks Bugfixes and cleanups: - Fix a number of sparse warnings and documentation format warnings - Fix nfs_parse_devname to not modify it's argument - Fix potential corruption of page being written through pNFS/blocks - fix xfstest generic/099 failures on nfsv3 - Avoid NFSv4.1 "false retries" when RPC calls are interrupted - Abort I/O early if the pNFS/flexfiles layout segment was invalidated - Avoid unnecessary pNFS/flexfiles layout invalidations" * tag 'nfs-for-5.1-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (90 commits) SUNRPC: Take the transport send lock before binding+connecting SUNRPC: Micro-optimise when the task is known not to be sleeping SUNRPC: Check whether the task was transmitted before rebind/reconnect SUNRPC: Remove redundant calls to RPC_IS_QUEUED() SUNRPC: Clean up SUNRPC: Respect RPC call timeouts when retrying transmission SUNRPC: Fix up RPC back channel transmission SUNRPC: Prevent thundering herd when the socket is not connected SUNRPC: Allow dynamic allocation of back channel slots NFSv4.1: Bump the default callback session slot count to 16 SUNRPC: Convert remaining GFP_NOIO, and GFP_NOWAIT sites in sunrpc NFS/flexfiles: Clean up mirror DS initialisation NFS/flexfiles: Remove dead code in ff_layout_mirror_valid() NFS/flexfile: Simplify nfs4_ff_layout_select_ds_stateid() NFS/flexfile: Simplify nfs4_ff_layout_ds_version() NFS/flexfiles: Simplify ff_layout_get_ds_cred() NFS/flexfiles: Simplify nfs4_ff_find_or_create_ds_client() NFS/flexfiles: Simplify nfs4_ff_layout_select_ds_fh() NFS/flexfiles: Speed up read failover when DSes are down NFS/flexfiles: Don't invalidate DS deviceids for being unresponsive ...
2 parents f88c594 + 4d6c671 commit 1fbf3e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3366
-2203
lines changed

fs/lockd/clnt4xdr.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,6 @@ static void nlm4_compute_offsets(const struct nlm_lock *lock,
7474
*l_len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
7575
}
7676

77-
/*
78-
* Handle decode buffer overflows out-of-line.
79-
*/
80-
static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
81-
{
82-
dprintk("lockd: %s prematurely hit the end of our receive buffer. "
83-
"Remaining buffer length is %tu words.\n",
84-
func, xdr->end - xdr->p);
85-
}
86-
87-
8877
/*
8978
* Encode/decode NLMv4 basic data types
9079
*
@@ -176,7 +165,6 @@ static int decode_cookie(struct xdr_stream *xdr,
176165
dprintk("NFS: returned cookie was too long: %u\n", length);
177166
return -EIO;
178167
out_overflow:
179-
print_overflow_msg(__func__, xdr);
180168
return -EIO;
181169
}
182170

@@ -236,7 +224,6 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat)
236224
__func__, be32_to_cpup(p));
237225
return -EIO;
238226
out_overflow:
239-
print_overflow_msg(__func__, xdr);
240227
return -EIO;
241228
}
242229

@@ -309,7 +296,6 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
309296
out:
310297
return error;
311298
out_overflow:
312-
print_overflow_msg(__func__, xdr);
313299
return -EIO;
314300
}
315301

fs/lockd/clntxdr.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ static void nlm_compute_offsets(const struct nlm_lock *lock,
7070
*l_len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
7171
}
7272

73-
/*
74-
* Handle decode buffer overflows out-of-line.
75-
*/
76-
static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
77-
{
78-
dprintk("lockd: %s prematurely hit the end of our receive buffer. "
79-
"Remaining buffer length is %tu words.\n",
80-
func, xdr->end - xdr->p);
81-
}
82-
83-
8473
/*
8574
* Encode/decode NLMv3 basic data types
8675
*
@@ -173,7 +162,6 @@ static int decode_cookie(struct xdr_stream *xdr,
173162
dprintk("NFS: returned cookie was too long: %u\n", length);
174163
return -EIO;
175164
out_overflow:
176-
print_overflow_msg(__func__, xdr);
177165
return -EIO;
178166
}
179167

@@ -231,7 +219,6 @@ static int decode_nlm_stat(struct xdr_stream *xdr,
231219
__func__, be32_to_cpup(p));
232220
return -EIO;
233221
out_overflow:
234-
print_overflow_msg(__func__, xdr);
235222
return -EIO;
236223
}
237224

@@ -303,7 +290,6 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result)
303290
out:
304291
return error;
305292
out_overflow:
306-
print_overflow_msg(__func__, xdr);
307293
return -EIO;
308294
}
309295

fs/nfs/callback_xdr.c

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p)
7272
return xdr_ressize_check(rqstp, p);
7373
}
7474

75-
static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes)
76-
{
77-
__be32 *p;
78-
79-
p = xdr_inline_decode(xdr, nbytes);
80-
if (unlikely(p == NULL))
81-
printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n");
82-
return p;
83-
}
84-
8575
static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,
8676
const char **str, size_t maxlen)
8777
{
@@ -98,13 +88,13 @@ static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
9888
{
9989
__be32 *p;
10090

101-
p = read_buf(xdr, 4);
91+
p = xdr_inline_decode(xdr, 4);
10292
if (unlikely(p == NULL))
10393
return htonl(NFS4ERR_RESOURCE);
10494
fh->size = ntohl(*p);
10595
if (fh->size > NFS4_FHSIZE)
10696
return htonl(NFS4ERR_BADHANDLE);
107-
p = read_buf(xdr, fh->size);
97+
p = xdr_inline_decode(xdr, fh->size);
10898
if (unlikely(p == NULL))
10999
return htonl(NFS4ERR_RESOURCE);
110100
memcpy(&fh->data[0], p, fh->size);
@@ -117,11 +107,11 @@ static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
117107
__be32 *p;
118108
unsigned int attrlen;
119109

120-
p = read_buf(xdr, 4);
110+
p = xdr_inline_decode(xdr, 4);
121111
if (unlikely(p == NULL))
122112
return htonl(NFS4ERR_RESOURCE);
123113
attrlen = ntohl(*p);
124-
p = read_buf(xdr, attrlen << 2);
114+
p = xdr_inline_decode(xdr, attrlen << 2);
125115
if (unlikely(p == NULL))
126116
return htonl(NFS4ERR_RESOURCE);
127117
if (likely(attrlen > 0))
@@ -135,7 +125,7 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
135125
{
136126
__be32 *p;
137127

138-
p = read_buf(xdr, NFS4_STATEID_SIZE);
128+
p = xdr_inline_decode(xdr, NFS4_STATEID_SIZE);
139129
if (unlikely(p == NULL))
140130
return htonl(NFS4ERR_RESOURCE);
141131
memcpy(stateid->data, p, NFS4_STATEID_SIZE);
@@ -156,7 +146,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
156146
status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ);
157147
if (unlikely(status != 0))
158148
return status;
159-
p = read_buf(xdr, 12);
149+
p = xdr_inline_decode(xdr, 12);
160150
if (unlikely(p == NULL))
161151
return htonl(NFS4ERR_RESOURCE);
162152
hdr->minorversion = ntohl(*p++);
@@ -176,7 +166,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
176166
static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op)
177167
{
178168
__be32 *p;
179-
p = read_buf(xdr, 4);
169+
p = xdr_inline_decode(xdr, 4);
180170
if (unlikely(p == NULL))
181171
return htonl(NFS4ERR_RESOURCE_HDR);
182172
*op = ntohl(*p);
@@ -205,7 +195,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp,
205195
status = decode_delegation_stateid(xdr, &args->stateid);
206196
if (unlikely(status != 0))
207197
return status;
208-
p = read_buf(xdr, 4);
198+
p = xdr_inline_decode(xdr, 4);
209199
if (unlikely(p == NULL))
210200
return htonl(NFS4ERR_RESOURCE);
211201
args->truncate = ntohl(*p);
@@ -227,7 +217,7 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
227217
__be32 status = 0;
228218
uint32_t iomode;
229219

230-
p = read_buf(xdr, 4 * sizeof(uint32_t));
220+
p = xdr_inline_decode(xdr, 4 * sizeof(uint32_t));
231221
if (unlikely(p == NULL))
232222
return htonl(NFS4ERR_BADXDR);
233223

@@ -245,14 +235,14 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
245235
if (unlikely(status != 0))
246236
return status;
247237

248-
p = read_buf(xdr, 2 * sizeof(uint64_t));
238+
p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t));
249239
if (unlikely(p == NULL))
250240
return htonl(NFS4ERR_BADXDR);
251241
p = xdr_decode_hyper(p, &args->cbl_range.offset);
252242
p = xdr_decode_hyper(p, &args->cbl_range.length);
253243
return decode_layout_stateid(xdr, &args->cbl_stateid);
254244
} else if (args->cbl_recall_type == RETURN_FSID) {
255-
p = read_buf(xdr, 2 * sizeof(uint64_t));
245+
p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t));
256246
if (unlikely(p == NULL))
257247
return htonl(NFS4ERR_BADXDR);
258248
p = xdr_decode_hyper(p, &args->cbl_fsid.major);
@@ -275,7 +265,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
275265
args->ndevs = 0;
276266

277267
/* Num of device notifications */
278-
p = read_buf(xdr, sizeof(uint32_t));
268+
p = xdr_inline_decode(xdr, sizeof(uint32_t));
279269
if (unlikely(p == NULL)) {
280270
status = htonl(NFS4ERR_BADXDR);
281271
goto out;
@@ -298,7 +288,8 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
298288
for (i = 0; i < n; i++) {
299289
struct cb_devicenotifyitem *dev = &args->devs[i];
300290

301-
p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE);
291+
p = xdr_inline_decode(xdr, (4 * sizeof(uint32_t)) +
292+
NFS4_DEVICEID4_SIZE);
302293
if (unlikely(p == NULL)) {
303294
status = htonl(NFS4ERR_BADXDR);
304295
goto err;
@@ -329,7 +320,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
329320
p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE);
330321

331322
if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) {
332-
p = read_buf(xdr, sizeof(uint32_t));
323+
p = xdr_inline_decode(xdr, sizeof(uint32_t));
333324
if (unlikely(p == NULL)) {
334325
status = htonl(NFS4ERR_BADXDR);
335326
goto err;
@@ -359,7 +350,7 @@ static __be32 decode_sessionid(struct xdr_stream *xdr,
359350
{
360351
__be32 *p;
361352

362-
p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN);
353+
p = xdr_inline_decode(xdr, NFS4_MAX_SESSIONID_LEN);
363354
if (unlikely(p == NULL))
364355
return htonl(NFS4ERR_RESOURCE);
365356

@@ -379,13 +370,13 @@ static __be32 decode_rc_list(struct xdr_stream *xdr,
379370
goto out;
380371

381372
status = htonl(NFS4ERR_RESOURCE);
382-
p = read_buf(xdr, sizeof(uint32_t));
373+
p = xdr_inline_decode(xdr, sizeof(uint32_t));
383374
if (unlikely(p == NULL))
384375
goto out;
385376

386377
rc_list->rcl_nrefcalls = ntohl(*p++);
387378
if (rc_list->rcl_nrefcalls) {
388-
p = read_buf(xdr,
379+
p = xdr_inline_decode(xdr,
389380
rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t));
390381
if (unlikely(p == NULL))
391382
goto out;
@@ -418,7 +409,7 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
418409
if (status)
419410
return status;
420411

421-
p = read_buf(xdr, 5 * sizeof(uint32_t));
412+
p = xdr_inline_decode(xdr, 5 * sizeof(uint32_t));
422413
if (unlikely(p == NULL))
423414
return htonl(NFS4ERR_RESOURCE);
424415

@@ -461,7 +452,7 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp,
461452
uint32_t bitmap[2];
462453
__be32 *p, status;
463454

464-
p = read_buf(xdr, 4);
455+
p = xdr_inline_decode(xdr, 4);
465456
if (unlikely(p == NULL))
466457
return htonl(NFS4ERR_BADXDR);
467458
args->craa_objs_to_keep = ntohl(*p++);
@@ -480,7 +471,7 @@ static __be32 decode_recallslot_args(struct svc_rqst *rqstp,
480471
struct cb_recallslotargs *args = argp;
481472
__be32 *p;
482473

483-
p = read_buf(xdr, 4);
474+
p = xdr_inline_decode(xdr, 4);
484475
if (unlikely(p == NULL))
485476
return htonl(NFS4ERR_BADXDR);
486477
args->crsa_target_highest_slotid = ntohl(*p++);
@@ -492,14 +483,14 @@ static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_arg
492483
__be32 *p;
493484
unsigned int len;
494485

495-
p = read_buf(xdr, 12);
486+
p = xdr_inline_decode(xdr, 12);
496487
if (unlikely(p == NULL))
497488
return htonl(NFS4ERR_BADXDR);
498489

499490
p = xdr_decode_hyper(p, &args->cbnl_owner.clientid);
500491
len = be32_to_cpu(*p);
501492

502-
p = read_buf(xdr, len);
493+
p = xdr_inline_decode(xdr, len);
503494
if (unlikely(p == NULL))
504495
return htonl(NFS4ERR_BADXDR);
505496

@@ -537,7 +528,7 @@ static __be32 decode_write_response(struct xdr_stream *xdr,
537528
__be32 *p;
538529

539530
/* skip the always zero field */
540-
p = read_buf(xdr, 4);
531+
p = xdr_inline_decode(xdr, 4);
541532
if (unlikely(!p))
542533
goto out;
543534
p++;
@@ -577,7 +568,7 @@ static __be32 decode_offload_args(struct svc_rqst *rqstp,
577568
return status;
578569

579570
/* decode status */
580-
p = read_buf(xdr, 4);
571+
p = xdr_inline_decode(xdr, 4);
581572
if (unlikely(!p))
582573
goto out;
583574
args->error = ntohl(*p++);
@@ -943,10 +934,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
943934
};
944935
unsigned int nops = 0;
945936

946-
xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base);
937+
xdr_init_decode(&xdr_in, &rqstp->rq_arg,
938+
rqstp->rq_arg.head[0].iov_base, NULL);
947939

948940
p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len);
949-
xdr_init_encode(&xdr_out, &rqstp->rq_res, p);
941+
xdr_init_encode(&xdr_out, &rqstp->rq_res, p, NULL);
950942

951943
status = decode_compound_hdr_arg(&xdr_in, &hdr_arg);
952944
if (status == htonl(NFS4ERR_RESOURCE))

fs/nfs/delegation.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation
229229
spin_lock(&delegation->lock);
230230
if (delegation->inode != NULL)
231231
inode = igrab(delegation->inode);
232+
if (!inode)
233+
set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags);
232234
spin_unlock(&delegation->lock);
233235
return inode;
234236
}
@@ -681,7 +683,7 @@ void nfs_expire_all_delegations(struct nfs_client *clp)
681683

682684
/**
683685
* nfs_super_return_all_delegations - return delegations for one superblock
684-
* @sb: sb to process
686+
* @server: pointer to nfs_server to process
685687
*
686688
*/
687689
void nfs_server_return_all_delegations(struct nfs_server *server)
@@ -944,10 +946,11 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
944946
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
945947
list_for_each_entry_rcu(delegation, &server->delegations,
946948
super_list) {
947-
if (test_bit(NFS_DELEGATION_RETURNING,
948-
&delegation->flags))
949-
continue;
950-
if (test_bit(NFS_DELEGATION_NEED_RECLAIM,
949+
if (test_bit(NFS_DELEGATION_INODE_FREEING,
950+
&delegation->flags) ||
951+
test_bit(NFS_DELEGATION_RETURNING,
952+
&delegation->flags) ||
953+
test_bit(NFS_DELEGATION_NEED_RECLAIM,
951954
&delegation->flags) == 0)
952955
continue;
953956
if (!nfs_sb_active(server->super))
@@ -1053,10 +1056,11 @@ void nfs_reap_expired_delegations(struct nfs_client *clp)
10531056
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
10541057
list_for_each_entry_rcu(delegation, &server->delegations,
10551058
super_list) {
1056-
if (test_bit(NFS_DELEGATION_RETURNING,
1057-
&delegation->flags))
1058-
continue;
1059-
if (test_bit(NFS_DELEGATION_TEST_EXPIRED,
1059+
if (test_bit(NFS_DELEGATION_INODE_FREEING,
1060+
&delegation->flags) ||
1061+
test_bit(NFS_DELEGATION_RETURNING,
1062+
&delegation->flags) ||
1063+
test_bit(NFS_DELEGATION_TEST_EXPIRED,
10601064
&delegation->flags) == 0)
10611065
continue;
10621066
if (!nfs_sb_active(server->super))

fs/nfs/delegation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum {
3434
NFS_DELEGATION_RETURNING,
3535
NFS_DELEGATION_REVOKED,
3636
NFS_DELEGATION_TEST_EXPIRED,
37+
NFS_DELEGATION_INODE_FREEING,
3738
};
3839

3940
int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,

0 commit comments

Comments
 (0)