aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2009-02-01 16:26:59 -0500
committerJonathan Corbet <corbet@lwn.net>2009-03-16 10:32:27 -0400
commit76398425bb06b07cc3a3b1ce169c67dc9d6874ed (patch)
treee6e1800edda88b5592617a950daacf2199587a33 /net
parentdb1dd4d376134eba0e08af523b61cc566a4ea1cd (diff)
Move FASYNC bit handling to f_op->fasync()
Removing the BKL from FASYNC handling ran into the challenge of keeping the setting of the FASYNC bit in filp->f_flags atomic with regard to calls to the underlying fasync() function. Andi Kleen suggested moving the handling of that bit into fasync(); this patch does exactly that. As a result, we have a couple of internal API changes: fasync() must now manage the FASYNC bit, and it will be called without the BKL held. As it happens, every fasync() implementation in the kernel with one exception calls fasync_helper(). So, if we make fasync_helper() set the FASYNC bit, we can avoid making any changes to the other fasync() functions - as long as those functions, themselves, have proper locking. Most fasync() implementations do nothing but call fasync_helper() - which has its own lock - so they are easily verified as correct. The BKL had already been pushed down into the rest. The networking code has its own version of fasync_helper(), so that code has been augmented with explicit FASYNC bit handling. Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: David Miller <davem@davemloft.net> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'net')
-rw-r--r--net/socket.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/socket.c b/net/socket.c
index 35dd7371752a..0f75746ab06e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1030,6 +1030,13 @@ static int sock_fasync(int fd, struct file *filp, int on)
1030 1030
1031 lock_sock(sk); 1031 lock_sock(sk);
1032 1032
1033 spin_lock(&filp->f_lock);
1034 if (on)
1035 filp->f_flags |= FASYNC;
1036 else
1037 filp->f_flags &= ~FASYNC;
1038 spin_unlock(&filp->f_lock);
1039
1033 prev = &(sock->fasync_list); 1040 prev = &(sock->fasync_list);
1034 1041
1035 for (fa = *prev; fa != NULL; prev = &fa->fa_next, fa = *prev) 1042 for (fa = *prev; fa != NULL; prev = &fa->fa_next, fa = *prev)