aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-07-26 00:39:17 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-07-26 20:53:40 -0400
commit516e0cc5646f377ab80fcc2ee639892eccb99853 (patch)
treee06296dcedb42dbe397d237887873e70c5823d51 /net
parent3c333937ee3be114b181c4861188cfe8f6a59697 (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')
-rw-r--r--net/sched/sch_atm.c4
-rw-r--r--net/unix/af_unix.c2
-rw-r--r--net/unix/garbage.c18
3 files changed, 12 insertions, 12 deletions
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 04faa835be17..6b517b9dac5b 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -162,7 +162,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
162 qdisc_destroy(flow->q); 162 qdisc_destroy(flow->q);
163 tcf_destroy_chain(&flow->filter_list); 163 tcf_destroy_chain(&flow->filter_list);
164 if (flow->sock) { 164 if (flow->sock) {
165 pr_debug("atm_tc_put: f_count %d\n", 165 pr_debug("atm_tc_put: f_count %ld\n",
166 file_count(flow->sock->file)); 166 file_count(flow->sock->file));
167 flow->vcc->pop = flow->old_pop; 167 flow->vcc->pop = flow->old_pop;
168 sockfd_put(flow->sock); 168 sockfd_put(flow->sock);
@@ -259,7 +259,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
259 sock = sockfd_lookup(fd, &error); 259 sock = sockfd_lookup(fd, &error);
260 if (!sock) 260 if (!sock)
261 return error; /* f_count++ */ 261 return error; /* f_count++ */
262 pr_debug("atm_tc_change: f_count %d\n", file_count(sock->file)); 262 pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file));
263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { 263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
264 error = -EPROTOTYPE; 264 error = -EPROTOTYPE;
265 goto err_out; 265 goto err_out;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 70ceb1604ad8..6e7fec74bdb3 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -603,7 +603,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
603 u->dentry = NULL; 603 u->dentry = NULL;
604 u->mnt = NULL; 604 u->mnt = NULL;
605 spin_lock_init(&u->lock); 605 spin_lock_init(&u->lock);
606 atomic_set(&u->inflight, 0); 606 atomic_long_set(&u->inflight, 0);
607 INIT_LIST_HEAD(&u->link); 607 INIT_LIST_HEAD(&u->link);
608 mutex_init(&u->readlock); /* single task reading lock */ 608 mutex_init(&u->readlock); /* single task reading lock */
609 init_waitqueue_head(&u->peer_wait); 609 init_waitqueue_head(&u->peer_wait);
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
238static void dec_inflight(struct unix_sock *usk) 238static void dec_inflight(struct unix_sock *usk)
239{ 239{
240 atomic_dec(&usk->inflight); 240 atomic_long_dec(&usk->inflight);
241} 241}
242 242
243static void inc_inflight(struct unix_sock *usk) 243static void inc_inflight(struct unix_sock *usk)
244{ 244{
245 atomic_inc(&usk->inflight); 245 atomic_long_inc(&usk->inflight);
246} 246}
247 247
248static void inc_inflight_move_tail(struct unix_sock *u) 248static 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);