[PATCH] f_count may wrap around

make it atomic_long_t; while we are at it, get rid of useless checks in affs,
hfs and hpfs - ->open() always has it equal to 1, ->release() - to 0.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2008-07-26 00:39:17 -04:00
parent 3c333937ee
commit 516e0cc564
11 changed files with 27 additions and 39 deletions

View File

@ -603,7 +603,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
u->dentry = NULL;
u->mnt = NULL;
spin_lock_init(&u->lock);
atomic_set(&u->inflight, 0);
atomic_long_set(&u->inflight, 0);
INIT_LIST_HEAD(&u->link);
mutex_init(&u->readlock); /* single task reading lock */
init_waitqueue_head(&u->peer_wait);

View File

@ -127,7 +127,7 @@ void unix_inflight(struct file *fp)
if(s) {
struct unix_sock *u = unix_sk(s);
spin_lock(&unix_gc_lock);
if (atomic_inc_return(&u->inflight) == 1) {
if (atomic_long_inc_return(&u->inflight) == 1) {
BUG_ON(!list_empty(&u->link));
list_add_tail(&u->link, &gc_inflight_list);
} else {
@ -145,7 +145,7 @@ void unix_notinflight(struct file *fp)
struct unix_sock *u = unix_sk(s);
spin_lock(&unix_gc_lock);
BUG_ON(list_empty(&u->link));
if (atomic_dec_and_test(&u->inflight))
if (atomic_long_dec_and_test(&u->inflight))
list_del_init(&u->link);
unix_tot_inflight--;
spin_unlock(&unix_gc_lock);
@ -237,17 +237,17 @@ static void scan_children(struct sock *x, void (*func)(struct unix_sock *),
static void dec_inflight(struct unix_sock *usk)
{
atomic_dec(&usk->inflight);
atomic_long_dec(&usk->inflight);
}
static void inc_inflight(struct unix_sock *usk)
{
atomic_inc(&usk->inflight);
atomic_long_inc(&usk->inflight);
}
static void inc_inflight_move_tail(struct unix_sock *u)
{
atomic_inc(&u->inflight);
atomic_long_inc(&u->inflight);
/*
* If this is still a candidate, move it to the end of the
* list, so that it's checked even if it was already passed
@ -288,11 +288,11 @@ void unix_gc(void)
* before the detach without atomicity guarantees.
*/
list_for_each_entry_safe(u, next, &gc_inflight_list, link) {
int total_refs;
int inflight_refs;
long total_refs;
long inflight_refs;
total_refs = file_count(u->sk.sk_socket->file);
inflight_refs = atomic_read(&u->inflight);
inflight_refs = atomic_long_read(&u->inflight);
BUG_ON(inflight_refs < 1);
BUG_ON(total_refs < inflight_refs);
@ -324,7 +324,7 @@ void unix_gc(void)
/* Move cursor to after the current position. */
list_move(&cursor, &u->link);
if (atomic_read(&u->inflight) > 0) {
if (atomic_long_read(&u->inflight) > 0) {
list_move_tail(&u->link, &gc_inflight_list);
u->gc_candidate = 0;
scan_children(&u->sk, inc_inflight_move_tail, NULL);