Skip to content

Commit 1a3b1bb

Browse files
committed
Merge tag 'nfs-for-5.18-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client fixes from Trond Myklebust: "Stable fixes: - SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() Bugfixes: - Fix an Oopsable condition due to SLAB_ACCOUNT setting in the NFSv4.2 xattr code. - Fix for open() using an file open mode of '3' in NFSv4 - Replace readdir's use of xxhash() with hash_64() - Several patches to handle malloc() failure in SUNRPC" * tag 'nfs-for-5.18-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: SUNRPC: Move the call to xprt_send_pagedata() out of xprt_sock_sendmsg() SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec() SUNRPC: Handle allocation failure in rpc_new_task() NFS: Ensure rpc_run_task() cannot fail in nfs_async_rename() NFSv4/pnfs: Handle RPC allocation errors in nfs4_proc_layoutget SUNRPC: Handle low memory situations in call_status() SUNRPC: Handle ENOMEM in call_transmit_status() NFSv4.2: Fix missing removal of SLAB_ACCOUNT on kmem_cache allocation SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() NFS: Replace readdir's use of xxhash() with hash_64() SUNRPC: handle malloc failure in ->request_prepare NFSv4: fix open failure with O_ACCMODE flag Revert "NFSv4: Handle the special Linux file open access mode"
2 parents c0aa533 + ff053db commit 1a3b1bb

File tree

18 files changed

+99
-61
lines changed

18 files changed

+99
-61
lines changed

fs/file_table.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ void __fput_sync(struct file *file)
412412
}
413413

414414
EXPORT_SYMBOL(fput);
415+
EXPORT_SYMBOL(__fput_sync);
415416

416417
void __init files_init(void)
417418
{

fs/nfs/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ config NFS_FS
44
depends on INET && FILE_LOCKING && MULTIUSER
55
select LOCKD
66
select SUNRPC
7-
select CRYPTO
8-
select CRYPTO_HASH
9-
select XXHASH
10-
select CRYPTO_XXHASH
117
select NFS_ACL_SUPPORT if NFS_V3_ACL
128
help
139
Choose Y here if you want to access files residing on other

fs/nfs/dir.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <linux/sched.h>
4040
#include <linux/kmemleak.h>
4141
#include <linux/xattr.h>
42-
#include <linux/xxhash.h>
42+
#include <linux/hash.h>
4343

4444
#include "delegation.h"
4545
#include "iostat.h"
@@ -350,10 +350,7 @@ static int nfs_readdir_page_array_append(struct page *page,
350350
* of directory cookies. Content is addressed by the value of the
351351
* cookie index of the first readdir entry in a page.
352352
*
353-
* The xxhash algorithm is chosen because it is fast, and is supposed
354-
* to result in a decent flat distribution of hashes.
355-
*
356-
* We then select only the first 18 bits to avoid issues with excessive
353+
* We select only the first 18 bits to avoid issues with excessive
357354
* memory use for the page cache XArray. 18 bits should allow the caching
358355
* of 262144 pages of sequences of readdir entries. Since each page holds
359356
* 127 readdir entries for a typical 64-bit system, that works out to a
@@ -363,7 +360,7 @@ static pgoff_t nfs_readdir_page_cookie_hash(u64 cookie)
363360
{
364361
if (cookie == 0)
365362
return 0;
366-
return xxhash(&cookie, sizeof(cookie), 0) & NFS_READDIR_COOKIE_MASK;
363+
return hash_64(cookie, 18);
367364
}
368365

369366
static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie,
@@ -1991,16 +1988,6 @@ const struct dentry_operations nfs4_dentry_operations = {
19911988
};
19921989
EXPORT_SYMBOL_GPL(nfs4_dentry_operations);
19931990

1994-
static fmode_t flags_to_mode(int flags)
1995-
{
1996-
fmode_t res = (__force fmode_t)flags & FMODE_EXEC;
1997-
if ((flags & O_ACCMODE) != O_WRONLY)
1998-
res |= FMODE_READ;
1999-
if ((flags & O_ACCMODE) != O_RDONLY)
2000-
res |= FMODE_WRITE;
2001-
return res;
2002-
}
2003-
20041991
static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags, struct file *filp)
20051992
{
20061993
return alloc_nfs_open_context(dentry, flags_to_mode(open_flags), filp);

fs/nfs/inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp)
11801180
nfs_fscache_open_file(inode, filp);
11811181
return 0;
11821182
}
1183-
EXPORT_SYMBOL_GPL(nfs_open);
11841183

11851184
/*
11861185
* This function is called whenever some part of NFS notices that

fs/nfs/internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry)
4242
return true;
4343
}
4444

45+
static inline fmode_t flags_to_mode(int flags)
46+
{
47+
fmode_t res = (__force fmode_t)flags & FMODE_EXEC;
48+
if ((flags & O_ACCMODE) != O_WRONLY)
49+
res |= FMODE_READ;
50+
if ((flags & O_ACCMODE) != O_RDONLY)
51+
res |= FMODE_WRITE;
52+
return res;
53+
}
54+
4555
/*
4656
* Note: RFC 1813 doesn't limit the number of auth flavors that
4757
* a server can return, so make something up.

fs/nfs/nfs42xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ int __init nfs4_xattr_cache_init(void)
997997

998998
nfs4_xattr_cache_cachep = kmem_cache_create("nfs4_xattr_cache_cache",
999999
sizeof(struct nfs4_xattr_cache), 0,
1000-
(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT),
1000+
(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD),
10011001
nfs4_xattr_cache_init_once);
10021002
if (nfs4_xattr_cache_cachep == NULL)
10031003
return -ENOMEM;

fs/nfs/nfs4file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
3232
struct dentry *parent = NULL;
3333
struct inode *dir;
3434
unsigned openflags = filp->f_flags;
35+
fmode_t f_mode;
3536
struct iattr attr;
3637
int err;
3738

@@ -50,16 +51,17 @@ nfs4_file_open(struct inode *inode, struct file *filp)
5051
if (err)
5152
return err;
5253

54+
f_mode = filp->f_mode;
5355
if ((openflags & O_ACCMODE) == 3)
54-
return nfs_open(inode, filp);
56+
f_mode |= flags_to_mode(openflags);
5557

5658
/* We can't create new files here */
5759
openflags &= ~(O_CREAT|O_EXCL);
5860

5961
parent = dget_parent(dentry);
6062
dir = d_inode(parent);
6163

62-
ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp);
64+
ctx = alloc_nfs_open_context(file_dentry(filp), f_mode, filp);
6365
err = PTR_ERR(ctx);
6466
if (IS_ERR(ctx))
6567
goto out;

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9615,6 +9615,8 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout)
96159615
nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0, 0);
96169616

96179617
task = rpc_run_task(&task_setup_data);
9618+
if (IS_ERR(task))
9619+
return ERR_CAST(task);
96189620

96199621
status = rpc_wait_for_completion_task(task);
96209622
if (status != 0)

fs/nfs/unlink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
347347
data = kzalloc(sizeof(*data), GFP_KERNEL);
348348
if (data == NULL)
349349
return ERR_PTR(-ENOMEM);
350+
task_setup_data.task = &data->task;
350351
task_setup_data.callback_data = data;
351352

352353
data->cred = get_current_cred();

include/linux/nfs_xdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@ struct nfs_unlinkdata {
16941694
struct nfs_renamedata {
16951695
struct nfs_renameargs args;
16961696
struct nfs_renameres res;
1697+
struct rpc_task task;
16971698
const struct cred *cred;
16981699
struct inode *old_dir;
16991700
struct dentry *old_dentry;

0 commit comments

Comments
 (0)