diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-26 00:39:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-26 20:53:40 -0400 |
commit | 516e0cc5646f377ab80fcc2ee639892eccb99853 (patch) | |
tree | e06296dcedb42dbe397d237887873e70c5823d51 /net/unix/garbage.c | |
parent | 3c333937ee3be114b181c4861188cfe8f6a59697 (diff) |
[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>
Diffstat (limited to 'net/unix/garbage.c')
-rw-r--r-- | net/unix/garbage.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index ebdff3d877a1..2a27b84f740b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
@@ -127,7 +127,7 @@ void unix_inflight(struct file *fp) | |||
127 | if(s) { | 127 | if(s) { |
128 | struct unix_sock *u = unix_sk(s); | 128 | struct unix_sock *u = unix_sk(s); |
129 | spin_lock(&unix_gc_lock); | 129 | spin_lock(&unix_gc_lock); |
130 | if (atomic_inc_return(&u->inflight) == 1) { | 130 | if (atomic_long_inc_return(&u->inflight) == 1) { |
131 | BUG_ON(!list_empty(&u->link)); | 131 | BUG_ON(!list_empty(&u->link)); |
132 | list_add_tail(&u->link, &gc_inflight_list); | 132 | list_add_tail(&u->link, &gc_inflight_list); |
133 | } else { | 133 | } else { |
@@ -145,7 +145,7 @@ void unix_notinflight(struct file *fp) | |||
145 | struct unix_sock *u = unix_sk(s); | 145 | struct unix_sock *u = unix_sk(s); |
146 | spin_lock(&unix_gc_lock); | 146 | spin_lock(&unix_gc_lock); |
147 | BUG_ON(list_empty(&u->link)); | 147 | BUG_ON(list_empty(&u->link)); |
148 | if (atomic_dec_and_test(&u->inflight)) | 148 | if (atomic_long_dec_and_test(&u->inflight)) |
149 | list_del_init(&u->link); | 149 | list_del_init(&u->link); |
150 | unix_tot_inflight--; | 150 | unix_tot_inflight--; |
151 | spin_unlock(&unix_gc_lock); | 151 | spin_unlock(&unix_gc_lock); |
@@ -237,17 +237,17 @@ static void scan_children(struct sock *x, void (*func)(struct unix_sock *), | |||
237 | 237 | ||
238 | static void dec_inflight(struct unix_sock *usk) | 238 | static void dec_inflight(struct unix_sock *usk) |
239 | { | 239 | { |
240 | atomic_dec(&usk->inflight); | 240 | atomic_long_dec(&usk->inflight); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void inc_inflight(struct unix_sock *usk) | 243 | static void inc_inflight(struct unix_sock *usk) |
244 | { | 244 | { |
245 | atomic_inc(&usk->inflight); | 245 | atomic_long_inc(&usk->inflight); |
246 | } | 246 | } |
247 | 247 | ||
248 | static void inc_inflight_move_tail(struct unix_sock *u) | 248 | static void inc_inflight_move_tail(struct unix_sock *u) |
249 | { | 249 | { |
250 | atomic_inc(&u->inflight); | 250 | atomic_long_inc(&u->inflight); |
251 | /* | 251 | /* |
252 | * If this is still a candidate, move it to the end of the | 252 | * If this is still a candidate, move it to the end of the |
253 | * list, so that it's checked even if it was already passed | 253 | * list, so that it's checked even if it was already passed |
@@ -288,11 +288,11 @@ void unix_gc(void) | |||
288 | * before the detach without atomicity guarantees. | 288 | * before the detach without atomicity guarantees. |
289 | */ | 289 | */ |
290 | list_for_each_entry_safe(u, next, &gc_inflight_list, link) { | 290 | list_for_each_entry_safe(u, next, &gc_inflight_list, link) { |
291 | int total_refs; | 291 | long total_refs; |
292 | int inflight_refs; | 292 | long inflight_refs; |
293 | 293 | ||
294 | total_refs = file_count(u->sk.sk_socket->file); | 294 | total_refs = file_count(u->sk.sk_socket->file); |
295 | inflight_refs = atomic_read(&u->inflight); | 295 | inflight_refs = atomic_long_read(&u->inflight); |
296 | 296 | ||
297 | BUG_ON(inflight_refs < 1); | 297 | BUG_ON(inflight_refs < 1); |
298 | BUG_ON(total_refs < inflight_refs); | 298 | BUG_ON(total_refs < inflight_refs); |
@@ -324,7 +324,7 @@ void unix_gc(void) | |||
324 | /* Move cursor to after the current position. */ | 324 | /* Move cursor to after the current position. */ |
325 | list_move(&cursor, &u->link); | 325 | list_move(&cursor, &u->link); |
326 | 326 | ||
327 | if (atomic_read(&u->inflight) > 0) { | 327 | if (atomic_long_read(&u->inflight) > 0) { |
328 | list_move_tail(&u->link, &gc_inflight_list); | 328 | list_move_tail(&u->link, &gc_inflight_list); |
329 | u->gc_candidate = 0; | 329 | u->gc_candidate = 0; |
330 | scan_children(&u->sk, inc_inflight_move_tail, NULL); | 330 | scan_children(&u->sk, inc_inflight_move_tail, NULL); |