Skip to content

Commit 2831fa8

Browse files
committed
Merge tag 'nfsd-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd updates from Chuck Lever: "Neil Brown and Jeff Layton contributed a dynamic thread pool sizing mechanism for NFSD. The sunrpc layer now tracks minimum and maximum thread counts per pool, and NFSD adjusts running thread counts based on workload: idle threads exit after a timeout when the pool exceeds its minimum, and new threads spawn automatically when all threads are busy. Administrators control this behavior via the nfsdctl netlink interface. Rick Macklem, FreeBSD NFS maintainer, generously contributed server- side support for the POSIX ACL extension to NFSv4, as specified in draft-ietf-nfsv4-posix-acls. This extension allows NFSv4 clients to get and set POSIX access and default ACLs using native NFSv4 operations, eliminating the need for sideband protocols. The feature is gated by a Kconfig option since the IETF draft has not yet been ratified. Chuck Lever delivered numerous improvements to the xdrgen tool. Error reporting now covers parsing, AST transformation, and invalid declarations. Generated enum decoders validate incoming values against valid enumerator lists. New features include pass-through line support for embedding C directives in XDR specifications, 16-bit integer types, and program number definitions. Several code generation issues were also addressed. When an administrator revokes NFSv4 state for a filesystem via the unlock_fs interface, ongoing async COPY operations referencing that filesystem are now cancelled, with CB_OFFLOAD callbacks notifying affected clients. The remaining patches in this pull request are clean-ups and minor optimizations. Sincere thanks to all contributors, reviewers, testers, and bug reporters who participated in the v7.0 NFSD development cycle" * tag 'nfsd-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (45 commits) NFSD: Add POSIX ACL file attributes to SUPPATTR bitmasks NFSD: Add POSIX draft ACL support to the NFSv4 SETATTR operation NFSD: Add support for POSIX draft ACLs for file creation NFSD: Add support for XDR decoding POSIX draft ACLs NFSD: Refactor nfsd_setattr()'s ACL error reporting NFSD: Do not allow NFSv4 (N)VERIFY to check POSIX ACL attributes NFSD: Add nfsd4_encode_fattr4_posix_access_acl NFSD: Add nfsd4_encode_fattr4_posix_default_acl NFSD: Add nfsd4_encode_fattr4_acl_trueform_scope NFSD: Add nfsd4_encode_fattr4_acl_trueform Add RPC language definition of NFSv4 POSIX ACL extension NFSD: Add a Kconfig setting to enable support for NFSv4 POSIX ACLs xdrgen: Implement pass-through lines in specifications nfsd: cancel async COPY operations when admin revokes filesystem state nfsd: add controls to set the minimum number of threads per pool nfsd: adjust number of running nfsd threads based on activity sunrpc: allow svc_recv() to return -ETIMEDOUT and -EBUSY sunrpc: split new thread creation into a separate function sunrpc: introduce the concept of a minimum number of threads per pool sunrpc: track the max number of requested threads in a pool ...
2 parents 37a93dd + e939bd6 commit 2831fa8

68 files changed

Lines changed: 2266 additions & 371 deletions

Some content is hidden

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

Documentation/netlink/specs/nfsd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ attribute-sets:
7878
-
7979
name: scope
8080
type: string
81+
-
82+
name: min-threads
83+
type: u32
8184
-
8285
name: version
8386
attributes:
@@ -159,6 +162,7 @@ operations:
159162
- gracetime
160163
- leasetime
161164
- scope
165+
- min-threads
162166
-
163167
name: threads-get
164168
doc: get the number of running threads
@@ -170,6 +174,7 @@ operations:
170174
- gracetime
171175
- leasetime
172176
- scope
177+
- min-threads
173178
-
174179
name: version-set
175180
doc: set nfs enabled versions

Documentation/sunrpc/xdr/nfs4_1.x

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ typedef unsigned int uint32_t;
5353
*/
5454
typedef uint32_t bitmap4<>;
5555

56+
typedef opaque utf8string<>;
57+
typedef utf8string utf8str_cis;
58+
typedef utf8string utf8str_cs;
59+
typedef utf8string utf8str_mixed;
60+
5661
/*
5762
* Timeval
5863
*/
@@ -184,3 +189,59 @@ enum open_delegation_type4 {
184189
OPEN_DELEGATE_READ_ATTRS_DELEG = 4,
185190
OPEN_DELEGATE_WRITE_ATTRS_DELEG = 5
186191
};
192+
193+
194+
/*
195+
* The following content was extracted from draft-ietf-nfsv4-posix-acls
196+
*/
197+
198+
enum aclmodel4 {
199+
ACL_MODEL_NFS4 = 1,
200+
ACL_MODEL_POSIX_DRAFT = 2,
201+
ACL_MODEL_NONE = 3
202+
};
203+
pragma public aclmodel4;
204+
205+
enum aclscope4 {
206+
ACL_SCOPE_FILE_OBJECT = 1,
207+
ACL_SCOPE_FILE_SYSTEM = 2,
208+
ACL_SCOPE_SERVER = 3
209+
};
210+
pragma public aclscope4;
211+
212+
enum posixacetag4 {
213+
POSIXACE4_TAG_USER_OBJ = 1,
214+
POSIXACE4_TAG_USER = 2,
215+
POSIXACE4_TAG_GROUP_OBJ = 3,
216+
POSIXACE4_TAG_GROUP = 4,
217+
POSIXACE4_TAG_MASK = 5,
218+
POSIXACE4_TAG_OTHER = 6
219+
};
220+
pragma public posixacetag4;
221+
222+
typedef uint32_t posixaceperm4;
223+
pragma public posixaceperm4;
224+
225+
/* Bit definitions for posixaceperm4. */
226+
const POSIXACE4_PERM_EXECUTE = 0x00000001;
227+
const POSIXACE4_PERM_WRITE = 0x00000002;
228+
const POSIXACE4_PERM_READ = 0x00000004;
229+
230+
struct posixace4 {
231+
posixacetag4 tag;
232+
posixaceperm4 perm;
233+
utf8str_mixed who;
234+
};
235+
236+
typedef aclmodel4 fattr4_acl_trueform;
237+
typedef aclscope4 fattr4_acl_trueform_scope;
238+
typedef posixace4 fattr4_posix_default_acl<>;
239+
typedef posixace4 fattr4_posix_access_acl<>;
240+
241+
%/*
242+
% * New for POSIX ACL extension
243+
% */
244+
const FATTR4_ACL_TRUEFORM = 89;
245+
const FATTR4_ACL_TRUEFORM_SCOPE = 90;
246+
const FATTR4_POSIX_DEFAULT_ACL = 91;
247+
const FATTR4_POSIX_ACCESS_ACL = 92;

fs/lockd/svc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ lockd(void *vrqstp)
141141
*/
142142
while (!svc_thread_should_stop(rqstp)) {
143143
nlmsvc_retry_blocked(rqstp);
144-
svc_recv(rqstp);
144+
svc_recv(rqstp, 0);
145145
}
146146
if (nlmsvc_ops)
147147
nlmsvc_invalidate_all();
@@ -340,7 +340,7 @@ static int lockd_get(void)
340340
return -ENOMEM;
341341
}
342342

343-
error = svc_set_num_threads(serv, NULL, 1);
343+
error = svc_set_num_threads(serv, 0, 1);
344344
if (error < 0) {
345345
svc_destroy(&serv);
346346
return error;
@@ -368,7 +368,7 @@ static void lockd_put(void)
368368
unregister_inet6addr_notifier(&lockd_inet6addr_notifier);
369369
#endif
370370

371-
svc_set_num_threads(nlmsvc_serv, NULL, 0);
371+
svc_set_num_threads(nlmsvc_serv, 0, 0);
372372
timer_delete_sync(&nlmsvc_retry);
373373
svc_destroy(&nlmsvc_serv);
374374
dprintk("lockd_down: service destroyed\n");

fs/lockd/svclock.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
641641
conflock->fl.c.flc_owner = lock->fl.c.flc_owner;
642642
error = vfs_test_lock(file->f_file[mode], &conflock->fl);
643643
if (error) {
644-
/* We can't currently deal with deferred test requests */
645-
if (error == FILE_LOCK_DEFERRED)
646-
WARN_ON_ONCE(1);
647-
648644
ret = nlm_lck_denied_nolocks;
649645
goto out;
650646
}

fs/locks.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,12 +2262,23 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
22622262
*/
22632263
int vfs_test_lock(struct file *filp, struct file_lock *fl)
22642264
{
2265+
int error = 0;
2266+
22652267
WARN_ON_ONCE(fl->fl_ops || fl->fl_lmops);
22662268
WARN_ON_ONCE(filp != fl->c.flc_file);
22672269
if (filp->f_op->lock)
2268-
return filp->f_op->lock(filp, F_GETLK, fl);
2269-
posix_test_lock(filp, fl);
2270-
return 0;
2270+
error = filp->f_op->lock(filp, F_GETLK, fl);
2271+
else
2272+
posix_test_lock(filp, fl);
2273+
2274+
/*
2275+
* We don't expect FILE_LOCK_DEFERRED and callers cannot
2276+
* handle it.
2277+
*/
2278+
if (WARN_ON_ONCE(error == FILE_LOCK_DEFERRED))
2279+
error = -EIO;
2280+
2281+
return error;
22712282
}
22722283
EXPORT_SYMBOL_GPL(vfs_test_lock);
22732284

fs/nfs/callback.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ nfs4_callback_svc(void *vrqstp)
8181
set_freezable();
8282

8383
while (!svc_thread_should_stop(rqstp))
84-
svc_recv(rqstp);
84+
svc_recv(rqstp, 0);
8585

8686
svc_exit_thread(rqstp);
8787
return 0;
@@ -119,9 +119,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
119119
if (serv->sv_nrthreads == nrservs)
120120
return 0;
121121

122-
ret = svc_set_num_threads(serv, NULL, nrservs);
122+
ret = svc_set_num_threads(serv, 0, nrservs);
123123
if (ret) {
124-
svc_set_num_threads(serv, NULL, 0);
124+
svc_set_num_threads(serv, 0, 0);
125125
return ret;
126126
}
127127
dprintk("nfs_callback_up: service started\n");
@@ -242,7 +242,7 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
242242
cb_info->users++;
243243
err_net:
244244
if (!cb_info->users) {
245-
svc_set_num_threads(cb_info->serv, NULL, 0);
245+
svc_set_num_threads(cb_info->serv, 0, 0);
246246
svc_destroy(&cb_info->serv);
247247
}
248248
err_create:
@@ -268,7 +268,7 @@ void nfs_callback_down(int minorversion, struct net *net, struct rpc_xprt *xprt)
268268
nfs_callback_down_net(minorversion, serv, net);
269269
cb_info->users--;
270270
if (cb_info->users == 0) {
271-
svc_set_num_threads(serv, NULL, 0);
271+
svc_set_num_threads(serv, 0, 0);
272272
dprintk("nfs_callback_down: service destroyed\n");
273273
xprt_svc_destroy_nullify_bc(xprt, &cb_info->serv);
274274
}

fs/nfsd/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,22 @@ config NFSD_V4_DELEG_TIMESTAMPS
186186
draft-ietf-nfsv4-delstid-08 "Extending the Opening of Files". This
187187
is currently an experimental feature and is therefore left disabled
188188
by default.
189+
190+
config NFSD_V4_POSIX_ACLS
191+
bool "Support NFSv4 POSIX draft ACLs"
192+
depends on NFSD_V4
193+
default n
194+
help
195+
Include experimental support for POSIX Access Control Lists
196+
(ACLs) in NFSv4 as specified in the IETF draft
197+
draft-ietf-nfsv4-posix-acls. This protocol extension enables
198+
NFSv4 clients to retrieve and modify POSIX ACLs on exported
199+
filesystems that support them.
200+
201+
This feature is based on an unratified IETF draft
202+
specification that may change in ways that impact
203+
interoperability with existing clients. Enable only for
204+
testing environments or when interoperability with specific
205+
clients that implement this draft is required.
206+
207+
If unsure, say N.

fs/nfsd/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ nfsd-$(CONFIG_NFSD_FLEXFILELAYOUT) += flexfilelayout.o flexfilelayoutxdr.o
2626
nfsd-$(CONFIG_NFS_LOCALIO) += localio.o
2727
nfsd-$(CONFIG_DEBUG_FS) += debugfs.o
2828

29-
29+
#
30+
# XDR code generation (requires Python and additional packages)
31+
#
32+
# The generated *xdr_gen.{h,c} files are checked into git. Normal kernel
33+
# builds do not require the xdrgen tool or its Python dependencies.
34+
#
35+
# Developers modifying .x files in Documentation/sunrpc/xdr/ should run
36+
# "make xdrgen" to regenerate the affected files.
37+
#
3038
.PHONY: xdrgen
3139

3240
xdrgen: ../../include/linux/sunrpc/xdrgen/nfs4_1.h nfs4xdr_gen.h nfs4xdr_gen.c

fs/nfsd/acl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ int nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
4949
struct nfs4_acl **acl);
5050
__be32 nfsd4_acl_to_attr(enum nfs_ftype4 type, struct nfs4_acl *acl,
5151
struct nfsd_attrs *attr);
52+
void sort_pacl_range(struct posix_acl *pacl, int start, int end);
5253

5354
#endif /* LINUX_NFS4_ACL_H */

fs/nfsd/netlink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED + 1] = {
2424
};
2525

2626
/* NFSD_CMD_THREADS_SET - do */
27-
static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_SCOPE + 1] = {
27+
static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_MIN_THREADS + 1] = {
2828
[NFSD_A_SERVER_THREADS] = { .type = NLA_U32, },
2929
[NFSD_A_SERVER_GRACETIME] = { .type = NLA_U32, },
3030
[NFSD_A_SERVER_LEASETIME] = { .type = NLA_U32, },
3131
[NFSD_A_SERVER_SCOPE] = { .type = NLA_NUL_STRING, },
32+
[NFSD_A_SERVER_MIN_THREADS] = { .type = NLA_U32, },
3233
};
3334

3435
/* NFSD_CMD_VERSION_SET - do */
@@ -57,7 +58,7 @@ static const struct genl_split_ops nfsd_nl_ops[] = {
5758
.cmd = NFSD_CMD_THREADS_SET,
5859
.doit = nfsd_nl_threads_set_doit,
5960
.policy = nfsd_threads_set_nl_policy,
60-
.maxattr = NFSD_A_SERVER_SCOPE,
61+
.maxattr = NFSD_A_SERVER_MIN_THREADS,
6162
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
6263
},
6364
{

0 commit comments

Comments
 (0)