X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fnfs%2Fidmap.c;h=821edd30333b8aff740fc1e66a013527f967fcfc;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=3fab5b0cfc5ad8987829da40034b698aac435b77;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index 3fab5b0cf..821edd303 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c @@ -35,7 +35,6 @@ */ #include -#include #include #include #include @@ -75,8 +74,8 @@ struct idmap { struct dentry *idmap_dentry; wait_queue_head_t idmap_wq; struct idmap_msg idmap_im; - struct mutex idmap_lock; /* Serializes upcalls */ - struct mutex idmap_im_lock; /* Protects the hashtable */ + struct semaphore idmap_lock; /* Serializes upcalls */ + struct semaphore idmap_im_lock; /* Protects the hashtable */ struct idmap_hashtable idmap_user_hash; struct idmap_hashtable idmap_group_hash; }; @@ -102,9 +101,11 @@ nfs_idmap_new(struct nfs4_client *clp) if (clp->cl_idmap != NULL) return; - if ((idmap = kzalloc(sizeof(*idmap), GFP_KERNEL)) == NULL) + if ((idmap = kmalloc(sizeof(*idmap), GFP_KERNEL)) == NULL) return; + memset(idmap, 0, sizeof(*idmap)); + snprintf(idmap->idmap_path, sizeof(idmap->idmap_path), "%s/idmap", clp->cl_rpcclient->cl_pathname); @@ -115,8 +116,8 @@ nfs_idmap_new(struct nfs4_client *clp) return; } - mutex_init(&idmap->idmap_lock); - mutex_init(&idmap->idmap_im_lock); + init_MUTEX(&idmap->idmap_lock); + init_MUTEX(&idmap->idmap_im_lock); init_waitqueue_head(&idmap->idmap_wq); idmap->idmap_user_hash.h_type = IDMAP_TYPE_USER; idmap->idmap_group_hash.h_type = IDMAP_TYPE_GROUP; @@ -131,8 +132,6 @@ nfs_idmap_delete(struct nfs4_client *clp) if (!idmap) return; - dput(idmap->idmap_dentry); - idmap->idmap_dentry = NULL; rpc_unlink(idmap->idmap_path); clp->cl_idmap = NULL; kfree(idmap); @@ -233,8 +232,8 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h, if (namelen >= IDMAP_NAMESZ) return -EINVAL; - mutex_lock(&idmap->idmap_lock); - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_lock); + down(&idmap->idmap_im_lock); he = idmap_lookup_name(h, name, namelen); if (he != NULL) { @@ -260,11 +259,11 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h, } set_current_state(TASK_UNINTERRUPTIBLE); - mutex_unlock(&idmap->idmap_im_lock); + up(&idmap->idmap_im_lock); schedule(); current->state = TASK_RUNNING; remove_wait_queue(&idmap->idmap_wq, &wq); - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_im_lock); if (im->im_status & IDMAP_STATUS_SUCCESS) { *id = im->im_id; @@ -273,8 +272,8 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h, out: memset(im, 0, sizeof(*im)); - mutex_unlock(&idmap->idmap_im_lock); - mutex_unlock(&idmap->idmap_lock); + up(&idmap->idmap_im_lock); + up(&idmap->idmap_lock); return (ret); } @@ -294,8 +293,8 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h, im = &idmap->idmap_im; - mutex_lock(&idmap->idmap_lock); - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_lock); + down(&idmap->idmap_im_lock); he = idmap_lookup_id(h, id); if (he != 0) { @@ -321,11 +320,11 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h, } set_current_state(TASK_UNINTERRUPTIBLE); - mutex_unlock(&idmap->idmap_im_lock); + up(&idmap->idmap_im_lock); schedule(); current->state = TASK_RUNNING; remove_wait_queue(&idmap->idmap_wq, &wq); - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_im_lock); if (im->im_status & IDMAP_STATUS_SUCCESS) { if ((len = strnlen(im->im_name, IDMAP_NAMESZ)) == 0) @@ -336,8 +335,8 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h, out: memset(im, 0, sizeof(*im)); - mutex_unlock(&idmap->idmap_im_lock); - mutex_unlock(&idmap->idmap_lock); + up(&idmap->idmap_im_lock); + up(&idmap->idmap_lock); return ret; } @@ -381,7 +380,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) if (copy_from_user(&im_in, src, mlen) != 0) return (-EFAULT); - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_im_lock); ret = mlen; im->im_status = im_in.im_status; @@ -441,7 +440,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) idmap_update_entry(he, im_in.im_name, namelen_in, im_in.im_id); ret = mlen; out: - mutex_unlock(&idmap->idmap_im_lock); + up(&idmap->idmap_im_lock); return ret; } @@ -453,10 +452,10 @@ idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg) if (msg->errno >= 0) return; - mutex_lock(&idmap->idmap_im_lock); + down(&idmap->idmap_im_lock); im->im_status = IDMAP_STATUS_LOOKUPFAIL; wake_up(&idmap->idmap_wq); - mutex_unlock(&idmap->idmap_im_lock); + up(&idmap->idmap_im_lock); } /*