mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 08:08:54 +00:00
NFS: sem2mutex idmap.c
semaphore to mutex conversion. the conversion was generated via scripts, and the result was validated automatically via a script as well. build and boot tested. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
bd6475454c
commit
c9d5128a10
1 changed files with 21 additions and 20 deletions
|
@ -35,6 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
@ -74,8 +75,8 @@ struct idmap {
|
||||||
struct dentry *idmap_dentry;
|
struct dentry *idmap_dentry;
|
||||||
wait_queue_head_t idmap_wq;
|
wait_queue_head_t idmap_wq;
|
||||||
struct idmap_msg idmap_im;
|
struct idmap_msg idmap_im;
|
||||||
struct semaphore idmap_lock; /* Serializes upcalls */
|
struct mutex idmap_lock; /* Serializes upcalls */
|
||||||
struct semaphore idmap_im_lock; /* Protects the hashtable */
|
struct mutex idmap_im_lock; /* Protects the hashtable */
|
||||||
struct idmap_hashtable idmap_user_hash;
|
struct idmap_hashtable idmap_user_hash;
|
||||||
struct idmap_hashtable idmap_group_hash;
|
struct idmap_hashtable idmap_group_hash;
|
||||||
};
|
};
|
||||||
|
@ -114,8 +115,8 @@ nfs_idmap_new(struct nfs4_client *clp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_MUTEX(&idmap->idmap_lock);
|
mutex_init(&idmap->idmap_lock);
|
||||||
init_MUTEX(&idmap->idmap_im_lock);
|
mutex_init(&idmap->idmap_im_lock);
|
||||||
init_waitqueue_head(&idmap->idmap_wq);
|
init_waitqueue_head(&idmap->idmap_wq);
|
||||||
idmap->idmap_user_hash.h_type = IDMAP_TYPE_USER;
|
idmap->idmap_user_hash.h_type = IDMAP_TYPE_USER;
|
||||||
idmap->idmap_group_hash.h_type = IDMAP_TYPE_GROUP;
|
idmap->idmap_group_hash.h_type = IDMAP_TYPE_GROUP;
|
||||||
|
@ -232,8 +233,8 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
if (namelen >= IDMAP_NAMESZ)
|
if (namelen >= IDMAP_NAMESZ)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
down(&idmap->idmap_lock);
|
mutex_lock(&idmap->idmap_lock);
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
he = idmap_lookup_name(h, name, namelen);
|
he = idmap_lookup_name(h, name, namelen);
|
||||||
if (he != NULL) {
|
if (he != NULL) {
|
||||||
|
@ -259,11 +260,11 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
}
|
}
|
||||||
|
|
||||||
set_current_state(TASK_UNINTERRUPTIBLE);
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
schedule();
|
schedule();
|
||||||
current->state = TASK_RUNNING;
|
current->state = TASK_RUNNING;
|
||||||
remove_wait_queue(&idmap->idmap_wq, &wq);
|
remove_wait_queue(&idmap->idmap_wq, &wq);
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
if (im->im_status & IDMAP_STATUS_SUCCESS) {
|
if (im->im_status & IDMAP_STATUS_SUCCESS) {
|
||||||
*id = im->im_id;
|
*id = im->im_id;
|
||||||
|
@ -272,8 +273,8 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
memset(im, 0, sizeof(*im));
|
memset(im, 0, sizeof(*im));
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
up(&idmap->idmap_lock);
|
mutex_unlock(&idmap->idmap_lock);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,8 +294,8 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
|
|
||||||
im = &idmap->idmap_im;
|
im = &idmap->idmap_im;
|
||||||
|
|
||||||
down(&idmap->idmap_lock);
|
mutex_lock(&idmap->idmap_lock);
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
he = idmap_lookup_id(h, id);
|
he = idmap_lookup_id(h, id);
|
||||||
if (he != 0) {
|
if (he != 0) {
|
||||||
|
@ -320,11 +321,11 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
}
|
}
|
||||||
|
|
||||||
set_current_state(TASK_UNINTERRUPTIBLE);
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
schedule();
|
schedule();
|
||||||
current->state = TASK_RUNNING;
|
current->state = TASK_RUNNING;
|
||||||
remove_wait_queue(&idmap->idmap_wq, &wq);
|
remove_wait_queue(&idmap->idmap_wq, &wq);
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
if (im->im_status & IDMAP_STATUS_SUCCESS) {
|
if (im->im_status & IDMAP_STATUS_SUCCESS) {
|
||||||
if ((len = strnlen(im->im_name, IDMAP_NAMESZ)) == 0)
|
if ((len = strnlen(im->im_name, IDMAP_NAMESZ)) == 0)
|
||||||
|
@ -335,8 +336,8 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
memset(im, 0, sizeof(*im));
|
memset(im, 0, sizeof(*im));
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
up(&idmap->idmap_lock);
|
mutex_unlock(&idmap->idmap_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +381,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
|
||||||
if (copy_from_user(&im_in, src, mlen) != 0)
|
if (copy_from_user(&im_in, src, mlen) != 0)
|
||||||
return (-EFAULT);
|
return (-EFAULT);
|
||||||
|
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
ret = mlen;
|
ret = mlen;
|
||||||
im->im_status = im_in.im_status;
|
im->im_status = im_in.im_status;
|
||||||
|
@ -440,7 +441,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);
|
idmap_update_entry(he, im_in.im_name, namelen_in, im_in.im_id);
|
||||||
ret = mlen;
|
ret = mlen;
|
||||||
out:
|
out:
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,10 +453,10 @@ idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
|
||||||
|
|
||||||
if (msg->errno >= 0)
|
if (msg->errno >= 0)
|
||||||
return;
|
return;
|
||||||
down(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
im->im_status = IDMAP_STATUS_LOOKUPFAIL;
|
im->im_status = IDMAP_STATUS_LOOKUPFAIL;
|
||||||
wake_up(&idmap->idmap_wq);
|
wake_up(&idmap->idmap_wq);
|
||||||
up(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue