Skip to content

Commit 972a2bf

Browse files
committed
Merge tag 'nfs-for-5.4-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "Stable bugfixes: - Dequeue the request from the receive queue while we're re-encoding # v4.20+ - Fix buffer handling of GSS MIC without slack # 5.1 Features: - Increase xprtrdma maximum transport header and slot table sizes - Add support for nfs4_call_sync() calls using a custom rpc_task_struct - Optimize the default readahead size - Enable pNFS filelayout LAYOUTGET on OPEN Other bugfixes and cleanups: - Fix possible null-pointer dereferences and memory leaks - Various NFS over RDMA cleanups - Various NFS over RDMA comment updates - Don't receive TCP data into a reset request buffer - Don't try to parse incomplete RPC messages - Fix congestion window race with disconnect - Clean up pNFS return-on-close error handling - Fixes for NFS4ERR_OLD_STATEID handling" * tag 'nfs-for-5.4-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (53 commits) pNFS/filelayout: enable LAYOUTGET on OPEN NFS: Optimise the default readahead size NFSv4: Handle NFS4ERR_OLD_STATEID in LOCKU NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE NFSv4: Fix OPEN_DOWNGRADE error handling pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state seqid NFSv4: Add a helper to increment stateid seqids NFSv4: Handle RPC level errors in LAYOUTRETURN NFSv4: Handle NFS4ERR_DELAY correctly in return-on-close NFSv4: Clean up pNFS return-on-close error handling pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors NFS: remove unused check for negative dentry NFSv3: use nfs_add_or_obtain() to create and reference inodes NFS: Refactor nfs_instantiate() for dentry referencing callers SUNRPC: Fix congestion window race with disconnect SUNRPC: Don't try to parse incomplete RPC messages SUNRPC: Rename xdr_buf_read_netobj to xdr_buf_read_mic SUNRPC: Fix buffer handling of GSS MIC without slack SUNRPC: RPC level errors should always set task->tk_rpc_status SUNRPC: Don't receive TCP data into a request buffer that has been reset ...
2 parents 7be3cb0 + a8fd0fe commit 972a2bf

File tree

29 files changed

+835
-580
lines changed

29 files changed

+835
-580
lines changed

fs/nfs/dir.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,24 +1669,19 @@ static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
16691669

16701670
#endif /* CONFIG_NFSV4 */
16711671

1672-
/*
1673-
* Code common to create, mkdir, and mknod.
1674-
*/
1675-
int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1672+
struct dentry *
1673+
nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle,
16761674
struct nfs_fattr *fattr,
16771675
struct nfs4_label *label)
16781676
{
16791677
struct dentry *parent = dget_parent(dentry);
16801678
struct inode *dir = d_inode(parent);
16811679
struct inode *inode;
16821680
struct dentry *d;
1683-
int error = -EACCES;
1681+
int error;
16841682

16851683
d_drop(dentry);
16861684

1687-
/* We may have been initialized further down */
1688-
if (d_really_is_positive(dentry))
1689-
goto out;
16901685
if (fhandle->size == 0) {
16911686
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, NULL);
16921687
if (error)
@@ -1702,18 +1697,32 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
17021697
}
17031698
inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label);
17041699
d = d_splice_alias(inode, dentry);
1705-
if (IS_ERR(d)) {
1706-
error = PTR_ERR(d);
1707-
goto out_error;
1708-
}
1709-
dput(d);
17101700
out:
17111701
dput(parent);
1712-
return 0;
1702+
return d;
17131703
out_error:
17141704
nfs_mark_for_revalidate(dir);
1715-
dput(parent);
1716-
return error;
1705+
d = ERR_PTR(error);
1706+
goto out;
1707+
}
1708+
EXPORT_SYMBOL_GPL(nfs_add_or_obtain);
1709+
1710+
/*
1711+
* Code common to create, mkdir, and mknod.
1712+
*/
1713+
int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1714+
struct nfs_fattr *fattr,
1715+
struct nfs4_label *label)
1716+
{
1717+
struct dentry *d;
1718+
1719+
d = nfs_add_or_obtain(dentry, fhandle, fattr, label);
1720+
if (IS_ERR(d))
1721+
return PTR_ERR(d);
1722+
1723+
/* Callers don't care */
1724+
dput(d);
1725+
return 0;
17171726
}
17181727
EXPORT_SYMBOL_GPL(nfs_instantiate);
17191728

fs/nfs/filelayout/filelayout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
11641164
.id = LAYOUT_NFSV4_1_FILES,
11651165
.name = "LAYOUT_NFSV4_1_FILES",
11661166
.owner = THIS_MODULE,
1167+
.flags = PNFS_LAYOUTGET_ON_OPEN,
11671168
.max_layoutget_response = 4096, /* 1 page or so... */
11681169
.alloc_layout_hdr = filelayout_alloc_layout_hdr,
11691170
.free_layout_hdr = filelayout_free_layout_hdr,

fs/nfs/internal.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ extern const struct export_operations nfs_export_ops;
1616

1717
struct nfs_string;
1818

19-
/* Maximum number of readahead requests
20-
* FIXME: this should really be a sysctl so that users may tune it to suit
21-
* their needs. People that do NFS over a slow network, might for
22-
* instance want to reduce it to something closer to 1 for improved
23-
* interactive response.
24-
*/
25-
#define NFS_MAX_READAHEAD (RPC_DEF_SLOT_TABLE - 1)
26-
2719
static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr)
2820
{
2921
if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid))

fs/nfs/nfs3proc.c

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,17 @@ static struct nfs3_createdata *nfs3_alloc_createdata(void)
279279
return data;
280280
}
281281

282-
static int nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data)
282+
static struct dentry *
283+
nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data)
283284
{
284285
int status;
285286

286287
status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0);
287288
nfs_post_op_update_inode(dir, data->res.dir_attr);
288-
if (status == 0)
289-
status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL);
290-
return status;
289+
if (status != 0)
290+
return ERR_PTR(status);
291+
292+
return nfs_add_or_obtain(dentry, data->res.fh, data->res.fattr, NULL);
291293
}
292294

293295
static void nfs3_free_createdata(struct nfs3_createdata *data)
@@ -304,6 +306,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
304306
{
305307
struct posix_acl *default_acl, *acl;
306308
struct nfs3_createdata *data;
309+
struct dentry *d_alias;
307310
int status = -ENOMEM;
308311

309312
dprintk("NFS call create %pd\n", dentry);
@@ -330,7 +333,8 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
330333
goto out;
331334

332335
for (;;) {
333-
status = nfs3_do_create(dir, dentry, data);
336+
d_alias = nfs3_do_create(dir, dentry, data);
337+
status = PTR_ERR_OR_ZERO(d_alias);
334338

335339
if (status != -ENOTSUPP)
336340
break;
@@ -355,6 +359,9 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
355359
if (status != 0)
356360
goto out_release_acls;
357361

362+
if (d_alias)
363+
dentry = d_alias;
364+
358365
/* When we created the file with exclusive semantics, make
359366
* sure we set the attributes afterwards. */
360367
if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) {
@@ -372,11 +379,13 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
372379
nfs_post_op_update_inode(d_inode(dentry), data->res.fattr);
373380
dprintk("NFS reply setattr (post-create): %d\n", status);
374381
if (status != 0)
375-
goto out_release_acls;
382+
goto out_dput;
376383
}
377384

378385
status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
379386

387+
out_dput:
388+
dput(d_alias);
380389
out_release_acls:
381390
posix_acl_release(acl);
382391
posix_acl_release(default_acl);
@@ -504,6 +513,7 @@ nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
504513
unsigned int len, struct iattr *sattr)
505514
{
506515
struct nfs3_createdata *data;
516+
struct dentry *d_alias;
507517
int status = -ENOMEM;
508518

509519
if (len > NFS3_MAXPATHLEN)
@@ -522,7 +532,11 @@ nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
522532
data->arg.symlink.pathlen = len;
523533
data->arg.symlink.sattr = sattr;
524534

525-
status = nfs3_do_create(dir, dentry, data);
535+
d_alias = nfs3_do_create(dir, dentry, data);
536+
status = PTR_ERR_OR_ZERO(d_alias);
537+
538+
if (status == 0)
539+
dput(d_alias);
526540

527541
nfs3_free_createdata(data);
528542
out:
@@ -535,6 +549,7 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
535549
{
536550
struct posix_acl *default_acl, *acl;
537551
struct nfs3_createdata *data;
552+
struct dentry *d_alias;
538553
int status = -ENOMEM;
539554

540555
dprintk("NFS call mkdir %pd\n", dentry);
@@ -553,12 +568,18 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
553568
data->arg.mkdir.len = dentry->d_name.len;
554569
data->arg.mkdir.sattr = sattr;
555570

556-
status = nfs3_do_create(dir, dentry, data);
571+
d_alias = nfs3_do_create(dir, dentry, data);
572+
status = PTR_ERR_OR_ZERO(d_alias);
573+
557574
if (status != 0)
558575
goto out_release_acls;
559576

577+
if (d_alias)
578+
dentry = d_alias;
579+
560580
status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
561581

582+
dput(d_alias);
562583
out_release_acls:
563584
posix_acl_release(acl);
564585
posix_acl_release(default_acl);
@@ -660,6 +681,7 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
660681
{
661682
struct posix_acl *default_acl, *acl;
662683
struct nfs3_createdata *data;
684+
struct dentry *d_alias;
663685
int status = -ENOMEM;
664686

665687
dprintk("NFS call mknod %pd %u:%u\n", dentry,
@@ -698,12 +720,17 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
698720
goto out;
699721
}
700722

701-
status = nfs3_do_create(dir, dentry, data);
723+
d_alias = nfs3_do_create(dir, dentry, data);
724+
status = PTR_ERR_OR_ZERO(d_alias);
702725
if (status != 0)
703726
goto out_release_acls;
704727

728+
if (d_alias)
729+
dentry = d_alias;
730+
705731
status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
706732

733+
dput(d_alias);
707734
out_release_acls:
708735
posix_acl_release(acl);
709736
posix_acl_release(default_acl);

fs/nfs/nfs4_fs.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,6 @@ extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
491491
extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
492492
const struct nfs_lock_context *, nfs4_stateid *,
493493
const struct cred **);
494-
extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst,
495-
struct nfs4_state *state);
496494
extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
497495
struct nfs4_state *state);
498496

@@ -574,6 +572,15 @@ static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stat
574572
return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
575573
}
576574

575+
static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1)
576+
{
577+
u32 seqid = be32_to_cpu(s1->seqid);
578+
579+
if (++seqid == 0)
580+
++seqid;
581+
s1->seqid = cpu_to_be32(seqid);
582+
}
583+
577584
static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
578585
{
579586
return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;

0 commit comments

Comments
 (0)