Skip to content

Commit f43574d

Browse files
committed
Merge tag 'nfs-for-5.6-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Puyll NFS client updates from Anna Schumaker: "Stable bugfixes: - Fix memory leaks and corruption in readdir # v2.6.37+ - Directory page cache needs to be locked when read # v2.6.37+ New features: - Convert NFS to use the new mount API - Add "softreval" mount option to let clients use cache if server goes down - Add a config option to compile without UDP support - Limit the number of inactive delegations the client can cache at once - Improved readdir concurrency using iterate_shared() Other bugfixes and cleanups: - More 64-bit time conversions - Add additional diagnostic tracepoints - Check for holes in swapfiles, and add dependency on CONFIG_SWAP - Various xprtrdma cleanups to prepare for 5.7's changes - Several fixes for NFS writeback and commit handling - Fix acls over krb5i/krb5p mounts - Recover from premature loss of openstateids - Fix NFS v3 chacl and chmod bug - Compare creds using cred_fscmp() - Use kmemdup_nul() in more places - Optimize readdir cache page invalidation - Lease renewal and recovery fixes" * tag 'nfs-for-5.6-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (93 commits) NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals NFSv4: try lease recovery on NFS4ERR_EXPIRED NFS: Fix memory leaks nfs: optimise readdir cache page invalidation NFS: Switch readdir to using iterate_shared() NFS: Use kmemdup_nul() in nfs_readdir_make_qstr() NFS: Directory page cache pages need to be locked when read NFS: Fix memory leaks and corruption in readdir SUNRPC: Use kmemdup_nul() in rpc_parse_scope_id() NFS: Replace various occurrences of kstrndup() with kmemdup_nul() NFSv4: Limit the total number of cached delegations NFSv4: Add accounting for the number of active delegations held NFSv4: Try to return the delegation immediately when marked for return on close NFS: Clear NFS_DELEGATION_RETURN_IF_CLOSED when the delegation is returned NFSv4: nfs_inode_evict_delegation() should set NFS_DELEGATION_RETURNING NFS: nfs_find_open_context() should use cred_fscmp() NFS: nfs_access_get_cached_rcu() should use cred_fscmp() NFSv4: pnfs_roc() must use cred_fscmp() to compare creds NFS: remove unused macros nfs: Return EINVAL rather than ERANGE for mount parse errors ...
2 parents 41dcd67 + 7dc2993 commit f43574d

63 files changed

Lines changed: 3348 additions & 3032 deletions

Some content is hidden

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

‎fs/nfs/Kconfig‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ config NFS_V4
9090
config NFS_SWAP
9191
bool "Provide swap over NFS support"
9292
default n
93-
depends on NFS_FS
93+
depends on NFS_FS && SWAP
9494
select SUNRPC_SWAP
9595
help
9696
This option enables swapon to work on files located on NFS mounts.
@@ -196,3 +196,12 @@ config NFS_DEBUG
196196
depends on NFS_FS && SUNRPC_DEBUG
197197
select CRC32
198198
default y
199+
200+
config NFS_DISABLE_UDP_SUPPORT
201+
bool "NFS: Disable NFS UDP protocol support"
202+
depends on NFS_FS
203+
default y
204+
help
205+
Choose Y here to disable the use of NFS over UDP. NFS over UDP
206+
on modern networks (1Gb+) can lead to data corruption caused by
207+
fragmentation during high loads.

‎fs/nfs/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CFLAGS_nfstrace.o += -I$(src)
99
nfs-y := client.o dir.o file.o getroot.o inode.o super.o \
1010
io.o direct.o pagelist.o read.o symlink.o unlink.o \
1111
write.o namespace.o mount_clnt.o nfstrace.o \
12-
export.o sysfs.o
12+
export.o sysfs.o fs_context.o
1313
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
1414
nfs-$(CONFIG_SYSCTL) += sysctl.o
1515
nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o

‎fs/nfs/callback_xdr.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "callback.h"
1919
#include "internal.h"
2020
#include "nfs4session.h"
21+
#include "nfs4trace.h"
2122

2223
#define CB_OP_TAGLEN_MAXSZ (512)
2324
#define CB_OP_HDR_RES_MAXSZ (2 * 4) // opcode, status
@@ -946,9 +947,13 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
946947

947948
if (hdr_arg.minorversion == 0) {
948949
cps.clp = nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident);
949-
if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) {
950-
if (cps.clp)
951-
nfs_put_client(cps.clp);
950+
if (!cps.clp) {
951+
trace_nfs_cb_no_clp(rqstp->rq_xid, hdr_arg.cb_ident);
952+
goto out_invalidcred;
953+
}
954+
if (!check_gss_callback_principal(cps.clp, rqstp)) {
955+
trace_nfs_cb_badprinc(rqstp->rq_xid, hdr_arg.cb_ident);
956+
nfs_put_client(cps.clp);
952957
goto out_invalidcred;
953958
}
954959
}

‎fs/nfs/client.c‎

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
474474
to->to_maxval = to->to_initval;
475475
to->to_exponential = 0;
476476
break;
477+
#ifndef CONFIG_NFS_DISABLE_UDP_SUPPORT
477478
case XPRT_TRANSPORT_UDP:
478479
if (retrans == NFS_UNSPEC_RETRANS)
479480
to->to_retries = NFS_DEF_UDP_RETRANS;
@@ -484,6 +485,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
484485
to->to_maxval = NFS_MAX_UDP_TIMEOUT;
485486
to->to_exponential = 1;
486487
break;
488+
#endif
487489
default:
488490
BUG();
489491
}
@@ -580,8 +582,10 @@ static int nfs_start_lockd(struct nfs_server *server)
580582
default:
581583
nlm_init.protocol = IPPROTO_TCP;
582584
break;
585+
#ifndef CONFIG_NFS_DISABLE_UDP_SUPPORT
583586
case XPRT_TRANSPORT_UDP:
584587
nlm_init.protocol = IPPROTO_UDP;
588+
#endif
585589
}
586590

587591
host = nlmclnt_init(&nlm_init);
@@ -658,28 +662,28 @@ EXPORT_SYMBOL_GPL(nfs_init_client);
658662
* Create a version 2 or 3 client
659663
*/
660664
static int nfs_init_server(struct nfs_server *server,
661-
const struct nfs_parsed_mount_data *data,
662-
struct nfs_subversion *nfs_mod)
665+
const struct fs_context *fc)
663666
{
667+
const struct nfs_fs_context *ctx = nfs_fc2context(fc);
664668
struct rpc_timeout timeparms;
665669
struct nfs_client_initdata cl_init = {
666-
.hostname = data->nfs_server.hostname,
667-
.addr = (const struct sockaddr *)&data->nfs_server.address,
668-
.addrlen = data->nfs_server.addrlen,
669-
.nfs_mod = nfs_mod,
670-
.proto = data->nfs_server.protocol,
671-
.net = data->net,
670+
.hostname = ctx->nfs_server.hostname,
671+
.addr = (const struct sockaddr *)&ctx->nfs_server.address,
672+
.addrlen = ctx->nfs_server.addrlen,
673+
.nfs_mod = ctx->nfs_mod,
674+
.proto = ctx->nfs_server.protocol,
675+
.net = fc->net_ns,
672676
.timeparms = &timeparms,
673677
.cred = server->cred,
674-
.nconnect = data->nfs_server.nconnect,
678+
.nconnect = ctx->nfs_server.nconnect,
675679
.init_flags = (1UL << NFS_CS_REUSEPORT),
676680
};
677681
struct nfs_client *clp;
678682
int error;
679683

680-
nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
681-
data->timeo, data->retrans);
682-
if (data->flags & NFS_MOUNT_NORESVPORT)
684+
nfs_init_timeout_values(&timeparms, ctx->nfs_server.protocol,
685+
ctx->timeo, ctx->retrans);
686+
if (ctx->flags & NFS_MOUNT_NORESVPORT)
683687
set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
684688

685689
/* Allocate or find a client reference we can use */
@@ -690,46 +694,46 @@ static int nfs_init_server(struct nfs_server *server,
690694
server->nfs_client = clp;
691695

692696
/* Initialise the client representation from the mount data */
693-
server->flags = data->flags;
694-
server->options = data->options;
697+
server->flags = ctx->flags;
698+
server->options = ctx->options;
695699
server->caps |= NFS_CAP_HARDLINKS|NFS_CAP_SYMLINKS|NFS_CAP_FILEID|
696700
NFS_CAP_MODE|NFS_CAP_NLINK|NFS_CAP_OWNER|NFS_CAP_OWNER_GROUP|
697701
NFS_CAP_ATIME|NFS_CAP_CTIME|NFS_CAP_MTIME;
698702

699-
if (data->rsize)
700-
server->rsize = nfs_block_size(data->rsize, NULL);
701-
if (data->wsize)
702-
server->wsize = nfs_block_size(data->wsize, NULL);
703+
if (ctx->rsize)
704+
server->rsize = nfs_block_size(ctx->rsize, NULL);
705+
if (ctx->wsize)
706+
server->wsize = nfs_block_size(ctx->wsize, NULL);
703707

704-
server->acregmin = data->acregmin * HZ;
705-
server->acregmax = data->acregmax * HZ;
706-
server->acdirmin = data->acdirmin * HZ;
707-
server->acdirmax = data->acdirmax * HZ;
708+
server->acregmin = ctx->acregmin * HZ;
709+
server->acregmax = ctx->acregmax * HZ;
710+
server->acdirmin = ctx->acdirmin * HZ;
711+
server->acdirmax = ctx->acdirmax * HZ;
708712

709713
/* Start lockd here, before we might error out */
710714
error = nfs_start_lockd(server);
711715
if (error < 0)
712716
goto error;
713717

714-
server->port = data->nfs_server.port;
715-
server->auth_info = data->auth_info;
718+
server->port = ctx->nfs_server.port;
719+
server->auth_info = ctx->auth_info;
716720

717721
error = nfs_init_server_rpcclient(server, &timeparms,
718-
data->selected_flavor);
722+
ctx->selected_flavor);
719723
if (error < 0)
720724
goto error;
721725

722726
/* Preserve the values of mount_server-related mount options */
723-
if (data->mount_server.addrlen) {
724-
memcpy(&server->mountd_address, &data->mount_server.address,
725-
data->mount_server.addrlen);
726-
server->mountd_addrlen = data->mount_server.addrlen;
727+
if (ctx->mount_server.addrlen) {
728+
memcpy(&server->mountd_address, &ctx->mount_server.address,
729+
ctx->mount_server.addrlen);
730+
server->mountd_addrlen = ctx->mount_server.addrlen;
727731
}
728-
server->mountd_version = data->mount_server.version;
729-
server->mountd_port = data->mount_server.port;
730-
server->mountd_protocol = data->mount_server.protocol;
732+
server->mountd_version = ctx->mount_server.version;
733+
server->mountd_port = ctx->mount_server.port;
734+
server->mountd_protocol = ctx->mount_server.protocol;
731735

732-
server->namelen = data->namlen;
736+
server->namelen = ctx->namlen;
733737
return 0;
734738

735739
error:
@@ -951,9 +955,9 @@ EXPORT_SYMBOL_GPL(nfs_free_server);
951955
* Create a version 2 or 3 volume record
952956
* - keyed on server and FSID
953957
*/
954-
struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
955-
struct nfs_subversion *nfs_mod)
958+
struct nfs_server *nfs_create_server(struct fs_context *fc)
956959
{
960+
struct nfs_fs_context *ctx = nfs_fc2context(fc);
957961
struct nfs_server *server;
958962
struct nfs_fattr *fattr;
959963
int error;
@@ -970,27 +974,27 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
970974
goto error;
971975

972976
/* Get a client representation */
973-
error = nfs_init_server(server, mount_info->parsed, nfs_mod);
977+
error = nfs_init_server(server, fc);
974978
if (error < 0)
975979
goto error;
976980

977981
/* Probe the root fh to retrieve its FSID */
978-
error = nfs_probe_fsinfo(server, mount_info->mntfh, fattr);
982+
error = nfs_probe_fsinfo(server, ctx->mntfh, fattr);
979983
if (error < 0)
980984
goto error;
981985
if (server->nfs_client->rpc_ops->version == 3) {
982986
if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
983987
server->namelen = NFS3_MAXNAMLEN;
984-
if (!(mount_info->parsed->flags & NFS_MOUNT_NORDIRPLUS))
988+
if (!(ctx->flags & NFS_MOUNT_NORDIRPLUS))
985989
server->caps |= NFS_CAP_READDIRPLUS;
986990
} else {
987991
if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
988992
server->namelen = NFS2_MAXNAMLEN;
989993
}
990994

991995
if (!(fattr->valid & NFS_ATTR_FATTR)) {
992-
error = nfs_mod->rpc_ops->getattr(server, mount_info->mntfh,
993-
fattr, NULL, NULL);
996+
error = ctx->nfs_mod->rpc_ops->getattr(server, ctx->mntfh,
997+
fattr, NULL, NULL);
994998
if (error < 0) {
995999
dprintk("nfs_create_server: getattr error = %d\n", -error);
9961000
goto error;

0 commit comments

Comments
 (0)