Skip to content

Commit c3e9c04

Browse files
committed
Merge tag 'nfs-for-4.15-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "Stable bugfixes: - Revalidate "." and ".." correctly on open - Avoid RCU usage in tracepoints - Fix ugly referral attributes - Fix a typo in nomigration mount option - Revert "NFS: Move the flock open mode check into nfs_flock()" Features: - Implement a stronger send queue accounting system for NFS over RDMA - Switch some atomics to the new refcount_t type Other bugfixes and cleanups: - Clean up access mode bits - Remove special-case revalidations in nfs_opendir() - Improve invalidating NFS over RDMA memory for async operations that time out - Handle NFS over RDMA replies with a worqueue - Handle NFS over RDMA sends with a workqueue - Fix up replaying interrupted requests - Remove dead NFS over RDMA definitions - Update NFS over RDMA copyright information - Be more consistent with bool initialization and comparisons - Mark expected switch fall throughs - Various sunrpc tracepoint cleanups - Fix various OPEN races - Fix a typo in nfs_rename() - Use common error handling code in nfs_lock_and_join_request() - Check that some structures are properly cleaned up during net_exit() - Remove net pointer from dprintk()s" * tag 'nfs-for-4.15-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (62 commits) NFS: Revert "NFS: Move the flock open mode check into nfs_flock()" NFS: Fix typo in nomigration mount option nfs: Fix ugly referral attributes NFS: super: mark expected switch fall-throughs sunrpc: remove net pointer from messages nfs: remove net pointer from messages sunrpc: exit_net cleanup check added nfs client: exit_net cleanup check added nfs/write: Use common error handling code in nfs_lock_and_join_requests() NFSv4: Replace closed stateids with the "invalid special stateid" NFSv4: nfs_set_open_stateid must not trigger state recovery for closed state NFSv4: Check the open stateid when searching for expired state NFSv4: Clean up nfs4_delegreturn_done NFSv4: cleanup nfs4_close_done NFSv4: Retry NFS4ERR_OLD_STATEID errors in layoutreturn pNFS: Retry NFS4ERR_OLD_STATEID errors in layoutreturn-on-close NFSv4: Don't try to CLOSE if the stateid 'other' field has changed NFSv4: Retry CLOSE and DELEGRETURN on NFS4ERR_OLD_STATEID. NFS: Fix a typo in nfs_rename() NFSv4: Fix open create exclusive when the server reboots ...
2 parents e0bcb42 + fcfa447 commit c3e9c04

43 files changed

Lines changed: 1191 additions & 716 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/cache_lib.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int nfs_cache_upcall(struct cache_detail *cd, char *entry_name)
6767
*/
6868
void nfs_cache_defer_req_put(struct nfs_cache_defer_req *dreq)
6969
{
70-
if (atomic_dec_and_test(&dreq->count))
70+
if (refcount_dec_and_test(&dreq->count))
7171
kfree(dreq);
7272
}
7373

@@ -87,7 +87,7 @@ static struct cache_deferred_req *nfs_dns_cache_defer(struct cache_req *req)
8787

8888
dreq = container_of(req, struct nfs_cache_defer_req, req);
8989
dreq->deferred_req.revisit = nfs_dns_cache_revisit;
90-
atomic_inc(&dreq->count);
90+
refcount_inc(&dreq->count);
9191

9292
return &dreq->deferred_req;
9393
}
@@ -99,7 +99,7 @@ struct nfs_cache_defer_req *nfs_cache_defer_req_alloc(void)
9999
dreq = kzalloc(sizeof(*dreq), GFP_KERNEL);
100100
if (dreq) {
101101
init_completion(&dreq->completion);
102-
atomic_set(&dreq->count, 1);
102+
refcount_set(&dreq->count, 1);
103103
dreq->req.defer = nfs_dns_cache_defer;
104104
}
105105
return dreq;

‎fs/nfs/cache_lib.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct nfs_cache_defer_req {
1616
struct cache_req req;
1717
struct cache_deferred_req deferred_req;
1818
struct completion completion;
19-
atomic_t count;
19+
refcount_t count;
2020
};
2121

2222
extern int nfs_cache_upcall(struct cache_detail *cd, char *entry_name);

‎fs/nfs/callback.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net)
4949
if (ret <= 0)
5050
goto out_err;
5151
nn->nfs_callback_tcpport = ret;
52-
dprintk("NFS: Callback listener port = %u (af %u, net %p)\n",
53-
nn->nfs_callback_tcpport, PF_INET, net);
52+
dprintk("NFS: Callback listener port = %u (af %u, net %x)\n",
53+
nn->nfs_callback_tcpport, PF_INET, net->ns.inum);
5454

5555
ret = svc_create_xprt(serv, "tcp", net, PF_INET6,
5656
nfs_callback_set_tcpport, SVC_SOCK_ANONYMOUS);
5757
if (ret > 0) {
5858
nn->nfs_callback_tcpport6 = ret;
59-
dprintk("NFS: Callback listener port = %u (af %u, net %p)\n",
60-
nn->nfs_callback_tcpport6, PF_INET6, net);
59+
dprintk("NFS: Callback listener port = %u (af %u, net %x\n",
60+
nn->nfs_callback_tcpport6, PF_INET6, net->ns.inum);
6161
} else if (ret != -EAFNOSUPPORT)
6262
goto out_err;
6363
return 0;
@@ -185,7 +185,7 @@ static void nfs_callback_down_net(u32 minorversion, struct svc_serv *serv, struc
185185
if (--nn->cb_users[minorversion])
186186
return;
187187

188-
dprintk("NFS: destroy per-net callback data; net=%p\n", net);
188+
dprintk("NFS: destroy per-net callback data; net=%x\n", net->ns.inum);
189189
svc_shutdown_net(serv, net);
190190
}
191191

@@ -198,7 +198,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
198198
if (nn->cb_users[minorversion]++)
199199
return 0;
200200

201-
dprintk("NFS: create per-net callback data; net=%p\n", net);
201+
dprintk("NFS: create per-net callback data; net=%x\n", net->ns.inum);
202202

203203
ret = svc_bind(serv, net);
204204
if (ret < 0) {
@@ -223,7 +223,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
223223
err_bind:
224224
nn->cb_users[minorversion]--;
225225
dprintk("NFS: Couldn't create callback socket: err = %d; "
226-
"net = %p\n", ret, net);
226+
"net = %x\n", ret, net->ns.inum);
227227
return ret;
228228
}
229229

‎fs/nfs/callback_proc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static bool referring_call_exists(struct nfs_client *clp,
440440
uint32_t nrclists,
441441
struct referring_call_list *rclists)
442442
{
443-
bool status = 0;
443+
bool status = false;
444444
int i, j;
445445
struct nfs4_session *session;
446446
struct nfs4_slot_table *tbl;

‎fs/nfs/client.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
163163

164164
clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
165165

166-
atomic_set(&clp->cl_count, 1);
166+
refcount_set(&clp->cl_count, 1);
167167
clp->cl_cons_state = NFS_CS_INITING;
168168

169169
memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen);
@@ -269,7 +269,7 @@ void nfs_put_client(struct nfs_client *clp)
269269

270270
nn = net_generic(clp->cl_net, nfs_net_id);
271271

272-
if (atomic_dec_and_lock(&clp->cl_count, &nn->nfs_client_lock)) {
272+
if (refcount_dec_and_lock(&clp->cl_count, &nn->nfs_client_lock)) {
273273
list_del(&clp->cl_share_link);
274274
nfs_cb_idr_remove_locked(clp);
275275
spin_unlock(&nn->nfs_client_lock);
@@ -314,7 +314,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
314314
sap))
315315
continue;
316316

317-
atomic_inc(&clp->cl_count);
317+
refcount_inc(&clp->cl_count);
318318
return clp;
319319
}
320320
return NULL;
@@ -1006,7 +1006,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
10061006
/* Copy data from the source */
10071007
server->nfs_client = source->nfs_client;
10081008
server->destroy = source->destroy;
1009-
atomic_inc(&server->nfs_client->cl_count);
1009+
refcount_inc(&server->nfs_client->cl_count);
10101010
nfs_server_copy_userdata(server, source);
10111011

10121012
server->fsid = fattr->fsid;
@@ -1166,7 +1166,7 @@ static int nfs_server_list_show(struct seq_file *m, void *v)
11661166
clp->rpc_ops->version,
11671167
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
11681168
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1169-
atomic_read(&clp->cl_count),
1169+
refcount_read(&clp->cl_count),
11701170
clp->cl_hostname);
11711171
rcu_read_unlock();
11721172

‎fs/nfs/delegation.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,33 @@ int nfs_delegations_present(struct nfs_client *clp)
10401040
return ret;
10411041
}
10421042

1043+
/**
1044+
* nfs4_refresh_delegation_stateid - Update delegation stateid seqid
1045+
* @dst: stateid to refresh
1046+
* @inode: inode to check
1047+
*
1048+
* Returns "true" and updates "dst->seqid" * if inode had a delegation
1049+
* that matches our delegation stateid. Otherwise "false" is returned.
1050+
*/
1051+
bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode)
1052+
{
1053+
struct nfs_delegation *delegation;
1054+
bool ret = false;
1055+
if (!inode)
1056+
goto out;
1057+
1058+
rcu_read_lock();
1059+
delegation = rcu_dereference(NFS_I(inode)->delegation);
1060+
if (delegation != NULL &&
1061+
nfs4_stateid_match_other(dst, &delegation->stateid)) {
1062+
dst->seqid = delegation->stateid.seqid;
1063+
return ret;
1064+
}
1065+
rcu_read_unlock();
1066+
out:
1067+
return ret;
1068+
}
1069+
10431070
/**
10441071
* nfs4_copy_delegation_stateid - Copy inode's state ID information
10451072
* @inode: inode to check

‎fs/nfs/delegation.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
6262
int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid, fmode_t type);
6363
int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid);
6464
bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, struct rpc_cred **cred);
65+
bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
6566

6667
void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
6768
int nfs4_have_delegation(struct inode *inode, fmode_t flags);

‎fs/nfs/dir.c‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ nfs_opendir(struct inode *inode, struct file *filp)
118118
goto out;
119119
}
120120
filp->private_data = ctx;
121-
if (filp->f_path.dentry == filp->f_path.mnt->mnt_root) {
122-
/* This is a mountpoint, so d_revalidate will never
123-
* have been called, so we need to refresh the
124-
* inode (for close-open consistency) ourselves.
125-
*/
126-
__nfs_revalidate_inode(NFS_SERVER(inode), inode);
127-
}
128121
out:
129122
put_rpccred(cred);
130123
return res;
@@ -253,7 +246,7 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
253246
desc->cache_entry_index = index;
254247
return 0;
255248
out_eof:
256-
desc->eof = 1;
249+
desc->eof = true;
257250
return -EBADCOOKIE;
258251
}
259252

@@ -307,7 +300,7 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
307300
if (array->eof_index >= 0) {
308301
status = -EBADCOOKIE;
309302
if (*desc->dir_cookie == array->last_cookie)
310-
desc->eof = 1;
303+
desc->eof = true;
311304
}
312305
out:
313306
return status;
@@ -761,7 +754,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc)
761754
ent = &array->array[i];
762755
if (!dir_emit(desc->ctx, ent->string.name, ent->string.len,
763756
nfs_compat_user_ino64(ent->ino), ent->d_type)) {
764-
desc->eof = 1;
757+
desc->eof = true;
765758
break;
766759
}
767760
desc->ctx->pos++;
@@ -773,7 +766,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc)
773766
ctx->duped = 1;
774767
}
775768
if (array->eof_index >= 0)
776-
desc->eof = 1;
769+
desc->eof = true;
777770

778771
kunmap(desc->page);
779772
cache_page_release(desc);
@@ -873,7 +866,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
873866
if (res == -EBADCOOKIE) {
874867
res = 0;
875868
/* This means either end of directory */
876-
if (*desc->dir_cookie && desc->eof == 0) {
869+
if (*desc->dir_cookie && !desc->eof) {
877870
/* Or that the server has 'lost' a cookie */
878871
res = uncached_readdir(desc);
879872
if (res == 0)
@@ -1241,8 +1234,7 @@ static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
12411234
return 0;
12421235
}
12431236

1244-
if (nfs_mapping_need_revalidate_inode(inode))
1245-
error = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
1237+
error = nfs_lookup_verify_inode(inode, flags);
12461238
dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n",
12471239
__func__, inode->i_ino, error ? "invalid" : "valid");
12481240
return !error;
@@ -1393,6 +1385,7 @@ static int nfs4_lookup_revalidate(struct dentry *, unsigned int);
13931385

13941386
const struct dentry_operations nfs4_dentry_operations = {
13951387
.d_revalidate = nfs4_lookup_revalidate,
1388+
.d_weak_revalidate = nfs_weak_revalidate,
13961389
.d_delete = nfs_dentry_delete,
13971390
.d_iput = nfs_dentry_iput,
13981391
.d_automount = nfs_d_automount,
@@ -2064,7 +2057,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
20642057
* should mark the directories for revalidation.
20652058
*/
20662059
d_move(old_dentry, new_dentry);
2067-
nfs_set_verifier(new_dentry,
2060+
nfs_set_verifier(old_dentry,
20682061
nfs_save_change_attribute(new_dir));
20692062
} else if (error == -ENOENT)
20702063
nfs_dentry_handle_enoent(old_dentry);
@@ -2369,15 +2362,15 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
23692362
}
23702363
EXPORT_SYMBOL_GPL(nfs_access_add_cache);
23712364

2372-
#define NFS_MAY_READ (NFS4_ACCESS_READ)
2373-
#define NFS_MAY_WRITE (NFS4_ACCESS_MODIFY | \
2374-
NFS4_ACCESS_EXTEND | \
2375-
NFS4_ACCESS_DELETE)
2376-
#define NFS_FILE_MAY_WRITE (NFS4_ACCESS_MODIFY | \
2377-
NFS4_ACCESS_EXTEND)
2365+
#define NFS_MAY_READ (NFS_ACCESS_READ)
2366+
#define NFS_MAY_WRITE (NFS_ACCESS_MODIFY | \
2367+
NFS_ACCESS_EXTEND | \
2368+
NFS_ACCESS_DELETE)
2369+
#define NFS_FILE_MAY_WRITE (NFS_ACCESS_MODIFY | \
2370+
NFS_ACCESS_EXTEND)
23782371
#define NFS_DIR_MAY_WRITE NFS_MAY_WRITE
2379-
#define NFS_MAY_LOOKUP (NFS4_ACCESS_LOOKUP)
2380-
#define NFS_MAY_EXECUTE (NFS4_ACCESS_EXECUTE)
2372+
#define NFS_MAY_LOOKUP (NFS_ACCESS_LOOKUP)
2373+
#define NFS_MAY_EXECUTE (NFS_ACCESS_EXECUTE)
23812374
static int
23822375
nfs_access_calc_mask(u32 access_result, umode_t umode)
23832376
{
@@ -2425,9 +2418,14 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)
24252418
if (!may_block)
24262419
goto out;
24272420

2428-
/* Be clever: ask server to check for all possible rights */
2429-
cache.mask = NFS_MAY_LOOKUP | NFS_MAY_EXECUTE
2430-
| NFS_MAY_WRITE | NFS_MAY_READ;
2421+
/*
2422+
* Determine which access bits we want to ask for...
2423+
*/
2424+
cache.mask = NFS_ACCESS_READ | NFS_ACCESS_MODIFY | NFS_ACCESS_EXTEND;
2425+
if (S_ISDIR(inode->i_mode))
2426+
cache.mask |= NFS_ACCESS_DELETE | NFS_ACCESS_LOOKUP;
2427+
else
2428+
cache.mask |= NFS_ACCESS_EXECUTE;
24312429
cache.cred = cred;
24322430
status = NFS_PROTO(inode)->access(inode, &cache);
24332431
if (status != 0) {

‎fs/nfs/file.c‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -829,23 +829,9 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
829829
if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FLOCK)
830830
is_local = 1;
831831

832-
/*
833-
* VFS doesn't require the open mode to match a flock() lock's type.
834-
* NFS, however, may simulate flock() locking with posix locking which
835-
* requires the open mode to match the lock type.
836-
*/
837-
switch (fl->fl_type) {
838-
case F_UNLCK:
832+
/* We're simulating flock() locks using posix locks on the server */
833+
if (fl->fl_type == F_UNLCK)
839834
return do_unlk(filp, cmd, fl, is_local);
840-
case F_RDLCK:
841-
if (!(filp->f_mode & FMODE_READ))
842-
return -EBADF;
843-
break;
844-
case F_WRLCK:
845-
if (!(filp->f_mode & FMODE_WRITE))
846-
return -EBADF;
847-
}
848-
849835
return do_setlk(filp, cmd, fl, is_local);
850836
}
851837
EXPORT_SYMBOL_GPL(nfs_flock);

‎fs/nfs/filelayout/filelayout.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ filelayout_read_pagelist(struct nfs_pgio_header *hdr)
471471
return PNFS_NOT_ATTEMPTED;
472472

473473
dprintk("%s USE DS: %s cl_count %d\n", __func__,
474-
ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
474+
ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count));
475475

476476
/* No multipath support. Use first DS */
477-
atomic_inc(&ds->ds_clp->cl_count);
477+
refcount_inc(&ds->ds_clp->cl_count);
478478
hdr->ds_clp = ds->ds_clp;
479479
hdr->ds_commit_idx = idx;
480480
fh = nfs4_fl_select_ds_fh(lseg, j);
@@ -515,10 +515,10 @@ filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
515515

516516
dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d\n",
517517
__func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count,
518-
offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
518+
offset, ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count));
519519

520520
hdr->pgio_done_cb = filelayout_write_done_cb;
521-
atomic_inc(&ds->ds_clp->cl_count);
521+
refcount_inc(&ds->ds_clp->cl_count);
522522
hdr->ds_clp = ds->ds_clp;
523523
hdr->ds_commit_idx = idx;
524524
fh = nfs4_fl_select_ds_fh(lseg, j);
@@ -1064,9 +1064,9 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
10641064
goto out_err;
10651065

10661066
dprintk("%s ino %lu, how %d cl_count %d\n", __func__,
1067-
data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count));
1067+
data->inode->i_ino, how, refcount_read(&ds->ds_clp->cl_count));
10681068
data->commit_done_cb = filelayout_commit_done_cb;
1069-
atomic_inc(&ds->ds_clp->cl_count);
1069+
refcount_inc(&ds->ds_clp->cl_count);
10701070
data->ds_clp = ds->ds_clp;
10711071
fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
10721072
if (fh)

0 commit comments

Comments
 (0)