aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-09-28 12:03:09 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-09-28 12:27:11 -0400
commit0e24d849c4ea777c59955b241fd3af14a1b84af5 (patch)
tree040025f1f7439395233591cdece544708e8ec333 /fs/nfs
parent62d98c935456ee121b03d6a68aa3091a04085b7e (diff)
NFSv4: Remove BUG_ON() and ACCESS_ONCE() calls in the idmapper
The use of ACCESS_ONCE() is wrong, since the various routines that set/clear idmap->idmap_key_cons should be strictly ordered w.r.t. each other, and the idmap->idmap_mutex ensures that only one thread at a time may be in an upcall situation. Also replace the BUG_ON()s with WARN_ON_ONCE() where appropriate. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/idmap.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index a850079467d8..79f6424aa081 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -465,8 +465,6 @@ nfs_idmap_new(struct nfs_client *clp)
465 struct rpc_pipe *pipe; 465 struct rpc_pipe *pipe;
466 int error; 466 int error;
467 467
468 BUG_ON(clp->cl_idmap != NULL);
469
470 idmap = kzalloc(sizeof(*idmap), GFP_KERNEL); 468 idmap = kzalloc(sizeof(*idmap), GFP_KERNEL);
471 if (idmap == NULL) 469 if (idmap == NULL)
472 return -ENOMEM; 470 return -ENOMEM;
@@ -510,7 +508,6 @@ static int __rpc_pipefs_event(struct nfs_client *clp, unsigned long event,
510 508
511 switch (event) { 509 switch (event) {
512 case RPC_PIPEFS_MOUNT: 510 case RPC_PIPEFS_MOUNT:
513 BUG_ON(clp->cl_rpcclient->cl_dentry == NULL);
514 err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry, 511 err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry,
515 clp->cl_idmap, 512 clp->cl_idmap,
516 clp->cl_idmap->idmap_pipe); 513 clp->cl_idmap->idmap_pipe);
@@ -689,7 +686,11 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
689 if (ret < 0) 686 if (ret < 0)
690 goto out2; 687 goto out2;
691 688
692 BUG_ON(idmap->idmap_key_cons != NULL); 689 if (idmap->idmap_key_cons != NULL) {
690 WARN_ON_ONCE(1);
691 ret = -EAGAIN;
692 goto out2;
693 }
693 idmap->idmap_key_cons = cons; 694 idmap->idmap_key_cons = cons;
694 695
695 ret = rpc_queue_upcall(idmap->idmap_pipe, msg); 696 ret = rpc_queue_upcall(idmap->idmap_pipe, msg);
@@ -746,7 +747,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
746 * will have been woken up and someone else may now have used 747 * will have been woken up and someone else may now have used
747 * idmap_key_cons - so after this point we may no longer touch it. 748 * idmap_key_cons - so after this point we may no longer touch it.
748 */ 749 */
749 cons = ACCESS_ONCE(idmap->idmap_key_cons); 750 cons = idmap->idmap_key_cons;
750 idmap->idmap_key_cons = NULL; 751 idmap->idmap_key_cons = NULL;
751 752
752 if (mlen != sizeof(im)) { 753 if (mlen != sizeof(im)) {
@@ -790,7 +791,7 @@ idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
790 struct idmap *idmap = data->idmap; 791 struct idmap *idmap = data->idmap;
791 struct key_construction *cons; 792 struct key_construction *cons;
792 if (msg->errno) { 793 if (msg->errno) {
793 cons = ACCESS_ONCE(idmap->idmap_key_cons); 794 cons = idmap->idmap_key_cons;
794 idmap->idmap_key_cons = NULL; 795 idmap->idmap_key_cons = NULL;
795 complete_request_key(cons, msg->errno); 796 complete_request_key(cons, msg->errno);
796 } 797 }