Skip to content

Commit b6dde1e

Browse files
committed
Merge tag 'nfsd-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd updates from Chuck Lever: "Neil Brown contributed more scalability improvements to NFSD's open file cache, and Jeff Layton contributed a menagerie of repairs to NFSD's NFSv4 callback / backchannel implementation. Mike Snitzer contributed a change to NFS re-export support that disables support for file locking on a re-exported NFSv4 mount. This is because NFSv4 state recovery is currently difficult if not impossible for re-exported NFS mounts. The change aims to prevent data integrity exposures after the re-export server crashes. Work continues on the evolving NFSD netlink administrative API. Many thanks to the contributors, reviewers, testers, and bug reporters who participated during the v6.15 development cycle" * tag 'nfsd-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (45 commits) NFSD: Add a Kconfig setting to enable delegated timestamps sysctl: Fixes nsm_local_state bounds nfsd: use a long for the count in nfsd4_state_shrinker_count() nfsd: remove obsolete comment from nfs4_alloc_stid nfsd: remove unneeded forward declaration of nfsd4_mark_cb_fault() nfsd: reorganize struct nfs4_delegation for better packing nfsd: handle errors from rpc_call_async() nfsd: move cb_need_restart flag into cb_flags nfsd: replace CB_GETATTR_BUSY with NFSD4_CALLBACK_RUNNING nfsd: eliminate cl_ra_cblist and NFSD4_CLIENT_CB_RECALL_ANY nfsd: prevent callback tasks running concurrently nfsd: disallow file locking and delegations for NFSv4 reexport nfsd: filecache: drop the list_lru lock during lock gc scans nfsd: filecache: don't repeatedly add/remove files on the lru list nfsd: filecache: introduce NFSD_FILE_RECENT nfsd: filecache: use list_lru_walk_node() in nfsd_file_gc() nfsd: filecache: use nfsd_file_dispose_list() in nfsd_file_close_inode_sync() NFSD: Re-organize nfsd_file_gc_worker() nfsd: filecache: remove race handling. fs: nfs: acl: Avoid -Wflex-array-member-not-at-end warning ...
2 parents 1e7857b + 26a8076 commit b6dde1e

File tree

29 files changed

+684
-404
lines changed

29 files changed

+684
-404
lines changed

Documentation/filesystems/nfs/reexport.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ Reboot recovery
2626
---------------
2727

2828
The NFS protocol's normal reboot recovery mechanisms don't work for the
29-
case when the reexport server reboots. Clients will lose any locks
30-
they held before the reboot, and further IO will result in errors.
31-
Closing and reopening files should clear the errors.
29+
case when the reexport server reboots because the source server has not
30+
rebooted, and so it is not in grace. Since the source server is not in
31+
grace, it cannot offer any guarantees that the file won't have been
32+
changed between the locks getting lost and any attempt to recover them.
33+
The same applies to delegations and any associated locks. Clients are
34+
not allowed to get file locks or delegations from a reexport server, any
35+
attempts will fail with operation not supported.
3236

3337
Filehandle limits
3438
-----------------
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
3+
name: lockd
4+
protocol: genetlink
5+
uapi-header: linux/lockd_netlink.h
6+
7+
doc: lockd configuration over generic netlink
8+
9+
attribute-sets:
10+
-
11+
name: server
12+
attributes:
13+
-
14+
name: gracetime
15+
type: u32
16+
-
17+
name: tcp-port
18+
type: u16
19+
-
20+
name: udp-port
21+
type: u16
22+
23+
operations:
24+
list:
25+
-
26+
name: server-set
27+
doc: set the lockd server parameters
28+
attribute-set: server
29+
flags: [ admin-perm ]
30+
do:
31+
request:
32+
attributes:
33+
- gracetime
34+
- tcp-port
35+
- udp-port
36+
-
37+
name: server-get
38+
doc: get the lockd server parameters
39+
attribute-set: server
40+
do:
41+
reply:
42+
attributes:
43+
- gracetime
44+
- tcp-port
45+
- udp-port

fs/lockd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ ccflags-y += -I$(src) # needed for trace events
88
obj-$(CONFIG_LOCKD) += lockd.o
99

1010
lockd-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \
11-
svcshare.o svcproc.o svcsubs.o mon.o trace.o xdr.o
11+
svcshare.o svcproc.o svcsubs.o mon.o trace.o xdr.o netlink.o
1212
lockd-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o
1313
lockd-$(CONFIG_PROC_FS) += procfs.o

fs/lockd/netlink.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/lockd.yaml */
4+
/* YNL-GEN kernel source */
5+
6+
#include <net/netlink.h>
7+
#include <net/genetlink.h>
8+
9+
#include "netlink.h"
10+
11+
#include <uapi/linux/lockd_netlink.h>
12+
13+
/* LOCKD_CMD_SERVER_SET - do */
14+
static const struct nla_policy lockd_server_set_nl_policy[LOCKD_A_SERVER_UDP_PORT + 1] = {
15+
[LOCKD_A_SERVER_GRACETIME] = { .type = NLA_U32, },
16+
[LOCKD_A_SERVER_TCP_PORT] = { .type = NLA_U16, },
17+
[LOCKD_A_SERVER_UDP_PORT] = { .type = NLA_U16, },
18+
};
19+
20+
/* Ops table for lockd */
21+
static const struct genl_split_ops lockd_nl_ops[] = {
22+
{
23+
.cmd = LOCKD_CMD_SERVER_SET,
24+
.doit = lockd_nl_server_set_doit,
25+
.policy = lockd_server_set_nl_policy,
26+
.maxattr = LOCKD_A_SERVER_UDP_PORT,
27+
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
28+
},
29+
{
30+
.cmd = LOCKD_CMD_SERVER_GET,
31+
.doit = lockd_nl_server_get_doit,
32+
.flags = GENL_CMD_CAP_DO,
33+
},
34+
};
35+
36+
struct genl_family lockd_nl_family __ro_after_init = {
37+
.name = LOCKD_FAMILY_NAME,
38+
.version = LOCKD_FAMILY_VERSION,
39+
.netnsok = true,
40+
.parallel_ops = true,
41+
.module = THIS_MODULE,
42+
.split_ops = lockd_nl_ops,
43+
.n_split_ops = ARRAY_SIZE(lockd_nl_ops),
44+
};

fs/lockd/netlink.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/lockd.yaml */
4+
/* YNL-GEN kernel header */
5+
6+
#ifndef _LINUX_LOCKD_GEN_H
7+
#define _LINUX_LOCKD_GEN_H
8+
9+
#include <net/netlink.h>
10+
#include <net/genetlink.h>
11+
12+
#include <uapi/linux/lockd_netlink.h>
13+
14+
int lockd_nl_server_set_doit(struct sk_buff *skb, struct genl_info *info);
15+
int lockd_nl_server_get_doit(struct sk_buff *skb, struct genl_info *info);
16+
17+
extern struct genl_family lockd_nl_family;
18+
19+
#endif /* _LINUX_LOCKD_GEN_H */

fs/lockd/netns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ struct lockd_net {
1010
unsigned int nlmsvc_users;
1111
unsigned long next_gc;
1212
unsigned long nrhosts;
13+
u32 gracetime;
14+
u16 tcp_port;
15+
u16 udp_port;
1316

1417
struct delayed_work grace_period_end;
1518
struct lock_manager lockd_manager;

fs/lockd/svc.c

Lines changed: 115 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include "netns.h"
4343
#include "procfs.h"
44+
#include "netlink.h"
4445

4546
#define NLMDBG_FACILITY NLMDBG_SVC
4647
#define LOCKD_BUFSIZE (1024 + NLMSVC_XDRSIZE)
@@ -83,8 +84,14 @@ static const int nlm_port_min = 0, nlm_port_max = 65535;
8384
static struct ctl_table_header * nlm_sysctl_table;
8485
#endif
8586

86-
static unsigned long get_lockd_grace_period(void)
87+
static unsigned long get_lockd_grace_period(struct net *net)
8788
{
89+
struct lockd_net *ln = net_generic(net, lockd_net_id);
90+
91+
/* Return the net-ns specific grace period, if there is one */
92+
if (ln->gracetime)
93+
return ln->gracetime * HZ;
94+
8895
/* Note: nlm_timeout should always be nonzero */
8996
if (nlm_grace_period)
9097
return roundup(nlm_grace_period, nlm_timeout) * HZ;
@@ -103,7 +110,7 @@ static void grace_ender(struct work_struct *grace)
103110

104111
static void set_grace_period(struct net *net)
105112
{
106-
unsigned long grace_period = get_lockd_grace_period();
113+
unsigned long grace_period = get_lockd_grace_period(net);
107114
struct lockd_net *ln = net_generic(net, lockd_net_id);
108115

109116
locks_start_grace(net, &ln->lockd_manager);
@@ -166,15 +173,16 @@ static int create_lockd_listener(struct svc_serv *serv, const char *name,
166173
static int create_lockd_family(struct svc_serv *serv, struct net *net,
167174
const int family, const struct cred *cred)
168175
{
176+
struct lockd_net *ln = net_generic(net, lockd_net_id);
169177
int err;
170178

171-
err = create_lockd_listener(serv, "udp", net, family, nlm_udpport,
172-
cred);
179+
err = create_lockd_listener(serv, "udp", net, family,
180+
ln->udp_port ? ln->udp_port : nlm_udpport, cred);
173181
if (err < 0)
174182
return err;
175183

176-
return create_lockd_listener(serv, "tcp", net, family, nlm_tcpport,
177-
cred);
184+
return create_lockd_listener(serv, "tcp", net, family,
185+
ln->tcp_port ? ln->tcp_port : nlm_tcpport, cred);
178186
}
179187

180188
/*
@@ -459,9 +467,10 @@ static const struct ctl_table nlm_sysctls[] = {
459467
{
460468
.procname = "nsm_local_state",
461469
.data = &nsm_local_state,
462-
.maxlen = sizeof(int),
470+
.maxlen = sizeof(nsm_local_state),
463471
.mode = 0644,
464-
.proc_handler = proc_dointvec,
472+
.proc_handler = proc_douintvec,
473+
.extra1 = SYSCTL_ZERO,
465474
},
466475
};
467476

@@ -588,13 +597,19 @@ static int __init init_nlm(void)
588597
if (err)
589598
goto err_pernet;
590599

600+
err = genl_register_family(&lockd_nl_family);
601+
if (err)
602+
goto err_netlink;
603+
591604
err = lockd_create_procfs();
592605
if (err)
593606
goto err_procfs;
594607

595608
return 0;
596609

597610
err_procfs:
611+
genl_unregister_family(&lockd_nl_family);
612+
err_netlink:
598613
unregister_pernet_subsys(&lockd_net_ops);
599614
err_pernet:
600615
#ifdef CONFIG_SYSCTL
@@ -608,6 +623,7 @@ static void __exit exit_nlm(void)
608623
{
609624
/* FIXME: delete all NLM clients */
610625
nlm_shutdown_hosts();
626+
genl_unregister_family(&lockd_nl_family);
611627
lockd_remove_procfs();
612628
unregister_pernet_subsys(&lockd_net_ops);
613629
#ifdef CONFIG_SYSCTL
@@ -710,3 +726,94 @@ static struct svc_program nlmsvc_program = {
710726
.pg_init_request = svc_generic_init_request,
711727
.pg_rpcbind_set = svc_generic_rpcbind_set,
712728
};
729+
730+
/**
731+
* lockd_nl_server_set_doit - set the lockd server parameters via netlink
732+
* @skb: reply buffer
733+
* @info: netlink metadata and command arguments
734+
*
735+
* This updates the per-net values. When updating the values in the init_net
736+
* namespace, also update the "legacy" global values.
737+
*
738+
* Return 0 on success or a negative errno.
739+
*/
740+
int lockd_nl_server_set_doit(struct sk_buff *skb, struct genl_info *info)
741+
{
742+
struct net *net = genl_info_net(info);
743+
struct lockd_net *ln = net_generic(net, lockd_net_id);
744+
const struct nlattr *attr;
745+
746+
if (GENL_REQ_ATTR_CHECK(info, LOCKD_A_SERVER_GRACETIME))
747+
return -EINVAL;
748+
749+
if (info->attrs[LOCKD_A_SERVER_GRACETIME] ||
750+
info->attrs[LOCKD_A_SERVER_TCP_PORT] ||
751+
info->attrs[LOCKD_A_SERVER_UDP_PORT]) {
752+
attr = info->attrs[LOCKD_A_SERVER_GRACETIME];
753+
if (attr) {
754+
u32 gracetime = nla_get_u32(attr);
755+
756+
if (gracetime > nlm_grace_period_max)
757+
return -EINVAL;
758+
759+
ln->gracetime = gracetime;
760+
761+
if (net == &init_net)
762+
nlm_grace_period = gracetime;
763+
}
764+
765+
attr = info->attrs[LOCKD_A_SERVER_TCP_PORT];
766+
if (attr) {
767+
ln->tcp_port = nla_get_u16(attr);
768+
if (net == &init_net)
769+
nlm_tcpport = ln->tcp_port;
770+
}
771+
772+
attr = info->attrs[LOCKD_A_SERVER_UDP_PORT];
773+
if (attr) {
774+
ln->udp_port = nla_get_u16(attr);
775+
if (net == &init_net)
776+
nlm_udpport = ln->udp_port;
777+
}
778+
}
779+
return 0;
780+
}
781+
782+
/**
783+
* lockd_nl_server_get_doit - get lockd server parameters via netlink
784+
* @skb: reply buffer
785+
* @info: netlink metadata and command arguments
786+
*
787+
* Return 0 on success or a negative errno.
788+
*/
789+
int lockd_nl_server_get_doit(struct sk_buff *skb, struct genl_info *info)
790+
{
791+
struct net *net = genl_info_net(info);
792+
struct lockd_net *ln = net_generic(net, lockd_net_id);
793+
void *hdr;
794+
int err;
795+
796+
skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
797+
if (!skb)
798+
return -ENOMEM;
799+
800+
hdr = genlmsg_iput(skb, info);
801+
if (!hdr) {
802+
err = -EMSGSIZE;
803+
goto err_free_msg;
804+
}
805+
806+
err = nla_put_u32(skb, LOCKD_A_SERVER_GRACETIME, ln->gracetime) ||
807+
nla_put_u16(skb, LOCKD_A_SERVER_TCP_PORT, ln->tcp_port) ||
808+
nla_put_u16(skb, LOCKD_A_SERVER_UDP_PORT, ln->udp_port);
809+
if (err)
810+
goto err_free_msg;
811+
812+
genlmsg_end(skb, hdr);
813+
814+
return genlmsg_reply(skb, info);
815+
err_free_msg:
816+
nlmsg_free(skb);
817+
818+
return err;
819+
}

fs/nfs/export.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,6 @@ const struct export_operations nfs_export_ops = {
154154
EXPORT_OP_CLOSE_BEFORE_UNLINK |
155155
EXPORT_OP_REMOTE_FS |
156156
EXPORT_OP_NOATOMIC_ATTR |
157-
EXPORT_OP_FLUSH_ON_CLOSE,
157+
EXPORT_OP_FLUSH_ON_CLOSE |
158+
EXPORT_OP_NOLOCKS,
158159
};

fs/nfs_common/nfsacl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct nfsacl_encode_desc {
4242
};
4343

4444
struct nfsacl_simple_acl {
45-
struct posix_acl acl;
45+
struct posix_acl_hdr acl;
4646
struct posix_acl_entry ace[4];
4747
};
4848

@@ -112,7 +112,8 @@ int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
112112
xdr_encode_word(buf, base, entries))
113113
return -EINVAL;
114114
if (encode_entries && acl && acl->a_count == 3) {
115-
struct posix_acl *acl2 = &aclbuf.acl;
115+
struct posix_acl *acl2 =
116+
container_of(&aclbuf.acl, struct posix_acl, hdr);
116117

117118
/* Avoid the use of posix_acl_alloc(). nfsacl_encode() is
118119
* invoked in contexts where a memory allocation failure is
@@ -177,7 +178,8 @@ bool nfs_stream_encode_acl(struct xdr_stream *xdr, struct inode *inode,
177178
return false;
178179

179180
if (encode_entries && acl && acl->a_count == 3) {
180-
struct posix_acl *acl2 = &aclbuf.acl;
181+
struct posix_acl *acl2 =
182+
container_of(&aclbuf.acl, struct posix_acl, hdr);
181183

182184
/* Avoid the use of posix_acl_alloc(). nfsacl_encode() is
183185
* invoked in contexts where a memory allocation failure is

fs/nfsd/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ config NFSD_LEGACY_CLIENT_TRACKING
172172
recoverydir, or spawn a process directly using a usermodehelper
173173
upcall.
174174

175-
These legacy client tracking methods have proven to be probelmatic
175+
These legacy client tracking methods have proven to be problematic
176176
and will be removed in the future. Say Y here if you need support
177177
for them in the interim.
178+
179+
config NFSD_V4_DELEG_TIMESTAMPS
180+
bool "Support delegated timestamps"
181+
depends on NFSD_V4
182+
default n
183+
help
184+
NFSD implements delegated timestamps according to
185+
draft-ietf-nfsv4-delstid-08 "Extending the Opening of Files". This
186+
is currently an experimental feature and is therefore left disabled
187+
by default.

0 commit comments

Comments
 (0)