Skip to content

Commit 06cbd26

Browse files
committed
Merge tag 'nfs-for-5.2-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "Highlights include: Stable bugfixes: - Fall back to MDS if no deviceid is found rather than aborting # v4.11+ - NFS4: Fix v4.0 client state corruption when mount Features: - Much improved handling of soft mounts with NFS v4.0: - Reduce risk of false positive timeouts - Faster failover of reads and writes after a timeout - Added a "softerr" mount option to return ETIMEDOUT instead of EIO to the application after a timeout - Increase number of xprtrdma backchannel requests - Add additional xprtrdma tracepoints - Improved send completion batching for xprtrdma Other bugfixes and cleanups: - Return -EINVAL when NFS v4.2 is passed an invalid dedup mode - Reduce usage of GFP_ATOMIC pages in SUNRPC - Various minor NFS over RDMA cleanups and bugfixes - Use the correct container namespace for upcalls - Don't share superblocks between user namespaces - Various other container fixes - Make nfs_match_client() killable to prevent soft lockups - Don't mark all open state for recovery when handling recallable state revoked flag" * tag 'nfs-for-5.2-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (69 commits) SUNRPC: Rebalance a kref in auth_gss.c NFS: Fix a double unlock from nfs_match,get_client nfs: pass the correct prototype to read_cache_page NFSv4: don't mark all open state for recovery when handling recallable state revoked flag SUNRPC: Fix an error code in gss_alloc_msg() SUNRPC: task should be exit if encode return EKEYEXPIRED more times NFS4: Fix v4.0 client state corruption when mount PNFS fallback to MDS if no deviceid found NFS: make nfs_match_client killable lockd: Store the lockd client credential in struct nlm_host NFS: When mounting, don't share filesystems between different user namespaces NFS: Convert NFSv2 to use the container user namespace NFSv4: Convert the NFS client idmapper to use the container user namespace NFS: Convert NFSv3 to use the container user namespace SUNRPC: Use namespace of listening daemon in the client AUTH_GSS upcall SUNRPC: Use the client user namespace when encoding creds NFS: Store the credential of the mount process in the nfs_server SUNRPC: Cache cred of process creating the rpc_client xprtrdma: Remove stale comment xprtrdma: Update comments that reference ib_drain_qp ...
2 parents abde77e + 5940d1c commit 06cbd26

59 files changed

Lines changed: 1366 additions & 946 deletions

Some content is hidden

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

‎fs/lockd/clntlock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
6363
host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen,
6464
nlm_init->protocol, nlm_version,
6565
nlm_init->hostname, nlm_init->noresvport,
66-
nlm_init->net);
66+
nlm_init->net, nlm_init->cred);
6767
if (host == NULL)
6868
goto out_nohost;
6969
if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL)

‎fs/lockd/clntproc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
715715
struct nlm_rqst *req = data;
716716
u32 status = ntohl(req->a_res.status);
717717

718-
if (RPC_ASSASSINATED(task))
718+
if (RPC_SIGNALLED(task))
719719
goto die;
720720

721721
if (task->tk_status < 0) {
@@ -783,7 +783,7 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
783783
struct nlm_rqst *req = data;
784784
u32 status = ntohl(req->a_res.status);
785785

786-
if (RPC_ASSASSINATED(task))
786+
if (RPC_SIGNALLED(task))
787787
goto die;
788788

789789
if (task->tk_status < 0) {

‎fs/lockd/host.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct nlm_lookup_host_info {
6060
const size_t hostname_len; /* it's length */
6161
const int noresvport; /* use non-priv port */
6262
struct net *net; /* network namespace to bind */
63+
const struct cred *cred;
6364
};
6465

6566
/*
@@ -162,6 +163,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
162163
host->h_nsmhandle = nsm;
163164
host->h_addrbuf = nsm->sm_addrbuf;
164165
host->net = ni->net;
166+
host->h_cred = get_cred(ni->cred),
165167
strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename));
166168

167169
out:
@@ -188,6 +190,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
188190
clnt = host->h_rpcclnt;
189191
if (clnt != NULL)
190192
rpc_shutdown_client(clnt);
193+
put_cred(host->h_cred);
191194
kfree(host);
192195

193196
ln->nrhosts--;
@@ -202,6 +205,8 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
202205
* @version: NLM protocol version
203206
* @hostname: '\0'-terminated hostname of server
204207
* @noresvport: 1 if non-privileged port should be used
208+
* @net: pointer to net namespace
209+
* @cred: pointer to cred
205210
*
206211
* Returns an nlm_host structure that matches the passed-in
207212
* [server address, transport protocol, NLM version, server hostname].
@@ -214,7 +219,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
214219
const u32 version,
215220
const char *hostname,
216221
int noresvport,
217-
struct net *net)
222+
struct net *net,
223+
const struct cred *cred)
218224
{
219225
struct nlm_lookup_host_info ni = {
220226
.server = 0,
@@ -226,6 +232,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
226232
.hostname_len = strlen(hostname),
227233
.noresvport = noresvport,
228234
.net = net,
235+
.cred = cred,
229236
};
230237
struct hlist_head *chain;
231238
struct nlm_host *host;
@@ -458,6 +465,7 @@ nlm_bind_host(struct nlm_host *host)
458465
.authflavor = RPC_AUTH_UNIX,
459466
.flags = (RPC_CLNT_CREATE_NOPING |
460467
RPC_CLNT_CREATE_AUTOBIND),
468+
.cred = host->h_cred,
461469
};
462470

463471
/*

‎fs/lockd/mon.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static struct rpc_clnt *nsm_create(struct net *net, const char *nodename)
8282
.version = NSM_VERSION,
8383
.authflavor = RPC_AUTH_NULL,
8484
.flags = RPC_CLNT_CREATE_NOPING,
85+
.cred = current_cred(),
8586
};
8687

8788
return rpc_create(&args);

‎fs/nfs/client.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
284284
struct nfs_client *clp;
285285
const struct sockaddr *sap = data->addr;
286286
struct nfs_net *nn = net_generic(data->net, nfs_net_id);
287+
int error;
287288

288289
again:
289290
list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
@@ -296,9 +297,11 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
296297
if (clp->cl_cons_state > NFS_CS_READY) {
297298
refcount_inc(&clp->cl_count);
298299
spin_unlock(&nn->nfs_client_lock);
299-
nfs_wait_client_init_complete(clp);
300+
error = nfs_wait_client_init_complete(clp);
300301
nfs_put_client(clp);
301302
spin_lock(&nn->nfs_client_lock);
303+
if (error < 0)
304+
return ERR_PTR(error);
302305
goto again;
303306
}
304307

@@ -407,6 +410,8 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
407410
clp = nfs_match_client(cl_init);
408411
if (clp) {
409412
spin_unlock(&nn->nfs_client_lock);
413+
if (IS_ERR(clp))
414+
return clp;
410415
if (new)
411416
new->rpc_ops->free_client(new);
412417
return nfs_found_client(cl_init, clp);
@@ -500,6 +505,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
500505
.program = &nfs_program,
501506
.version = clp->rpc_ops->version,
502507
.authflavor = flavor,
508+
.cred = cl_init->cred,
503509
};
504510

505511
if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags))
@@ -598,6 +604,8 @@ int nfs_init_server_rpcclient(struct nfs_server *server,
598604
sizeof(server->client->cl_timeout_default));
599605
server->client->cl_timeout = &server->client->cl_timeout_default;
600606
server->client->cl_softrtry = 0;
607+
if (server->flags & NFS_MOUNT_SOFTERR)
608+
server->client->cl_softerr = 1;
601609
if (server->flags & NFS_MOUNT_SOFT)
602610
server->client->cl_softrtry = 1;
603611

@@ -652,6 +660,7 @@ static int nfs_init_server(struct nfs_server *server,
652660
.proto = data->nfs_server.protocol,
653661
.net = data->net,
654662
.timeparms = &timeparms,
663+
.cred = server->cred,
655664
};
656665
struct nfs_client *clp;
657666
int error;
@@ -920,6 +929,7 @@ void nfs_free_server(struct nfs_server *server)
920929
ida_destroy(&server->lockowner_id);
921930
ida_destroy(&server->openowner_id);
922931
nfs_free_iostats(server->io_stats);
932+
put_cred(server->cred);
923933
kfree(server);
924934
nfs_release_automount_timer();
925935
}
@@ -940,6 +950,8 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
940950
if (!server)
941951
return ERR_PTR(-ENOMEM);
942952

953+
server->cred = get_cred(current_cred());
954+
943955
error = -ENOMEM;
944956
fattr = nfs_alloc_fattr();
945957
if (fattr == NULL)
@@ -1006,6 +1018,8 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
10061018
if (!server)
10071019
return ERR_PTR(-ENOMEM);
10081020

1021+
server->cred = get_cred(source->cred);
1022+
10091023
error = -ENOMEM;
10101024
fattr_fsinfo = nfs_alloc_fattr();
10111025
if (fattr_fsinfo == NULL)

‎fs/nfs/delegation.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,18 @@ void nfs_mark_test_expired_all_delegations(struct nfs_client *clp)
10331033
rcu_read_unlock();
10341034
}
10351035

1036+
/**
1037+
* nfs_test_expired_all_delegations - test all delegations for a client
1038+
* @clp: nfs_client to process
1039+
*
1040+
* Helper for handling "recallable state revoked" status from server.
1041+
*/
1042+
void nfs_test_expired_all_delegations(struct nfs_client *clp)
1043+
{
1044+
nfs_mark_test_expired_all_delegations(clp);
1045+
nfs4_schedule_state_manager(clp);
1046+
}
1047+
10361048
/**
10371049
* nfs_reap_expired_delegations - reap expired delegations
10381050
* @clp: nfs_client to process

‎fs/nfs/delegation.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void nfs_delegation_mark_reclaim(struct nfs_client *clp);
5858
void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
5959

6060
void nfs_mark_test_expired_all_delegations(struct nfs_client *clp);
61+
void nfs_test_expired_all_delegations(struct nfs_client *clp);
6162
void nfs_reap_expired_delegations(struct nfs_client *clp);
6263

6364
/* NFSv4 delegation-related procedures */

‎fs/nfs/dir.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,9 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
714714
* We only need to convert from xdr once so future lookups are much simpler
715715
*/
716716
static
717-
int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page)
717+
int nfs_readdir_filler(void *data, struct page* page)
718718
{
719+
nfs_readdir_descriptor_t *desc = data;
719720
struct inode *inode = file_inode(desc->file);
720721
int ret;
721722

@@ -762,8 +763,8 @@ void cache_page_release(nfs_readdir_descriptor_t *desc)
762763
static
763764
struct page *get_cache_page(nfs_readdir_descriptor_t *desc)
764765
{
765-
return read_cache_page(desc->file->f_mapping,
766-
desc->page_index, (filler_t *)nfs_readdir_filler, desc);
766+
return read_cache_page(desc->file->f_mapping, desc->page_index,
767+
nfs_readdir_filler, desc);
767768
}
768769

769770
/*

‎fs/nfs/direct.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
492492
struct nfs_page *req;
493493
unsigned int req_len = min_t(size_t, bytes, PAGE_SIZE - pgbase);
494494
/* XXX do we need to do the eof zeroing found in async_filler? */
495-
req = nfs_create_request(dreq->ctx, pagevec[i], NULL,
495+
req = nfs_create_request(dreq->ctx, pagevec[i],
496496
pgbase, req_len);
497497
if (IS_ERR(req)) {
498498
result = PTR_ERR(req);
@@ -663,6 +663,8 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
663663
}
664664

665665
list_for_each_entry_safe(req, tmp, &reqs, wb_list) {
666+
/* Bump the transmission count */
667+
req->wb_nio++;
666668
if (!nfs_pageio_add_request(&desc, req)) {
667669
nfs_list_move_request(req, &failed);
668670
spin_lock(&cinfo.inode->i_lock);
@@ -703,6 +705,11 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)
703705
req = nfs_list_entry(data->pages.next);
704706
nfs_list_remove_request(req);
705707
if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) {
708+
/*
709+
* Despite the reboot, the write was successful,
710+
* so reset wb_nio.
711+
*/
712+
req->wb_nio = 0;
706713
/* Note the rewrite will go through mds */
707714
nfs_mark_request_commit(req, NULL, &cinfo, 0);
708715
} else
@@ -899,7 +906,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
899906
struct nfs_page *req;
900907
unsigned int req_len = min_t(size_t, bytes, PAGE_SIZE - pgbase);
901908

902-
req = nfs_create_request(dreq->ctx, pagevec[i], NULL,
909+
req = nfs_create_request(dreq->ctx, pagevec[i],
903910
pgbase, req_len);
904911
if (IS_ERR(req)) {
905912
result = PTR_ERR(req);

‎fs/nfs/file.c‎

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ nfs_file_flush(struct file *file, fl_owner_t id)
147147
return 0;
148148

149149
/* Flush writes to the server and return any errors */
150-
return vfs_fsync(file, 0);
150+
return nfs_wb_all(inode);
151151
}
152152

153153
ssize_t
@@ -199,13 +199,6 @@ EXPORT_SYMBOL_GPL(nfs_file_mmap);
199199
* Flush any dirty pages for this process, and check for write errors.
200200
* The return status from this call provides a reliable indication of
201201
* whether any write errors occurred for this process.
202-
*
203-
* Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to
204-
* disk, but it retrieves and clears ctx->error after synching, despite
205-
* the two being set at the same time in nfs_context_set_write_error().
206-
* This is because the former is used to notify the _next_ call to
207-
* nfs_file_write() that a write error occurred, and hence cause it to
208-
* fall back to doing a synchronous write.
209202
*/
210203
static int
211204
nfs_file_fsync_commit(struct file *file, int datasync)
@@ -220,11 +213,8 @@ nfs_file_fsync_commit(struct file *file, int datasync)
220213
nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
221214
do_resend = test_and_clear_bit(NFS_CONTEXT_RESEND_WRITES, &ctx->flags);
222215
status = nfs_commit_inode(inode, FLUSH_SYNC);
223-
if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags)) {
224-
ret = xchg(&ctx->error, 0);
225-
if (ret)
226-
goto out;
227-
}
216+
if (status == 0)
217+
status = file_check_and_advance_wb_err(file);
228218
if (status < 0) {
229219
ret = status;
230220
goto out;
@@ -245,13 +235,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
245235
trace_nfs_fsync_enter(inode);
246236

247237
do {
248-
struct nfs_open_context *ctx = nfs_file_open_context(file);
249-
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
250-
if (test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags)) {
251-
int ret2 = xchg(&ctx->error, 0);
252-
if (ret2)
253-
ret = ret2;
254-
}
238+
ret = file_write_and_wait_range(file, start, end);
255239
if (ret != 0)
256240
break;
257241
ret = nfs_file_fsync_commit(file, datasync);
@@ -600,8 +584,7 @@ static int nfs_need_check_write(struct file *filp, struct inode *inode)
600584
struct nfs_open_context *ctx;
601585

602586
ctx = nfs_file_open_context(filp);
603-
if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) ||
604-
nfs_ctx_key_to_expire(ctx, inode))
587+
if (nfs_ctx_key_to_expire(ctx, inode))
605588
return 1;
606589
return 0;
607590
}
@@ -655,7 +638,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
655638

656639
/* Return error values */
657640
if (nfs_need_check_write(file, inode)) {
658-
int err = vfs_fsync(file, 0);
641+
int err = nfs_wb_all(inode);
659642
if (err < 0)
660643
result = err;
661644
}
@@ -709,7 +692,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
709692
* Flush all pending writes before doing anything
710693
* with locks..
711694
*/
712-
vfs_fsync(filp, 0);
695+
nfs_wb_all(inode);
713696

714697
l_ctx = nfs_get_lock_context(nfs_file_open_context(filp));
715698
if (!IS_ERR(l_ctx)) {

0 commit comments

Comments
 (0)