Skip to content

Commit

Permalink
Merge tag 'nfsd-6.12' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/cel/linux

Pull nfsd updates from Chuck Lever:
 "Notable features of this release include:

   - Pre-requisites for automatically determining the RPC server thread
     count

   - Clean-up and preparation for supporting LOCALIO, which will be
     merged via the NFS client tree

   - Enhancements and fixes to NFSv4.2 COPY offload

   - A new Python-based tool for generating kernel SunRPC XDR encoding
     and decoding functions, added as an aid for prototyping features in
     protocols based on the Linux kernel's SunRPC implementation

  As always I am grateful to the NFSD contributors, reviewers, testers,
  and bug reporters who participated during this cycle"

* tag 'nfsd-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (57 commits)
  xdrgen: Prevent reordering of encoder and decoder functions
  xdrgen: typedefs should use the built-in string and opaque functions
  xdrgen: Fix return code checking in built-in XDR decoders
  tools: Add xdrgen
  nfsd: fix delegation_blocked() to block correctly for at least 30 seconds
  nfsd: fix initial getattr on write delegation
  nfsd: untangle code in nfsd4_deleg_getattr_conflict()
  nfsd: enforce upper limit for namelen in __cld_pipe_inprogress_downcall()
  nfsd: return -EINVAL when namelen is 0
  NFSD: Wrap async copy operations with trace points
  NFSD: Clean up extra whitespace in trace_nfsd_copy_done
  NFSD: Record the callback stateid in copy tracepoints
  NFSD: Display copy stateids with conventional print formatting
  NFSD: Limit the number of concurrent async COPY operations
  NFSD: Async COPY result needs to return a write verifier
  nfsd: avoid races with wake_up_var()
  nfsd: use clear_and_wake_up_bit()
  sunrpc: xprtrdma: Use ERR_CAST() to return
  NFSD: Annotate struct pnfs_block_deviceaddr with __counted_by()
  nfsd: call cache_put if xdr_reserve_space returns NULL
  ...
  • Loading branch information
torvalds committed Sep 23, 2024
2 parents 721068d + 509abfc commit 18ba603
Show file tree
Hide file tree
Showing 200 changed files with 4,955 additions and 495 deletions.
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ Christian Brauner <[email protected]> <[email protected]>
Christian Marangi <[email protected]>
Christophe Ricard <[email protected]>
Christoph Hellwig <[email protected]>
Chuck Lever <[email protected]> <[email protected]>
Chuck Lever <[email protected]> <[email protected]>
Chuck Lever <[email protected]> <[email protected]>
Claudiu Beznea <[email protected]> <[email protected]>
Colin Ian King <[email protected]> <[email protected]>
Corey Minyard <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ nlm_bind_host(struct nlm_host *host)
if ((clnt = host->h_rpcclnt) != NULL) {
nlm_rebind_host(host);
} else {
unsigned long increment = nlmsvc_timeout;
unsigned long increment = nlm_timeout * HZ;
struct rpc_timeout timeparms = {
.to_initval = increment,
.to_increment = increment,
Expand Down
9 changes: 3 additions & 6 deletions fs/lockd/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ EXPORT_SYMBOL_GPL(nlmsvc_ops);
static DEFINE_MUTEX(nlmsvc_mutex);
static unsigned int nlmsvc_users;
static struct svc_serv *nlmsvc_serv;
unsigned long nlmsvc_timeout;

static void nlmsvc_request_retry(struct timer_list *tl)
{
Expand All @@ -68,7 +67,7 @@ unsigned int lockd_net_id;
* and also changed through the sysctl interface. -- Jamie Lokier, Aug 2003
*/
static unsigned long nlm_grace_period;
static unsigned long nlm_timeout = LOCKD_DFLT_TIMEO;
unsigned long nlm_timeout = LOCKD_DFLT_TIMEO;
static int nlm_udpport, nlm_tcpport;

/* RLIM_NOFILE defaults to 1024. That seems like a reasonable default here. */
Expand Down Expand Up @@ -125,6 +124,8 @@ lockd(void *vrqstp)
struct net *net = &init_net;
struct lockd_net *ln = net_generic(net, lockd_net_id);

svc_thread_init_status(rqstp, 0);

/* try_to_freeze() is called from svc_recv() */
set_freezable();

Expand Down Expand Up @@ -333,10 +334,6 @@ static int lockd_get(void)
printk(KERN_WARNING
"lockd_up: no pid, %d users??\n", nlmsvc_users);

if (!nlm_timeout)
nlm_timeout = LOCKD_DFLT_TIMEO;
nlmsvc_timeout = nlm_timeout * HZ;

serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, lockd);
if (!serv) {
printk(KERN_WARNING "lockd_up: create service failed\n");
Expand Down
2 changes: 2 additions & 0 deletions fs/nfs/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ nfs4_callback_svc(void *vrqstp)
{
struct svc_rqst *rqstp = vrqstp;

svc_thread_init_status(rqstp, 0);

set_freezable();

while (!svc_thread_should_stop(rqstp))
Expand Down
14 changes: 7 additions & 7 deletions fs/nfsd/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@
#include "nfsd.h"
#include "auth.h"

int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
int nfsexp_flags(struct svc_cred *cred, struct svc_export *exp)
{
struct exp_flavor_info *f;
struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;

for (f = exp->ex_flavors; f < end; f++) {
if (f->pseudoflavor == rqstp->rq_cred.cr_flavor)
if (f->pseudoflavor == cred->cr_flavor)
return f->flags;
}
return exp->ex_flags;

}

int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp)
{
struct group_info *rqgi;
struct group_info *gi;
struct cred *new;
int i;
int flags = nfsexp_flags(rqstp, exp);
int flags = nfsexp_flags(cred, exp);

/* discard any old override before preparing the new set */
revert_creds(get_cred(current_real_cred()));
new = prepare_creds();
if (!new)
return -ENOMEM;

new->fsuid = rqstp->rq_cred.cr_uid;
new->fsgid = rqstp->rq_cred.cr_gid;
new->fsuid = cred->cr_uid;
new->fsgid = cred->cr_gid;

rqgi = rqstp->rq_cred.cr_group_info;
rqgi = cred->cr_group_info;

if (flags & NFSEXP_ALLSQUASH) {
new->fsuid = exp->ex_anon_uid;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
* Set the current process's fsuid/fsgid etc to those of the NFS
* client user
*/
int nfsd_setuser(struct svc_rqst *, struct svc_export *);
int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp);

#endif /* LINUX_NFSD_AUTH_H */
6 changes: 2 additions & 4 deletions fs/nfsd/blocklayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ nfsd4_block_get_device_info_simple(struct super_block *sb,
struct pnfs_block_deviceaddr *dev;
struct pnfs_block_volume *b;

dev = kzalloc(sizeof(struct pnfs_block_deviceaddr) +
sizeof(struct pnfs_block_volume), GFP_KERNEL);
dev = kzalloc(struct_size(dev, volumes, 1), GFP_KERNEL);
if (!dev)
return -ENOMEM;
gdp->gd_device = dev;
Expand Down Expand Up @@ -255,8 +254,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb,
const struct pr_ops *ops;
int ret;

dev = kzalloc(sizeof(struct pnfs_block_deviceaddr) +
sizeof(struct pnfs_block_volume), GFP_KERNEL);
dev = kzalloc(struct_size(dev, volumes, 1), GFP_KERNEL);
if (!dev)
return -ENOMEM;
gdp->gd_device = dev;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/blocklayoutxdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct pnfs_block_volume {

struct pnfs_block_deviceaddr {
u32 nr_volumes;
struct pnfs_block_volume volumes[];
struct pnfs_block_volume volumes[] __counted_by(nr_volumes);
};

__be32 nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr,
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define NFSCACHE_H

#include <linux/sunrpc/svc.h>
#include "netns.h"
#include "nfsd.h"

/*
* Representation of a reply cache entry.
Expand Down
37 changes: 27 additions & 10 deletions fs/nfsd/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp)
return 0;

denied:
return rqstp->rq_vers < 4 ? nfserr_acces : nfserr_wrongsec;
return nfserr_wrongsec;
}

/*
Expand Down Expand Up @@ -1164,19 +1164,35 @@ rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
return gssexp;
}

/**
* rqst_exp_find - Find an svc_export in the context of a rqst or similar
* @reqp: The handle to be used to suspend the request if a cache-upcall is needed
* If NULL, missing in-cache information will result in failure.
* @net: The network namespace in which the request exists
* @cl: default auth_domain to use for looking up the export
* @gsscl: an alternate auth_domain defined using deprecated gss/krb5 format.
* @fsid_type: The type of fsid to look for
* @fsidv: The actual fsid to look up in the context of either client.
*
* Perform a lookup for @cl/@fsidv in the given @net for an export. If
* none found and @gsscl specified, repeat the lookup.
*
* Returns an export, or an error pointer.
*/
struct svc_export *
rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
rqst_exp_find(struct cache_req *reqp, struct net *net,
struct auth_domain *cl, struct auth_domain *gsscl,
int fsid_type, u32 *fsidv)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
struct cache_detail *cd = nn->svc_export_cache;

if (rqstp->rq_client == NULL)
if (!cl)
goto gss;

/* First try the auth_unix client: */
exp = exp_find(cd, rqstp->rq_client, fsid_type,
fsidv, &rqstp->rq_chandle);
exp = exp_find(cd, cl, fsid_type, fsidv, reqp);
if (PTR_ERR(exp) == -ENOENT)
goto gss;
if (IS_ERR(exp))
Expand All @@ -1186,10 +1202,9 @@ rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
return exp;
gss:
/* Otherwise, try falling back on gss client */
if (rqstp->rq_gssclient == NULL)
if (!gsscl)
return exp;
gssexp = exp_find(cd, rqstp->rq_gssclient, fsid_type, fsidv,
&rqstp->rq_chandle);
gssexp = exp_find(cd, gsscl, fsid_type, fsidv, reqp);
if (PTR_ERR(gssexp) == -ENOENT)
return exp;
if (!IS_ERR(exp))
Expand Down Expand Up @@ -1220,7 +1235,9 @@ struct svc_export *rqst_find_fsidzero_export(struct svc_rqst *rqstp)

mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);

return rqst_exp_find(rqstp, FSID_NUM, fsidv);
return rqst_exp_find(&rqstp->rq_chandle, SVC_NET(rqstp),
rqstp->rq_client, rqstp->rq_gssclient,
FSID_NUM, fsidv);
}

/*
Expand Down
7 changes: 5 additions & 2 deletions fs/nfsd/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ struct svc_expkey {
#define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
#define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)

int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
struct svc_cred;
int nfsexp_flags(struct svc_cred *cred, struct svc_export *exp);
__be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);

/*
Expand Down Expand Up @@ -127,6 +128,8 @@ static inline struct svc_export *exp_get(struct svc_export *exp)
cache_get(&exp->h);
return exp;
}
struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
struct svc_export *rqst_exp_find(struct cache_req *reqp, struct net *net,
struct auth_domain *cl, struct auth_domain *gsscl,
int fsid_type, u32 *fsidv);

#endif /* NFSD_EXPORT_H */
Loading

0 comments on commit 18ba603

Please sign in to comment.