aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/client.c10
-rw-r--r--fs/nfs/filelayout/filelayout.c12
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c12
-rw-r--r--fs/nfs/nfs4client.c10
-rw-r--r--fs/nfs/nfs4proc.c12
-rw-r--r--fs/nfs/nfs4state.c6
-rw-r--r--include/linux/nfs_fs_sb.h3
7 files changed, 33 insertions, 32 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 22880ef6d8dd..0ac2fb1c6b63 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -163,7 +163,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
163 163
164 clp->rpc_ops = clp->cl_nfs_mod->rpc_ops; 164 clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
165 165
166 atomic_set(&clp->cl_count, 1); 166 refcount_set(&clp->cl_count, 1);
167 clp->cl_cons_state = NFS_CS_INITING; 167 clp->cl_cons_state = NFS_CS_INITING;
168 168
169 memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen); 169 memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen);
@@ -269,7 +269,7 @@ void nfs_put_client(struct nfs_client *clp)
269 269
270 nn = net_generic(clp->cl_net, nfs_net_id); 270 nn = net_generic(clp->cl_net, nfs_net_id);
271 271
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)) {
273 list_del(&clp->cl_share_link); 273 list_del(&clp->cl_share_link);
274 nfs_cb_idr_remove_locked(clp); 274 nfs_cb_idr_remove_locked(clp);
275 spin_unlock(&nn->nfs_client_lock); 275 spin_unlock(&nn->nfs_client_lock);
@@ -314,7 +314,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
314 sap)) 314 sap))
315 continue; 315 continue;
316 316
317 atomic_inc(&clp->cl_count); 317 refcount_inc(&clp->cl_count);
318 return clp; 318 return clp;
319 } 319 }
320 return NULL; 320 return NULL;
@@ -1006,7 +1006,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
1006 /* Copy data from the source */ 1006 /* Copy data from the source */
1007 server->nfs_client = source->nfs_client; 1007 server->nfs_client = source->nfs_client;
1008 server->destroy = source->destroy; 1008 server->destroy = source->destroy;
1009 atomic_inc(&server->nfs_client->cl_count); 1009 refcount_inc(&server->nfs_client->cl_count);
1010 nfs_server_copy_userdata(server, source); 1010 nfs_server_copy_userdata(server, source);
1011 1011
1012 server->fsid = fattr->fsid; 1012 server->fsid = fattr->fsid;
@@ -1166,7 +1166,7 @@ static int nfs_server_list_show(struct seq_file *m, void *v)
1166 clp->rpc_ops->version, 1166 clp->rpc_ops->version,
1167 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR), 1167 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1168 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT), 1168 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1169 atomic_read(&clp->cl_count), 1169 refcount_read(&clp->cl_count),
1170 clp->cl_hostname); 1170 clp->cl_hostname);
1171 rcu_read_unlock(); 1171 rcu_read_unlock();
1172 1172
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 508126eb49f9..4e54d8b5413a 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -471,10 +471,10 @@ filelayout_read_pagelist(struct nfs_pgio_header *hdr)
471 return PNFS_NOT_ATTEMPTED; 471 return PNFS_NOT_ATTEMPTED;
472 472
473 dprintk("%s USE DS: %s cl_count %d\n", __func__, 473 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));
475 475
476 /* No multipath support. Use first DS */ 476 /* No multipath support. Use first DS */
477 atomic_inc(&ds->ds_clp->cl_count); 477 refcount_inc(&ds->ds_clp->cl_count);
478 hdr->ds_clp = ds->ds_clp; 478 hdr->ds_clp = ds->ds_clp;
479 hdr->ds_commit_idx = idx; 479 hdr->ds_commit_idx = idx;
480 fh = nfs4_fl_select_ds_fh(lseg, j); 480 fh = nfs4_fl_select_ds_fh(lseg, j);
@@ -515,10 +515,10 @@ filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
515 515
516 dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d\n", 516 dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d\n",
517 __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count, 517 __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));
519 519
520 hdr->pgio_done_cb = filelayout_write_done_cb; 520 hdr->pgio_done_cb = filelayout_write_done_cb;
521 atomic_inc(&ds->ds_clp->cl_count); 521 refcount_inc(&ds->ds_clp->cl_count);
522 hdr->ds_clp = ds->ds_clp; 522 hdr->ds_clp = ds->ds_clp;
523 hdr->ds_commit_idx = idx; 523 hdr->ds_commit_idx = idx;
524 fh = nfs4_fl_select_ds_fh(lseg, j); 524 fh = nfs4_fl_select_ds_fh(lseg, j);
@@ -1064,9 +1064,9 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
1064 goto out_err; 1064 goto out_err;
1065 1065
1066 dprintk("%s ino %lu, how %d cl_count %d\n", __func__, 1066 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));
1068 data->commit_done_cb = filelayout_commit_done_cb; 1068 data->commit_done_cb = filelayout_commit_done_cb;
1069 atomic_inc(&ds->ds_clp->cl_count); 1069 refcount_inc(&ds->ds_clp->cl_count);
1070 data->ds_clp = ds->ds_clp; 1070 data->ds_clp = ds->ds_clp;
1071 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index); 1071 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
1072 if (fh) 1072 if (fh)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index ff55a0a1b2e8..c75ad982bcfc 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1726,10 +1726,10 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
1726 vers = nfs4_ff_layout_ds_version(lseg, idx); 1726 vers = nfs4_ff_layout_ds_version(lseg, idx);
1727 1727
1728 dprintk("%s USE DS: %s cl_count %d vers %d\n", __func__, 1728 dprintk("%s USE DS: %s cl_count %d vers %d\n", __func__,
1729 ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count), vers); 1729 ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count), vers);
1730 1730
1731 hdr->pgio_done_cb = ff_layout_read_done_cb; 1731 hdr->pgio_done_cb = ff_layout_read_done_cb;
1732 atomic_inc(&ds->ds_clp->cl_count); 1732 refcount_inc(&ds->ds_clp->cl_count);
1733 hdr->ds_clp = ds->ds_clp; 1733 hdr->ds_clp = ds->ds_clp;
1734 fh = nfs4_ff_layout_select_ds_fh(lseg, idx); 1734 fh = nfs4_ff_layout_select_ds_fh(lseg, idx);
1735 if (fh) 1735 if (fh)
@@ -1785,11 +1785,11 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
1785 1785
1786 dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d vers %d\n", 1786 dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d vers %d\n",
1787 __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count, 1787 __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count,
1788 offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count), 1788 offset, ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count),
1789 vers); 1789 vers);
1790 1790
1791 hdr->pgio_done_cb = ff_layout_write_done_cb; 1791 hdr->pgio_done_cb = ff_layout_write_done_cb;
1792 atomic_inc(&ds->ds_clp->cl_count); 1792 refcount_inc(&ds->ds_clp->cl_count);
1793 hdr->ds_clp = ds->ds_clp; 1793 hdr->ds_clp = ds->ds_clp;
1794 hdr->ds_commit_idx = idx; 1794 hdr->ds_commit_idx = idx;
1795 fh = nfs4_ff_layout_select_ds_fh(lseg, idx); 1795 fh = nfs4_ff_layout_select_ds_fh(lseg, idx);
@@ -1863,11 +1863,11 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
1863 vers = nfs4_ff_layout_ds_version(lseg, idx); 1863 vers = nfs4_ff_layout_ds_version(lseg, idx);
1864 1864
1865 dprintk("%s ino %lu, how %d cl_count %d vers %d\n", __func__, 1865 dprintk("%s ino %lu, how %d cl_count %d vers %d\n", __func__,
1866 data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count), 1866 data->inode->i_ino, how, refcount_read(&ds->ds_clp->cl_count),
1867 vers); 1867 vers);
1868 data->commit_done_cb = ff_layout_commit_done_cb; 1868 data->commit_done_cb = ff_layout_commit_done_cb;
1869 data->cred = ds_cred; 1869 data->cred = ds_cred;
1870 atomic_inc(&ds->ds_clp->cl_count); 1870 refcount_inc(&ds->ds_clp->cl_count);
1871 data->ds_clp = ds->ds_clp; 1871 data->ds_clp = ds->ds_clp;
1872 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index); 1872 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
1873 if (fh) 1873 if (fh)
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index e9bea90dc017..31b5bc0f10a4 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -483,7 +483,7 @@ static int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
483 * ID and serverowner fields. Wait for CREATE_SESSION 483 * ID and serverowner fields. Wait for CREATE_SESSION
484 * to finish. */ 484 * to finish. */
485 if (pos->cl_cons_state > NFS_CS_READY) { 485 if (pos->cl_cons_state > NFS_CS_READY) {
486 atomic_inc(&pos->cl_count); 486 refcount_inc(&pos->cl_count);
487 spin_unlock(&nn->nfs_client_lock); 487 spin_unlock(&nn->nfs_client_lock);
488 488
489 nfs_put_client(*prev); 489 nfs_put_client(*prev);
@@ -559,7 +559,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
559 * way that a SETCLIENTID_CONFIRM to pos can succeed is 559 * way that a SETCLIENTID_CONFIRM to pos can succeed is
560 * if new and pos point to the same server: 560 * if new and pos point to the same server:
561 */ 561 */
562 atomic_inc(&pos->cl_count); 562 refcount_inc(&pos->cl_count);
563 spin_unlock(&nn->nfs_client_lock); 563 spin_unlock(&nn->nfs_client_lock);
564 564
565 nfs_put_client(prev); 565 nfs_put_client(prev);
@@ -715,7 +715,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
715 continue; 715 continue;
716 716
717found: 717found:
718 atomic_inc(&pos->cl_count); 718 refcount_inc(&pos->cl_count);
719 *result = pos; 719 *result = pos;
720 status = 0; 720 status = 0;
721 break; 721 break;
@@ -749,7 +749,7 @@ nfs4_find_client_ident(struct net *net, int cb_ident)
749 spin_lock(&nn->nfs_client_lock); 749 spin_lock(&nn->nfs_client_lock);
750 clp = idr_find(&nn->cb_ident_idr, cb_ident); 750 clp = idr_find(&nn->cb_ident_idr, cb_ident);
751 if (clp) 751 if (clp)
752 atomic_inc(&clp->cl_count); 752 refcount_inc(&clp->cl_count);
753 spin_unlock(&nn->nfs_client_lock); 753 spin_unlock(&nn->nfs_client_lock);
754 return clp; 754 return clp;
755} 755}
@@ -804,7 +804,7 @@ nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr,
804 sid->data, NFS4_MAX_SESSIONID_LEN) != 0) 804 sid->data, NFS4_MAX_SESSIONID_LEN) != 0)
805 continue; 805 continue;
806 806
807 atomic_inc(&clp->cl_count); 807 refcount_inc(&clp->cl_count);
808 spin_unlock(&nn->nfs_client_lock); 808 spin_unlock(&nn->nfs_client_lock);
809 return clp; 809 return clp;
810 } 810 }
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index be8c75a2cbbe..82e5ed2ee6ba 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4870,7 +4870,7 @@ static void nfs4_renew_release(void *calldata)
4870 struct nfs4_renewdata *data = calldata; 4870 struct nfs4_renewdata *data = calldata;
4871 struct nfs_client *clp = data->client; 4871 struct nfs_client *clp = data->client;
4872 4872
4873 if (atomic_read(&clp->cl_count) > 1) 4873 if (refcount_read(&clp->cl_count) > 1)
4874 nfs4_schedule_state_renewal(clp); 4874 nfs4_schedule_state_renewal(clp);
4875 nfs_put_client(clp); 4875 nfs_put_client(clp);
4876 kfree(data); 4876 kfree(data);
@@ -4918,7 +4918,7 @@ static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred,
4918 4918
4919 if (renew_flags == 0) 4919 if (renew_flags == 0)
4920 return 0; 4920 return 0;
4921 if (!atomic_inc_not_zero(&clp->cl_count)) 4921 if (!refcount_inc_not_zero(&clp->cl_count))
4922 return -EIO; 4922 return -EIO;
4923 data = kmalloc(sizeof(*data), GFP_NOFS); 4923 data = kmalloc(sizeof(*data), GFP_NOFS);
4924 if (data == NULL) { 4924 if (data == NULL) {
@@ -7499,7 +7499,7 @@ nfs4_run_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
7499 struct nfs41_exchange_id_data *calldata; 7499 struct nfs41_exchange_id_data *calldata;
7500 int status; 7500 int status;
7501 7501
7502 if (!atomic_inc_not_zero(&clp->cl_count)) 7502 if (!refcount_inc_not_zero(&clp->cl_count))
7503 return ERR_PTR(-EIO); 7503 return ERR_PTR(-EIO);
7504 7504
7505 status = -ENOMEM; 7505 status = -ENOMEM;
@@ -8099,7 +8099,7 @@ static void nfs41_sequence_release(void *data)
8099 struct nfs4_sequence_data *calldata = data; 8099 struct nfs4_sequence_data *calldata = data;
8100 struct nfs_client *clp = calldata->clp; 8100 struct nfs_client *clp = calldata->clp;
8101 8101
8102 if (atomic_read(&clp->cl_count) > 1) 8102 if (refcount_read(&clp->cl_count) > 1)
8103 nfs4_schedule_state_renewal(clp); 8103 nfs4_schedule_state_renewal(clp);
8104 nfs_put_client(clp); 8104 nfs_put_client(clp);
8105 kfree(calldata); 8105 kfree(calldata);
@@ -8128,7 +8128,7 @@ static void nfs41_sequence_call_done(struct rpc_task *task, void *data)
8128 trace_nfs4_sequence(clp, task->tk_status); 8128 trace_nfs4_sequence(clp, task->tk_status);
8129 if (task->tk_status < 0) { 8129 if (task->tk_status < 0) {
8130 dprintk("%s ERROR %d\n", __func__, task->tk_status); 8130 dprintk("%s ERROR %d\n", __func__, task->tk_status);
8131 if (atomic_read(&clp->cl_count) == 1) 8131 if (refcount_read(&clp->cl_count) == 1)
8132 goto out; 8132 goto out;
8133 8133
8134 if (nfs41_sequence_handle_errors(task, clp) == -EAGAIN) { 8134 if (nfs41_sequence_handle_errors(task, clp) == -EAGAIN) {
@@ -8179,7 +8179,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
8179 struct rpc_task *ret; 8179 struct rpc_task *ret;
8180 8180
8181 ret = ERR_PTR(-EIO); 8181 ret = ERR_PTR(-EIO);
8182 if (!atomic_inc_not_zero(&clp->cl_count)) 8182 if (!refcount_inc_not_zero(&clp->cl_count))
8183 goto out_err; 8183 goto out_err;
8184 8184
8185 ret = ERR_PTR(-ENOMEM); 8185 ret = ERR_PTR(-ENOMEM);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 1887134d5231..3bd79b8c016b 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1177,7 +1177,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
1177 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0) 1177 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
1178 return; 1178 return;
1179 __module_get(THIS_MODULE); 1179 __module_get(THIS_MODULE);
1180 atomic_inc(&clp->cl_count); 1180 refcount_inc(&clp->cl_count);
1181 1181
1182 /* The rcu_read_lock() is not strictly necessary, as the state 1182 /* The rcu_read_lock() is not strictly necessary, as the state
1183 * manager is the only thread that ever changes the rpc_xprt 1183 * manager is the only thread that ever changes the rpc_xprt
@@ -1269,7 +1269,7 @@ int nfs4_wait_clnt_recover(struct nfs_client *clp)
1269 1269
1270 might_sleep(); 1270 might_sleep();
1271 1271
1272 atomic_inc(&clp->cl_count); 1272 refcount_inc(&clp->cl_count);
1273 res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING, 1273 res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING,
1274 nfs_wait_bit_killable, TASK_KILLABLE); 1274 nfs_wait_bit_killable, TASK_KILLABLE);
1275 if (res) 1275 if (res)
@@ -2510,7 +2510,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
2510 break; 2510 break;
2511 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0) 2511 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
2512 break; 2512 break;
2513 } while (atomic_read(&clp->cl_count) > 1); 2513 } while (refcount_read(&clp->cl_count) > 1);
2514 return; 2514 return;
2515out_error: 2515out_error:
2516 if (strlen(section)) 2516 if (strlen(section))
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 74c44665e6d3..efcfe9ded9ea 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -9,6 +9,7 @@
9#include <linux/sunrpc/xprt.h> 9#include <linux/sunrpc/xprt.h>
10 10
11#include <linux/atomic.h> 11#include <linux/atomic.h>
12#include <linux/refcount.h>
12 13
13struct nfs4_session; 14struct nfs4_session;
14struct nfs_iostats; 15struct nfs_iostats;
@@ -24,7 +25,7 @@ struct nfs41_impl_id;
24 * The nfs_client identifies our client state to the server. 25 * The nfs_client identifies our client state to the server.
25 */ 26 */
26struct nfs_client { 27struct nfs_client {
27 atomic_t cl_count; 28 refcount_t cl_count;
28 atomic_t cl_mds_count; 29 atomic_t cl_mds_count;
29 int cl_cons_state; /* current construction state (-ve: init error) */ 30 int cl_cons_state; /* current construction state (-ve: init error) */
30#define NFS_CS_READY 0 /* ready to be used */ 31#define NFS_CS_READY 0 /* ready to be used */