NFS: Clean up fs/nfs/idmap.c
Clean up white space damage and use standard kernel coding conventions for return statements. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
committed by
Trond Myklebust
parent
7df089952f
commit
369af0f116
@@ -72,39 +72,39 @@ module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int,
|
|||||||
&nfs_idmap_cache_timeout, 0644);
|
&nfs_idmap_cache_timeout, 0644);
|
||||||
|
|
||||||
struct idmap_hashent {
|
struct idmap_hashent {
|
||||||
unsigned long ih_expires;
|
unsigned long ih_expires;
|
||||||
__u32 ih_id;
|
__u32 ih_id;
|
||||||
int ih_namelen;
|
int ih_namelen;
|
||||||
char ih_name[IDMAP_NAMESZ];
|
char ih_name[IDMAP_NAMESZ];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct idmap_hashtable {
|
struct idmap_hashtable {
|
||||||
__u8 h_type;
|
__u8 h_type;
|
||||||
struct idmap_hashent h_entries[IDMAP_HASH_SZ];
|
struct idmap_hashent h_entries[IDMAP_HASH_SZ];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct idmap {
|
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 mutex idmap_lock; /* Serializes upcalls */
|
struct mutex idmap_lock; /* Serializes upcalls */
|
||||||
struct mutex 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *,
|
static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *,
|
||||||
char __user *, size_t);
|
char __user *, size_t);
|
||||||
static ssize_t idmap_pipe_downcall(struct file *, const char __user *,
|
static ssize_t idmap_pipe_downcall(struct file *, const char __user *,
|
||||||
size_t);
|
size_t);
|
||||||
static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
|
static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
|
||||||
|
|
||||||
static unsigned int fnvhash32(const void *, size_t);
|
static unsigned int fnvhash32(const void *, size_t);
|
||||||
|
|
||||||
static struct rpc_pipe_ops idmap_upcall_ops = {
|
static struct rpc_pipe_ops idmap_upcall_ops = {
|
||||||
.upcall = idmap_pipe_upcall,
|
.upcall = idmap_pipe_upcall,
|
||||||
.downcall = idmap_pipe_downcall,
|
.downcall = idmap_pipe_downcall,
|
||||||
.destroy_msg = idmap_pipe_destroy_msg,
|
.destroy_msg = idmap_pipe_destroy_msg,
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -115,19 +115,20 @@ nfs_idmap_new(struct nfs_client *clp)
|
|||||||
|
|
||||||
BUG_ON(clp->cl_idmap != NULL);
|
BUG_ON(clp->cl_idmap != NULL);
|
||||||
|
|
||||||
if ((idmap = kzalloc(sizeof(*idmap), GFP_KERNEL)) == NULL)
|
idmap = kzalloc(sizeof(*idmap), GFP_KERNEL);
|
||||||
return -ENOMEM;
|
if (idmap == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
idmap->idmap_dentry = rpc_mkpipe(clp->cl_rpcclient->cl_dentry, "idmap",
|
idmap->idmap_dentry = rpc_mkpipe(clp->cl_rpcclient->cl_dentry, "idmap",
|
||||||
idmap, &idmap_upcall_ops, 0);
|
idmap, &idmap_upcall_ops, 0);
|
||||||
if (IS_ERR(idmap->idmap_dentry)) {
|
if (IS_ERR(idmap->idmap_dentry)) {
|
||||||
error = PTR_ERR(idmap->idmap_dentry);
|
error = PTR_ERR(idmap->idmap_dentry);
|
||||||
kfree(idmap);
|
kfree(idmap);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_init(&idmap->idmap_lock);
|
mutex_init(&idmap->idmap_lock);
|
||||||
mutex_init(&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;
|
||||||
@@ -285,7 +286,7 @@ nfs_idmap_id(struct idmap *idmap, struct idmap_hashtable *h,
|
|||||||
memset(im, 0, sizeof(*im));
|
memset(im, 0, sizeof(*im));
|
||||||
mutex_unlock(&idmap->idmap_im_lock);
|
mutex_unlock(&idmap->idmap_im_lock);
|
||||||
mutex_unlock(&idmap->idmap_lock);
|
mutex_unlock(&idmap->idmap_lock);
|
||||||
return (ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -354,16 +355,16 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
|
|||||||
/* RPC pipefs upcall/downcall routines */
|
/* RPC pipefs upcall/downcall routines */
|
||||||
static ssize_t
|
static ssize_t
|
||||||
idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
|
idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
|
||||||
char __user *dst, size_t buflen)
|
char __user *dst, size_t buflen)
|
||||||
{
|
{
|
||||||
char *data = (char *)msg->data + msg->copied;
|
char *data = (char *)msg->data + msg->copied;
|
||||||
ssize_t mlen = msg->len - msg->copied;
|
ssize_t mlen = msg->len - msg->copied;
|
||||||
ssize_t left;
|
ssize_t left;
|
||||||
|
|
||||||
if (mlen > buflen)
|
if (mlen > buflen)
|
||||||
mlen = buflen;
|
mlen = buflen;
|
||||||
|
|
||||||
left = copy_to_user(dst, data, mlen);
|
left = copy_to_user(dst, data, mlen);
|
||||||
if (left < 0) {
|
if (left < 0) {
|
||||||
msg->errno = left;
|
msg->errno = left;
|
||||||
return left;
|
return left;
|
||||||
@@ -371,13 +372,13 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
|
|||||||
mlen -= left;
|
mlen -= left;
|
||||||
msg->copied += mlen;
|
msg->copied += mlen;
|
||||||
msg->errno = 0;
|
msg->errno = 0;
|
||||||
return mlen;
|
return mlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
|
idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
|
||||||
{
|
{
|
||||||
struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
|
struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
|
||||||
struct idmap *idmap = (struct idmap *)rpci->private;
|
struct idmap *idmap = (struct idmap *)rpci->private;
|
||||||
struct idmap_msg im_in, *im = &idmap->idmap_im;
|
struct idmap_msg im_in, *im = &idmap->idmap_im;
|
||||||
struct idmap_hashtable *h;
|
struct idmap_hashtable *h;
|
||||||
@@ -385,11 +386,11 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
|
|||||||
int namelen_in;
|
int namelen_in;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (mlen != sizeof(im_in))
|
if (mlen != sizeof(im_in))
|
||||||
return (-ENOSPC);
|
return -ENOSPC;
|
||||||
|
|
||||||
if (copy_from_user(&im_in, src, mlen) != 0)
|
if (copy_from_user(&im_in, src, mlen) != 0)
|
||||||
return (-EFAULT);
|
return -EFAULT;
|
||||||
|
|
||||||
mutex_lock(&idmap->idmap_im_lock);
|
mutex_lock(&idmap->idmap_im_lock);
|
||||||
|
|
||||||
@@ -487,7 +488,7 @@ static unsigned int fnvhash32(const void *buf, size_t buflen)
|
|||||||
hash ^= (unsigned int)*p;
|
hash ^= (unsigned int)*p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (hash);
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid)
|
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid)
|
||||||
|
Reference in New Issue
Block a user