Commit 57b47a53 authored by Ingo Molnar's avatar Ingo Molnar Committed by David S. Miller

[NET]: sem2mutex part 2

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6613f82d
...@@ -36,7 +36,7 @@ struct svc_sock { ...@@ -36,7 +36,7 @@ struct svc_sock {
struct list_head sk_deferred; /* deferred requests that need to struct list_head sk_deferred; /* deferred requests that need to
* be revisted */ * be revisted */
struct semaphore sk_sem; /* to serialize sending data */ struct mutex sk_mutex; /* to serialize sending data */
int (*sk_recvfrom)(struct svc_rqst *rqstp); int (*sk_recvfrom)(struct svc_rqst *rqstp);
int (*sk_sendto)(struct svc_rqst *rqstp); int (*sk_sendto)(struct svc_rqst *rqstp);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/un.h> #include <linux/un.h>
#include <linux/mutex.h>
#include <net/sock.h> #include <net/sock.h>
extern void unix_inflight(struct file *fp); extern void unix_inflight(struct file *fp);
...@@ -71,7 +72,7 @@ struct unix_sock { ...@@ -71,7 +72,7 @@ struct unix_sock {
struct unix_address *addr; struct unix_address *addr;
struct dentry *dentry; struct dentry *dentry;
struct vfsmount *mnt; struct vfsmount *mnt;
struct semaphore readsem; struct mutex readlock;
struct sock *peer; struct sock *peer;
struct sock *other; struct sock *other;
struct sock *gc_tree; struct sock *gc_tree;
......
...@@ -451,12 +451,12 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) ...@@ -451,12 +451,12 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
dev = try_then_request_module(atm_dev_lookup(itf), "atm-device-%d", itf); dev = try_then_request_module(atm_dev_lookup(itf), "atm-device-%d", itf);
} else { } else {
dev = NULL; dev = NULL;
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
if (!list_empty(&atm_devs)) { if (!list_empty(&atm_devs)) {
dev = list_entry(atm_devs.next, struct atm_dev, dev_list); dev = list_entry(atm_devs.next, struct atm_dev, dev_list);
atm_dev_hold(dev); atm_dev_hold(dev);
} }
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
} }
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mutex.h>
#include <net/sock.h> /* for struct sock */ #include <net/sock.h> /* for struct sock */
#include "common.h" #include "common.h"
...@@ -26,7 +28,7 @@ ...@@ -26,7 +28,7 @@
LIST_HEAD(atm_devs); LIST_HEAD(atm_devs);
DECLARE_MUTEX(atm_dev_mutex); DEFINE_MUTEX(atm_dev_mutex);
static struct atm_dev *__alloc_atm_dev(const char *type) static struct atm_dev *__alloc_atm_dev(const char *type)
{ {
...@@ -65,9 +67,9 @@ struct atm_dev *atm_dev_lookup(int number) ...@@ -65,9 +67,9 @@ struct atm_dev *atm_dev_lookup(int number)
{ {
struct atm_dev *dev; struct atm_dev *dev;
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
dev = __atm_dev_lookup(number); dev = __atm_dev_lookup(number);
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
return dev; return dev;
} }
...@@ -83,11 +85,11 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, ...@@ -83,11 +85,11 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
type); type);
return NULL; return NULL;
} }
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
if (number != -1) { if (number != -1) {
if ((inuse = __atm_dev_lookup(number))) { if ((inuse = __atm_dev_lookup(number))) {
atm_dev_put(inuse); atm_dev_put(inuse);
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
kfree(dev); kfree(dev);
return NULL; return NULL;
} }
...@@ -112,12 +114,12 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, ...@@ -112,12 +114,12 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
printk(KERN_ERR "atm_dev_register: " printk(KERN_ERR "atm_dev_register: "
"atm_proc_dev_register failed for dev %s\n", "atm_proc_dev_register failed for dev %s\n",
type); type);
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
kfree(dev); kfree(dev);
return NULL; return NULL;
} }
list_add_tail(&dev->dev_list, &atm_devs); list_add_tail(&dev->dev_list, &atm_devs);
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
return dev; return dev;
} }
...@@ -133,9 +135,9 @@ void atm_dev_deregister(struct atm_dev *dev) ...@@ -133,9 +135,9 @@ void atm_dev_deregister(struct atm_dev *dev)
* with same number can appear, such we need deregister proc, * with same number can appear, such we need deregister proc,
* release async all vccs and remove them from vccs list too * release async all vccs and remove them from vccs list too
*/ */
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
list_del(&dev->dev_list); list_del(&dev->dev_list);
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
atm_dev_release_vccs(dev); atm_dev_release_vccs(dev);
atm_proc_dev_deregister(dev); atm_proc_dev_deregister(dev);
...@@ -196,16 +198,16 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) ...@@ -196,16 +198,16 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
return -EFAULT; return -EFAULT;
if (get_user(len, &iobuf->length)) if (get_user(len, &iobuf->length))
return -EFAULT; return -EFAULT;
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
list_for_each(p, &atm_devs) list_for_each(p, &atm_devs)
size += sizeof(int); size += sizeof(int);
if (size > len) { if (size > len) {
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
return -E2BIG; return -E2BIG;
} }
tmp_buf = kmalloc(size, GFP_ATOMIC); tmp_buf = kmalloc(size, GFP_ATOMIC);
if (!tmp_buf) { if (!tmp_buf) {
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
return -ENOMEM; return -ENOMEM;
} }
tmp_p = tmp_buf; tmp_p = tmp_buf;
...@@ -213,7 +215,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) ...@@ -213,7 +215,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
dev = list_entry(p, struct atm_dev, dev_list); dev = list_entry(p, struct atm_dev, dev_list);
*tmp_p++ = dev->number; *tmp_p++ = dev->number;
} }
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
error = ((copy_to_user(buf, tmp_buf, size)) || error = ((copy_to_user(buf, tmp_buf, size)) ||
put_user(size, &iobuf->length)) put_user(size, &iobuf->length))
? -EFAULT : 0; ? -EFAULT : 0;
...@@ -400,13 +402,13 @@ static __inline__ void *dev_get_idx(loff_t left) ...@@ -400,13 +402,13 @@ static __inline__ void *dev_get_idx(loff_t left)
void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
{ {
down(&atm_dev_mutex); mutex_lock(&atm_dev_mutex);
return *pos ? dev_get_idx(*pos) : (void *) 1; return *pos ? dev_get_idx(*pos) : (void *) 1;
} }
void atm_dev_seq_stop(struct seq_file *seq, void *v) void atm_dev_seq_stop(struct seq_file *seq, void *v)
{ {
up(&atm_dev_mutex); mutex_unlock(&atm_dev_mutex);
} }
void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
......
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/atmdev.h> #include <linux/atmdev.h>
#include <linux/mutex.h>
extern struct list_head atm_devs; extern struct list_head atm_devs;
extern struct semaphore atm_dev_mutex; extern struct mutex atm_dev_mutex;
int atm_dev_ioctl(unsigned int cmd, void __user *arg); int atm_dev_ioctl(unsigned int cmd, void __user *arg);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define ASSERT_READ_LOCK(x) #define ASSERT_READ_LOCK(x)
#define ASSERT_WRITE_LOCK(x) #define ASSERT_WRITE_LOCK(x)
#include <linux/netfilter_ipv4/listhelp.h> #include <linux/netfilter_ipv4/listhelp.h>
#include <linux/mutex.h>
#if 0 #if 0
/* use this for remote debugging /* use this for remote debugging
...@@ -81,7 +82,7 @@ static void print_string(char *str) ...@@ -81,7 +82,7 @@ static void print_string(char *str)
static DECLARE_MUTEX(ebt_mutex); static DEFINE_MUTEX(ebt_mutex);
static LIST_HEAD(ebt_tables); static LIST_HEAD(ebt_tables);
static LIST_HEAD(ebt_targets); static LIST_HEAD(ebt_targets);
static LIST_HEAD(ebt_matches); static LIST_HEAD(ebt_matches);
...@@ -296,18 +297,18 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff **pskb, ...@@ -296,18 +297,18 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff **pskb,
/* If it succeeds, returns element and locks mutex */ /* If it succeeds, returns element and locks mutex */
static inline void * static inline void *
find_inlist_lock_noload(struct list_head *head, const char *name, int *error, find_inlist_lock_noload(struct list_head *head, const char *name, int *error,
struct semaphore *mutex) struct mutex *mutex)
{ {
void *ret; void *ret;
*error = down_interruptible(mutex); *error = mutex_lock_interruptible(mutex);
if (*error != 0) if (*error != 0)
return NULL; return NULL;
ret = list_named_find(head, name); ret = list_named_find(head, name);
if (!ret) { if (!ret) {
*error = -ENOENT; *error = -ENOENT;
up(mutex); mutex_unlock(mutex);
} }
return ret; return ret;
} }
...@@ -317,7 +318,7 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error, ...@@ -317,7 +318,7 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error,
#else #else
static void * static void *
find_inlist_lock(struct list_head *head, const char *name, const char *prefix, find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
int *error, struct semaphore *mutex) int *error, struct mutex *mutex)
{ {
void *ret; void *ret;
...@@ -331,25 +332,25 @@ find_inlist_lock(struct list_head *head, const char *name, const char *prefix, ...@@ -331,25 +332,25 @@ find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
#endif #endif
static inline struct ebt_table * static inline struct ebt_table *
find_table_lock(const char *name, int *error, struct semaphore *mutex) find_table_lock(const char *name, int *error, struct mutex *mutex)
{ {
return find_inlist_lock(&ebt_tables, name, "ebtable_", error, mutex); return find_inlist_lock(&ebt_tables, name, "ebtable_", error, mutex);
} }
static inline struct ebt_match * static inline struct ebt_match *
find_match_lock(const char *name, int *error, struct semaphore *mutex) find_match_lock(const char *name, int *error, struct mutex *mutex)
{ {
return find_inlist_lock(&ebt_matches, name, "ebt_", error, mutex); return find_inlist_lock(&ebt_matches, name, "ebt_", error, mutex);
} }
static inline struct ebt_watcher * static inline struct ebt_watcher *
find_watcher_lock(const char *name, int *error, struct semaphore *mutex) find_watcher_lock(const char *name, int *error, struct mutex *mutex)
{ {
return find_inlist_lock(&ebt_watchers, name, "ebt_", error, mutex); return find_inlist_lock(&ebt_watchers, name, "ebt_", error, mutex);
} }
static inline struct ebt_target * static inline struct ebt_target *
find_target_lock(const char *name, int *error, struct semaphore *mutex) find_target_lock(const char *name, int *error, struct mutex *mutex)
{ {
return find_inlist_lock(&ebt_targets, name, "ebt_", error, mutex); return find_inlist_lock(&ebt_targets, name, "ebt_", error, mutex);
} }
...@@ -369,10 +370,10 @@ ebt_check_match(struct ebt_entry_match *m, struct ebt_entry *e, ...@@ -369,10 +370,10 @@ ebt_check_match(struct ebt_entry_match *m, struct ebt_entry *e,
return ret; return ret;
m->u.match = match; m->u.match = match;
if (!try_module_get(match->me)) { if (!try_module_get(match->me)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return -ENOENT; return -ENOENT;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
if (match->check && if (match->check &&
match->check(name, hookmask, e, m->data, m->match_size) != 0) { match->check(name, hookmask, e, m->data, m->match_size) != 0) {
BUGPRINT("match->check failed\n"); BUGPRINT("match->check failed\n");
...@@ -398,10 +399,10 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct ebt_entry *e, ...@@ -398,10 +399,10 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct ebt_entry *e,
return ret; return ret;
w->u.watcher = watcher; w->u.watcher = watcher;
if (!try_module_get(watcher->me)) { if (!try_module_get(watcher->me)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return -ENOENT; return -ENOENT;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
if (watcher->check && if (watcher->check &&
watcher->check(name, hookmask, e, w->data, w->watcher_size) != 0) { watcher->check(name, hookmask, e, w->data, w->watcher_size) != 0) {
BUGPRINT("watcher->check failed\n"); BUGPRINT("watcher->check failed\n");
...@@ -638,11 +639,11 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo, ...@@ -638,11 +639,11 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
if (!target) if (!target)
goto cleanup_watchers; goto cleanup_watchers;
if (!try_module_get(target->me)) { if (!try_module_get(target->me)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
ret = -ENOENT; ret = -ENOENT;
goto cleanup_watchers; goto cleanup_watchers;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
t->u.target = target; t->u.target = target;
if (t->u.target == &ebt_standard_target) { if (t->u.target == &ebt_standard_target) {
...@@ -1015,7 +1016,7 @@ static int do_replace(void __user *user, unsigned int len) ...@@ -1015,7 +1016,7 @@ static int do_replace(void __user *user, unsigned int len)
t->private = newinfo; t->private = newinfo;
write_unlock_bh(&t->lock); write_unlock_bh(&t->lock);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
/* so, a user can change the chains while having messed up her counter /* so, a user can change the chains while having messed up her counter
allocation. Only reason why this is done is because this way the lock allocation. Only reason why this is done is because this way the lock
is held only once, while this doesn't bring the kernel into a is held only once, while this doesn't bring the kernel into a
...@@ -1045,7 +1046,7 @@ static int do_replace(void __user *user, unsigned int len) ...@@ -1045,7 +1046,7 @@ static int do_replace(void __user *user, unsigned int len)
return ret; return ret;
free_unlock: free_unlock:
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
free_iterate: free_iterate:
EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
ebt_cleanup_entry, NULL); ebt_cleanup_entry, NULL);
...@@ -1068,69 +1069,69 @@ int ebt_register_target(struct ebt_target *target) ...@@ -1068,69 +1069,69 @@ int ebt_register_target(struct ebt_target *target)
{ {
int ret; int ret;
ret = down_interruptible(&ebt_mutex); ret = mutex_lock_interruptible(&ebt_mutex);
if (ret != 0) if (ret != 0)
return ret; return ret;
if (!list_named_insert(&ebt_targets, target)) { if (!list_named_insert(&ebt_targets, target)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return -EEXIST; return -EEXIST;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return 0; return 0;
} }
void ebt_unregister_target(struct ebt_target *target) void ebt_unregister_target(struct ebt_target *target)
{ {
down(&ebt_mutex); mutex_lock(&ebt_mutex);
LIST_DELETE(&ebt_targets, target); LIST_DELETE(&ebt_targets, target);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
} }
int ebt_register_match(struct ebt_match *match) int ebt_register_match(struct ebt_match *match)
{ {
int ret; int ret;
ret = down_interruptible(&ebt_mutex); ret = mutex_lock_interruptible(&ebt_mutex);
if (ret != 0) if (ret != 0)
return ret; return ret;
if (!list_named_insert(&ebt_matches, match)) { if (!list_named_insert(&ebt_matches, match)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return -EEXIST; return -EEXIST;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return 0; return 0;
} }
void ebt_unregister_match(struct ebt_match *match) void ebt_unregister_match(struct ebt_match *match)
{ {
down(&ebt_mutex); mutex_lock(&ebt_mutex);
LIST_DELETE(&ebt_matches, match); LIST_DELETE(&ebt_matches, match);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
} }
int ebt_register_watcher(struct ebt_watcher *watcher) int ebt_register_watcher(struct ebt_watcher *watcher)
{ {
int ret; int ret;
ret = down_interruptible(&ebt_mutex); ret = mutex_lock_interruptible(&ebt_mutex);
if (ret != 0) if (ret != 0)
return ret; return ret;
if (!list_named_insert(&ebt_watchers, watcher)) { if (!list_named_insert(&ebt_watchers, watcher)) {
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return -EEXIST; return -EEXIST;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return 0; return 0;
} }
void ebt_unregister_watcher(struct ebt_watcher *watcher) void ebt_unregister_watcher(struct ebt_watcher *watcher)
{ {
down(&ebt_mutex); mutex_lock(&ebt_mutex);
LIST_DELETE(&ebt_watchers, watcher); LIST_DELETE(&ebt_watchers, watcher);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
} }
int ebt_register_table(struct ebt_table *table) int ebt_register_table(struct ebt_table *table)
...@@ -1178,7 +1179,7 @@ int ebt_register_table(struct ebt_table *table) ...@@ -1178,7 +1179,7 @@ int ebt_register_table(struct ebt_table *table)
table->private = newinfo; table->private = newinfo;
rwlock_init(&table->lock); rwlock_init(&table->lock);
ret = down_interruptible(&ebt_mutex); ret = mutex_lock_interruptible(&ebt_mutex);
if (ret != 0) if (ret != 0)
goto free_chainstack; goto free_chainstack;
...@@ -1194,10 +1195,10 @@ int ebt_register_table(struct ebt_table *table) ...@@ -1194,10 +1195,10 @@ int ebt_register_table(struct ebt_table *table)
goto free_unlock; goto free_unlock;
} }
list_prepend(&ebt_tables, table); list_prepend(&ebt_tables, table);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
return 0; return 0;
free_unlock: free_unlock:
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
free_chainstack: free_chainstack:
if (newinfo->chainstack) { if (newinfo->chainstack) {
for_each_cpu(i) for_each_cpu(i)
...@@ -1218,9 +1219,9 @@ void ebt_unregister_table(struct ebt_table *table) ...@@ -1218,9 +1219,9 @@ void ebt_unregister_table(struct ebt_table *table)
BUGPRINT("Request to unregister NULL table!!!\n"); BUGPRINT("Request to unregister NULL table!!!\n");
return; return;
} }
down(&ebt_mutex); mutex_lock(&ebt_mutex);
LIST_DELETE(&ebt_tables, table); LIST_DELETE(&ebt_tables, table);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
vfree(table->private->entries); vfree(table->private->entries);
if (table->private->chainstack) { if (table->private->chainstack) {
for_each_cpu(i) for_each_cpu(i)
...@@ -1281,7 +1282,7 @@ static int update_counters(void __user *user, unsigned int len) ...@@ -1281,7 +1282,7 @@ static int update_counters(void __user *user, unsigned int len)
write_unlock_bh(&t->lock); write_unlock_bh(&t->lock);
ret = 0; ret = 0;
unlock_mutex: unlock_mutex:
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
free_tmp: free_tmp:
vfree(tmp); vfree(tmp);
return ret; return ret;
...@@ -1328,7 +1329,7 @@ static inline int ebt_make_names(struct ebt_entry *e, char *base, char *ubase) ...@@ -1328,7 +1329,7 @@ static inline int ebt_make_names(struct ebt_entry *e, char *base, char *ubase)
return 0; return 0;
} }
/* called with ebt_mutex down */ /* called with ebt_mutex locked */
static int copy_everything_to_user(struct ebt_table *t, void __user *user, static int copy_everything_to_user(struct ebt_table *t, void __user *user,
int *len, int cmd) int *len, int cmd)
{ {
...@@ -1440,7 +1441,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -1440,7 +1441,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
case EBT_SO_GET_INIT_INFO: case EBT_SO_GET_INIT_INFO:
if (*len != sizeof(struct ebt_replace)){ if (*len != sizeof(struct ebt_replace)){
ret = -EINVAL; ret = -EINVAL;
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
break; break;
} }
if (cmd == EBT_SO_GET_INFO) { if (cmd == EBT_SO_GET_INFO) {
...@@ -1452,7 +1453,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -1452,7 +1453,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
tmp.entries_size = t->table->entries_size; tmp.entries_size = t->table->entries_size;
tmp.valid_hooks = t->table->valid_hooks; tmp.valid_hooks = t->table->valid_hooks;
} }
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
if (copy_to_user(user, &tmp, *len) != 0){ if (copy_to_user(user, &tmp, *len) != 0){
BUGPRINT("c2u Didn't work\n"); BUGPRINT("c2u Didn't work\n");
ret = -EFAULT; ret = -EFAULT;
...@@ -1464,11 +1465,11 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -1464,11 +1465,11 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
case EBT_SO_GET_ENTRIES: case EBT_SO_GET_ENTRIES:
case EBT_SO_GET_INIT_ENTRIES: case EBT_SO_GET_INIT_ENTRIES:
ret = copy_everything_to_user(t, user, len, cmd); ret = copy_everything_to_user(t, user, len, cmd);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
break; break;
default: default:
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -1484,9 +1485,9 @@ static int __init init(void) ...@@ -1484,9 +1485,9 @@ static int __init init(void)
{ {
int ret; int ret;
down(&ebt_mutex); mutex_lock(&ebt_mutex);
list_named_insert(&ebt_targets, &ebt_standard_target); list_named_insert(&ebt_targets, &ebt_standard_target);
up(&ebt_mutex); mutex_unlock(&ebt_mutex);
if ((ret = nf_register_sockopt(&ebt_sockopts)) < 0) if ((ret = nf_register_sockopt(&ebt_sockopts)) < 0)
return ret; return ret;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/mutex.h>
#include <net/ip_vs.h> #include <net/ip_vs.h>
...@@ -40,7 +41,7 @@ EXPORT_SYMBOL(register_ip_vs_app_inc); ...@@ -40,7 +41,7 @@ EXPORT_SYMBOL(register_ip_vs_app_inc);
/* ipvs application list head */ /* ipvs application list head */
static LIST_HEAD(ip_vs_app_list); static LIST_HEAD(ip_vs_app_list);
static DECLARE_MUTEX(__ip_vs_app_mutex); static DEFINE_MUTEX(__ip_vs_app_mutex);
/* /*
...@@ -173,11 +174,11 @@ register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port) ...@@ -173,11 +174,11 @@ register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port)
{ {
int result; int result;
down(&__ip_vs_app_mutex); mutex_lock(&__ip_vs_app_mutex);
result = ip_vs_app_inc_new(app, proto, port); result = ip_vs_app_inc_new(app, proto, port);
up(&__ip_vs_app_mutex); mutex_unlock(&__ip_vs_app_mutex);
return result; return result;
} }
...@@ -191,11 +192,11 @@ int register_ip_vs_app(struct ip_vs_app *app) ...@@ -191,11 +192,11 @@ int register_ip_vs_app(struct ip_vs_app *app)
/* increase the module use count */ /* increase the module use count */
ip_vs_use_count_inc(); ip_vs_use_count_inc();
down(&__ip_vs_app_mutex); mutex_lock(&__ip_vs_app_mutex);
list_add(&app->a_list, &ip_vs_app_list); list_add(&app->a_list, &ip_vs_app_list);
up(&__ip_vs_app_mutex); mutex_unlock(&__ip_vs_app_mutex);
return 0; return 0;
} }
...@@ -209,7 +210,7 @@ void unregister_ip_vs_app(struct ip_vs_app *app) ...@@ -209,7 +210,7 @@ void unregister_ip_vs_app(struct ip_vs_app *app)
{ {
struct ip_vs_app *inc, *nxt; struct ip_vs_app *inc, *nxt;
down(&__ip_vs_app_mutex); mutex_lock(&__ip_vs_app_mutex);
list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) { list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) {
ip_vs_app_inc_release(inc); ip_vs_app_inc_release(inc);
...@@ -217,7 +218,7 @@ void unregister_ip_vs_app(struct ip_vs_app *app) ...@@ -217,7 +218,7 @@ void unregister_ip_vs_app(struct ip_vs_app *app)
list_del(&app->a_list); list_del(&app->a_list);
up(&__ip_vs_app_mutex); mutex_unlock(&__ip_vs_app_mutex);
/* decrease the module use count */ /* decrease the module use count */
ip_vs_use_count_dec(); ip_vs_use_count_dec();
...@@ -498,7 +499,7 @@ static struct ip_vs_app *ip_vs_app_idx(loff_t pos) ...@@ -498,7 +499,7 @@ static struct ip_vs_app *ip_vs_app_idx(loff_t pos)
static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos) static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos)
{ {
down(&__ip_vs_app_mutex); mutex_lock(&__ip_vs_app_mutex);
return *pos ? ip_vs_app_idx(*pos - 1) : SEQ_START_TOKEN; return *pos ? ip_vs_app_idx(*pos - 1) : SEQ_START_TOKEN;
} }
...@@ -530,7 +531,7 @@ static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -530,7 +531,7 @@ static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos)
static void ip_vs_app_seq_stop(struct seq_file *seq, void *v) static void ip_vs_app_seq_stop(struct seq_file *seq, void *v)
{ {
up(&__ip_vs_app_mutex); mutex_unlock(&__ip_vs_app_mutex);
} }
static int ip_vs_app_seq_show(struct seq_file *seq, void *v) static int ip_vs_app_seq_show(struct seq_file *seq, void *v)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <linux/netfilter/x_tables.h> #include <linux/netfilter/x_tables.h>
#include <linux/netfilter_arp/arp_tables.h> #include <linux/netfilter_arp/arp_tables.h>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/icmp.h> #include <linux/icmp.h>
#include <net/ip.h> #include <net/ip.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include <net/ipv6.h> #include <net/ipv6.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
......
...@@ -185,7 +185,7 @@ static struct { ...@@ -185,7 +185,7 @@ static struct {
DEFINE_RWLOCK(nf_ct_cache_lock); DEFINE_RWLOCK(nf_ct_cache_lock);
/* This avoids calling kmem_cache_create() with same name simultaneously */ /* This avoids calling kmem_cache_create() with same name simultaneously */
DECLARE_MUTEX(nf_ct_cache_mutex); static DEFINE_MUTEX(nf_ct_cache_mutex);
extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
struct nf_conntrack_protocol * struct nf_conntrack_protocol *
...@@ -278,7 +278,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name, ...@@ -278,7 +278,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
return -EINVAL; return -EINVAL;
} }
down(&nf_ct_cache_mutex); mutex_lock(&nf_ct_cache_mutex);
write_lock_bh(&nf_ct_cache_lock); write_lock_bh(&nf_ct_cache_lock);
/* e.g: multiple helpers are loaded */ /* e.g: multiple helpers are loaded */
...@@ -294,7 +294,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name, ...@@ -294,7 +294,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
ret = -EBUSY; ret = -EBUSY;
write_unlock_bh(&nf_ct_cache_lock); write_unlock_bh(&nf_ct_cache_lock);
up(&nf_ct_cache_mutex); mutex_unlock(&nf_ct_cache_mutex);
return ret; return ret;
} }
write_unlock_bh(&nf_ct_cache_lock); write_unlock_bh(&nf_ct_cache_lock);
...@@ -338,7 +338,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name, ...@@ -338,7 +338,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
out_free_name: out_free_name:
kfree(cache_name); kfree(cache_name);
out_up_mutex: out_up_mutex:
up(&nf_ct_cache_mutex); mutex_unlock(&nf_ct_cache_mutex);
return ret; return ret;
} }
...@@ -353,12 +353,12 @@ void nf_conntrack_unregister_cache(u_int32_t features) ...@@ -353,12 +353,12 @@ void nf_conntrack_unregister_cache(u_int32_t features)
* slab cache. * slab cache.
*/ */
DEBUGP("nf_conntrack_unregister_cache: 0x%04x\n", features); DEBUGP("nf_conntrack_unregister_cache: 0x%04x\n", features);
down(&nf_ct_cache_mutex); mutex_lock(&nf_ct_cache_mutex);
write_lock_bh(&nf_ct_cache_lock); write_lock_bh(&nf_ct_cache_lock);
if (--nf_ct_cache[features].use > 0) { if (--nf_ct_cache[features].use > 0) {
write_unlock_bh(&nf_ct_cache_lock); write_unlock_bh(&nf_ct_cache_lock);
up(&nf_ct_cache_mutex); mutex_unlock(&nf_ct_cache_mutex);
return; return;
} }
cachep = nf_ct_cache[features].cachep; cachep = nf_ct_cache[features].cachep;
...@@ -373,7 +373,7 @@ void nf_conntrack_unregister_cache(u_int32_t features) ...@@ -373,7 +373,7 @@ void nf_conntrack_unregister_cache(u_int32_t features)
kmem_cache_destroy(cachep); kmem_cache_destroy(cachep);
kfree(name); kfree(name);
up(&nf_ct_cache_mutex); mutex_unlock(&nf_ct_cache_mutex);
} }
int int
...@@ -1408,6 +1408,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, ...@@ -1408,6 +1408,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
#include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_conntrack.h> #include <linux/netfilter/nfnetlink_conntrack.h>
#include <linux/mutex.h>
/* Generic function for tcp/udp/sctp/dccp and alike. This needs to be /* Generic function for tcp/udp/sctp/dccp and alike. This needs to be
* in ip_conntrack_core, since we don't want the protocols to autoload * in ip_conntrack_core, since we don't want the protocols to autoload
......
...@@ -1296,13 +1296,13 @@ svc_send(struct svc_rqst *rqstp) ...@@ -1296,13 +1296,13 @@ svc_send(struct svc_rqst *rqstp)
xb->page_len + xb->page_len +
xb->tail[0].iov_len; xb->tail[0].iov_len;
/* Grab svsk->sk_sem to serialize outgoing data. */ /* Grab svsk->sk_mutex to serialize outgoing data. */
down(&svsk->sk_sem); mutex_lock(&svsk->sk_mutex);
if (test_bit(SK_DEAD, &svsk->sk_flags)) if (test_bit(SK_DEAD, &svsk->sk_flags))
len = -ENOTCONN; len = -ENOTCONN;
else else
len = svsk->sk_sendto(rqstp); len = svsk->sk_sendto(rqstp);
up(&svsk->sk_sem); mutex_unlock(&svsk->sk_mutex);
svc_sock_release(rqstp); svc_sock_release(rqstp);
if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN) if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
...@@ -1351,7 +1351,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock, ...@@ -1351,7 +1351,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
svsk->sk_lastrecv = get_seconds(); svsk->sk_lastrecv = get_seconds();
INIT_LIST_HEAD(&svsk->sk_deferred); INIT_LIST_HEAD(&svsk->sk_deferred);
INIT_LIST_HEAD(&svsk->sk_ready); INIT_LIST_HEAD(&svsk->sk_ready);
sema_init(&svsk->sk_sem, 1); mutex_init(&svsk->sk_mutex);
/* Initialize the socket */ /* Initialize the socket */
if (sock->type == SOCK_DGRAM) if (sock->type == SOCK_DGRAM)
......
...@@ -566,7 +566,7 @@ static struct sock * unix_create1(struct socket *sock) ...@@ -566,7 +566,7 @@ static struct sock * unix_create1(struct socket *sock)
u->mnt = NULL; u->mnt = NULL;
spin_lock_init(&u->lock); spin_lock_init(&u->lock);
atomic_set(&u->inflight, sock ? 0 : -1); atomic_set(&u->inflight, sock ? 0 : -1);
init_MUTEX(&u->readsem); /* single task reading lock */ mutex_init(&u->readlock); /* single task reading lock */
init_waitqueue_head(&u->peer_wait); init_waitqueue_head(&u->peer_wait);
unix_insert_socket(unix_sockets_unbound, sk); unix_insert_socket(unix_sockets_unbound, sk);
out: out:
...@@ -623,7 +623,7 @@ static int unix_autobind(struct socket *sock) ...@@ -623,7 +623,7 @@ static int unix_autobind(struct socket *sock)
struct unix_address * addr; struct unix_address * addr;
int err; int err;
down(&u->readsem); mutex_lock(&u->readlock);
err = 0; err = 0;
if (u->addr) if (u->addr)
...@@ -661,7 +661,7 @@ static int unix_autobind(struct socket *sock) ...@@ -661,7 +661,7 @@ static int unix_autobind(struct socket *sock)
spin_unlock(&unix_table_lock); spin_unlock(&unix_table_lock);
err = 0; err = 0;
out: up(&u->readsem); out: mutex_unlock(&u->readlock);
return err; return err;
} }
...@@ -744,7 +744,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -744,7 +744,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out; goto out;
addr_len = err; addr_len = err;
down(&u->readsem); mutex_lock(&u->readlock);
err = -EINVAL; err = -EINVAL;
if (u->addr) if (u->addr)
...@@ -816,7 +816,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -816,7 +816,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
out_unlock: out_unlock:
spin_unlock(&unix_table_lock); spin_unlock(&unix_table_lock);
out_up: out_up:
up(&u->readsem); mutex_unlock(&u->readlock);
out: out:
return err; return err;
...@@ -1545,7 +1545,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1545,7 +1545,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
msg->msg_namelen = 0; msg->msg_namelen = 0;
down(&u->readsem); mutex_lock(&u->readlock);
skb = skb_recv_datagram(sk, flags, noblock, &err); skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb) if (!skb)
...@@ -1600,7 +1600,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1600,7 +1600,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
out_free: out_free:
skb_free_datagram(sk,skb); skb_free_datagram(sk,skb);
out_unlock: out_unlock:
up(&u->readsem); mutex_unlock(&u->readlock);
out: out:
return err; return err;
} }
...@@ -1676,7 +1676,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1676,7 +1676,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
memset(&tmp_scm, 0, sizeof(tmp_scm)); memset(&tmp_scm, 0, sizeof(tmp_scm));
} }
down(&u->readsem); mutex_lock(&u->readlock);
do do
{ {
...@@ -1700,7 +1700,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1700,7 +1700,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
err = -EAGAIN; err = -EAGAIN;
if (!timeo) if (!timeo)
break; break;
up(&u->readsem); mutex_unlock(&u->readlock);
timeo = unix_stream_data_wait(sk, timeo); timeo = unix_stream_data_wait(sk, timeo);
...@@ -1708,7 +1708,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1708,7 +1708,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
err = sock_intr_errno(timeo); err = sock_intr_errno(timeo);
goto out; goto out;
} }
down(&u->readsem); mutex_lock(&u->readlock);
continue; continue;
} }
...@@ -1774,7 +1774,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1774,7 +1774,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
} }
} while (size); } while (size);
up(&u->readsem); mutex_unlock(&u->readlock);
scm_recv(sock, msg, siocb->scm, flags); scm_recv(sock, msg, siocb->scm, flags);
out: out:
return copied ? : err; return copied ? : err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment