Skip to content

Commit 298fb76

Browse files
committed
Merge tag 'nfsd-5.4' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "Highlights: - Add a new knfsd file cache, so that we don't have to open and close on each (NFSv2/v3) READ or WRITE. This can speed up read and write in some cases. It also replaces our readahead cache. - Prevent silent data loss on write errors, by treating write errors like server reboots for the purposes of write caching, thus forcing clients to resend their writes. - Tweak the code that allocates sessions to be more forgiving, so that NFSv4.1 mounts are less likely to hang when a server already has a lot of clients. - Eliminate an arbitrary limit on NFSv4 ACL sizes; they should now be limited only by the backend filesystem and the maximum RPC size. - Allow the server to enforce use of the correct kerberos credentials when a client reclaims state after a reboot. And some miscellaneous smaller bugfixes and cleanup" * tag 'nfsd-5.4' of git://linux-nfs.org/~bfields/linux: (34 commits) sunrpc: clean up indentation issue nfsd: fix nfs read eof detection nfsd: Make nfsd_reset_boot_verifier_locked static nfsd: degraded slot-count more gracefully as allocation nears exhaustion. nfsd: handle drc over-allocation gracefully. nfsd: add support for upcall version 2 nfsd: add a "GetVersion" upcall for nfsdcld nfsd: Reset the boot verifier on all write I/O errors nfsd: Don't garbage collect files that might contain write errors nfsd: Support the server resetting the boot verifier nfsd: nfsd_file cache entries should be per net namespace nfsd: eliminate an unnecessary acl size limit Deprecate nfsd fault injection nfsd: remove duplicated include from filecache.c nfsd: Fix the documentation for svcxdr_tmpalloc() nfsd: Fix up some unused variable warnings nfsd: close cached files prior to a REMOVE or RENAME that would replace target nfsd: rip out the raparms cache nfsd: have nfsd_test_lock use the nfsd_file cache nfsd: hook up nfs4_preprocess_stateid_op to the nfsd_file cache ...
2 parents 8f744bd + e41f9ef commit 298fb76

40 files changed

+2083
-600
lines changed

fs/file_table.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ void flush_delayed_fput(void)
327327
{
328328
delayed_fput(NULL);
329329
}
330+
EXPORT_SYMBOL_GPL(flush_delayed_fput);
330331

331332
static DECLARE_DELAYED_WORK(delayed_fput_work, delayed_fput);
332333

fs/locks.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ struct file_lock_list_struct {
212212
static DEFINE_PER_CPU(struct file_lock_list_struct, file_lock_list);
213213
DEFINE_STATIC_PERCPU_RWSEM(file_rwsem);
214214

215+
215216
/*
216217
* The blocked_hash is used to find POSIX lock loops for deadlock detection.
217218
* It is protected by blocked_lock_lock.
@@ -1991,6 +1992,64 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
19911992
}
19921993
EXPORT_SYMBOL(generic_setlease);
19931994

1995+
#if IS_ENABLED(CONFIG_SRCU)
1996+
/*
1997+
* Kernel subsystems can register to be notified on any attempt to set
1998+
* a new lease with the lease_notifier_chain. This is used by (e.g.) nfsd
1999+
* to close files that it may have cached when there is an attempt to set a
2000+
* conflicting lease.
2001+
*/
2002+
static struct srcu_notifier_head lease_notifier_chain;
2003+
2004+
static inline void
2005+
lease_notifier_chain_init(void)
2006+
{
2007+
srcu_init_notifier_head(&lease_notifier_chain);
2008+
}
2009+
2010+
static inline void
2011+
setlease_notifier(long arg, struct file_lock *lease)
2012+
{
2013+
if (arg != F_UNLCK)
2014+
srcu_notifier_call_chain(&lease_notifier_chain, arg, lease);
2015+
}
2016+
2017+
int lease_register_notifier(struct notifier_block *nb)
2018+
{
2019+
return srcu_notifier_chain_register(&lease_notifier_chain, nb);
2020+
}
2021+
EXPORT_SYMBOL_GPL(lease_register_notifier);
2022+
2023+
void lease_unregister_notifier(struct notifier_block *nb)
2024+
{
2025+
srcu_notifier_chain_unregister(&lease_notifier_chain, nb);
2026+
}
2027+
EXPORT_SYMBOL_GPL(lease_unregister_notifier);
2028+
2029+
#else /* !IS_ENABLED(CONFIG_SRCU) */
2030+
static inline void
2031+
lease_notifier_chain_init(void)
2032+
{
2033+
}
2034+
2035+
static inline void
2036+
setlease_notifier(long arg, struct file_lock *lease)
2037+
{
2038+
}
2039+
2040+
int lease_register_notifier(struct notifier_block *nb)
2041+
{
2042+
return 0;
2043+
}
2044+
EXPORT_SYMBOL_GPL(lease_register_notifier);
2045+
2046+
void lease_unregister_notifier(struct notifier_block *nb)
2047+
{
2048+
}
2049+
EXPORT_SYMBOL_GPL(lease_unregister_notifier);
2050+
2051+
#endif /* IS_ENABLED(CONFIG_SRCU) */
2052+
19942053
/**
19952054
* vfs_setlease - sets a lease on an open file
19962055
* @filp: file pointer
@@ -2011,6 +2070,8 @@ EXPORT_SYMBOL(generic_setlease);
20112070
int
20122071
vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
20132072
{
2073+
if (lease)
2074+
setlease_notifier(arg, *lease);
20142075
if (filp->f_op->setlease)
20152076
return filp->f_op->setlease(filp, arg, lease, priv);
20162077
else
@@ -2924,6 +2985,7 @@ static int __init filelock_init(void)
29242985
INIT_HLIST_HEAD(&fll->hlist);
29252986
}
29262987

2988+
lease_notifier_chain_init();
29272989
return 0;
29282990
}
29292991
core_initcall(filelock_init);

fs/nfsd/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config NFSD
33
tristate "NFS server support"
44
depends on INET
55
depends on FILE_LOCKING
6+
depends on FSNOTIFY
67
select LOCKD
78
select SUNRPC
89
select EXPORTFS
@@ -147,7 +148,7 @@ config NFSD_V4_SECURITY_LABEL
147148

148149
config NFSD_FAULT_INJECTION
149150
bool "NFS server manual fault injection"
150-
depends on NFSD_V4 && DEBUG_KERNEL && DEBUG_FS
151+
depends on NFSD_V4 && DEBUG_KERNEL && DEBUG_FS && BROKEN
151152
help
152153
This option enables support for manually injecting faults
153154
into the NFS server. This is intended to be used for

fs/nfsd/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ obj-$(CONFIG_NFSD) += nfsd.o
1111
nfsd-y += trace.o
1212

1313
nfsd-y += nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
14-
export.o auth.o lockd.o nfscache.o nfsxdr.o stats.o
14+
export.o auth.o lockd.o nfscache.o nfsxdr.o \
15+
stats.o filecache.o
1516
nfsd-$(CONFIG_NFSD_FAULT_INJECTION) += fault_inject.o
1617
nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o
1718
nfsd-$(CONFIG_NFSD_V3) += nfs3proc.o nfs3xdr.o

fs/nfsd/acl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ struct nfs4_acl;
3939
struct svc_fh;
4040
struct svc_rqst;
4141

42-
/*
43-
* Maximum ACL we'll accept from a client; chosen (somewhat
44-
* arbitrarily) so that kmalloc'ing the ACL shouldn't require a
45-
* high-order allocation. This allows 204 ACEs on x86_64:
46-
*/
47-
#define NFS4_ACL_MAX ((PAGE_SIZE - sizeof(struct nfs4_acl)) \
48-
/ sizeof(struct nfs4_ace))
49-
5042
int nfs4_acl_bytes(int entries);
5143
int nfs4_acl_get_whotype(char *, u32);
5244
__be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who);

fs/nfsd/blocklayout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "blocklayoutxdr.h"
1717
#include "pnfs.h"
18+
#include "filecache.h"
1819

1920
#define NFSDDBG_FACILITY NFSDDBG_PNFS
2021

@@ -404,7 +405,7 @@ static void
404405
nfsd4_scsi_fence_client(struct nfs4_layout_stateid *ls)
405406
{
406407
struct nfs4_client *clp = ls->ls_stid.sc_client;
407-
struct block_device *bdev = ls->ls_file->f_path.mnt->mnt_sb->s_bdev;
408+
struct block_device *bdev = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_bdev;
408409

409410
bdev->bd_disk->fops->pr_ops->pr_preempt(bdev, NFSD_MDS_PR_KEY,
410411
nfsd4_scsi_pr_key(clp), 0, true);

fs/nfsd/export.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "nfsfh.h"
2323
#include "netns.h"
2424
#include "pnfs.h"
25+
#include "filecache.h"
2526

2627
#define NFSDDBG_FACILITY NFSDDBG_EXPORT
2728

@@ -232,6 +233,17 @@ static struct cache_head *expkey_alloc(void)
232233
return NULL;
233234
}
234235

236+
static void expkey_flush(void)
237+
{
238+
/*
239+
* Take the nfsd_mutex here to ensure that the file cache is not
240+
* destroyed while we're in the middle of flushing.
241+
*/
242+
mutex_lock(&nfsd_mutex);
243+
nfsd_file_cache_purge(current->nsproxy->net_ns);
244+
mutex_unlock(&nfsd_mutex);
245+
}
246+
235247
static const struct cache_detail svc_expkey_cache_template = {
236248
.owner = THIS_MODULE,
237249
.hash_size = EXPKEY_HASHMAX,
@@ -244,6 +256,7 @@ static const struct cache_detail svc_expkey_cache_template = {
244256
.init = expkey_init,
245257
.update = expkey_update,
246258
.alloc = expkey_alloc,
259+
.flush = expkey_flush,
247260
};
248261

249262
static int

0 commit comments

Comments
 (0)