From: Arnd Bergmann <arnd@arndb.de> To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann <arnd@arndb.de>, Arnaldo Carvalho de Melo <acme@ghostprotocols.net>, netdev@vger.kernel.org Subject: [PATCH 14/20] staging/appletalk: remove the BKL Date: Tue, 25 Jan 2011 23:17:28 +0100 [thread overview] Message-ID: <1295993854-4971-15-git-send-email-arnd@arndb.de> (raw) In-Reply-To: <1295993854-4971-1-git-send-email-arnd@arndb.de> This changes appletalk to use lock_sock instead of lock_kernel for serialization. I tried to make sure that we don't hold the socket lock during sleeping functions, but I did not try to prove whether the locks are necessary in the first place. Compile-tested only. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: netdev@vger.kernel.org --- drivers/staging/appletalk/Kconfig | 1 - drivers/staging/appletalk/ddp.c | 40 ++++++++++++++---------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/staging/appletalk/Kconfig b/drivers/staging/appletalk/Kconfig index 0b376a9..f5a8916 100644 --- a/drivers/staging/appletalk/Kconfig +++ b/drivers/staging/appletalk/Kconfig @@ -3,7 +3,6 @@ # config ATALK tristate "Appletalk protocol support" - depends on BKL # waiting to be removed from net/appletalk/ddp.c select LLC ---help--- AppleTalk is the protocol that Apple computers can use to communicate diff --git a/drivers/staging/appletalk/ddp.c b/drivers/staging/appletalk/ddp.c index 940dd19..0e2240c 100644 --- a/drivers/staging/appletalk/ddp.c +++ b/drivers/staging/appletalk/ddp.c @@ -54,7 +54,6 @@ #include <linux/capability.h> #include <linux/module.h> #include <linux/if_arp.h> -#include <linux/smp_lock.h> #include <linux/termios.h> /* For TIOCOUTQ/INQ */ #include <linux/compat.h> #include <linux/slab.h> @@ -1052,13 +1051,13 @@ static int atalk_release(struct socket *sock) { struct sock *sk = sock->sk; - lock_kernel(); + lock_sock(sk); if (sk) { sock_orphan(sk); sock->sk = NULL; atalk_destroy_socket(sk); } - unlock_kernel(); + release_sock(sk); return 0; } @@ -1143,7 +1142,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (addr->sat_family != AF_APPLETALK) return -EAFNOSUPPORT; - lock_kernel(); + lock_sock(sk); if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) { struct atalk_addr *ap = atalk_find_primary(); @@ -1179,7 +1178,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) sock_reset_flag(sk, SOCK_ZAPPED); err = 0; out: - unlock_kernel(); + release_sock(sk); return err; } @@ -1215,7 +1214,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr, #endif } - lock_kernel(); + lock_sock(sk); err = -EBUSY; if (sock_flag(sk, SOCK_ZAPPED)) if (atalk_autobind(sk) < 0) @@ -1233,7 +1232,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr, sk->sk_state = TCP_ESTABLISHED; err = 0; out: - unlock_kernel(); + release_sock(sk); return err; } @@ -1249,7 +1248,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, struct atalk_sock *at = at_sk(sk); int err; - lock_kernel(); + lock_sock(sk); err = -ENOBUFS; if (sock_flag(sk, SOCK_ZAPPED)) if (atalk_autobind(sk) < 0) @@ -1277,17 +1276,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, memcpy(uaddr, &sat, sizeof(sat)); out: - unlock_kernel(); - return err; -} - -static unsigned int atalk_poll(struct file *file, struct socket *sock, - poll_table *wait) -{ - int err; - lock_kernel(); - err = datagram_poll(file, sock, wait); - unlock_kernel(); + release_sock(sk); return err; } @@ -1596,7 +1585,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr if (len > DDP_MAXSZ) return -EMSGSIZE; - lock_kernel(); + lock_sock(sk); if (usat) { err = -EBUSY; if (sock_flag(sk, SOCK_ZAPPED)) @@ -1651,7 +1640,9 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr sk, size, dev->name); size += dev->hard_header_len; + release_sock(sk); skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err); + lock_sock(sk); if (!skb) goto out; @@ -1738,7 +1729,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len); out: - unlock_kernel(); + release_sock(sk); return err ? : len; } @@ -1753,9 +1744,10 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr int err = 0; struct sk_buff *skb; - lock_kernel(); skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &err); + lock_sock(sk); + if (!skb) goto out; @@ -1787,7 +1779,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr skb_free_datagram(sk, skb); /* Free the datagram. */ out: - unlock_kernel(); + release_sock(sk); return err ? : copied; } @@ -1887,7 +1879,7 @@ static const struct proto_ops atalk_dgram_ops = { .socketpair = sock_no_socketpair, .accept = sock_no_accept, .getname = atalk_getname, - .poll = atalk_poll, + .poll = datagram_poll, .ioctl = atalk_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = atalk_compat_ioctl, -- 1.7.1
next prev parent reply other threads:[~2011-01-25 22:19 UTC|newest] Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-01-25 22:17 [RFC 00/20] Proposal for remaining BKL users Arnd Bergmann 2011-01-25 22:17 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 01/20] drm/i810: remove the BKL Arnd Bergmann 2011-01-25 22:17 ` [PATCH 02/20] drm: remove i830 driver Arnd Bergmann 2011-01-25 22:17 ` [PATCH 03/20] staging/usbip: convert to kthread Arnd Bergmann 2011-01-28 17:53 ` Max Vozeler 2011-01-28 18:48 ` Arnd Bergmann 2011-03-01 22:15 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 04/20] staging/cx25721: serialize access to devlist Arnd Bergmann 2011-01-26 16:23 ` Palash Bandyopadhyay 2011-01-31 21:37 ` Greg KH 2011-01-25 22:17 ` [PATCH 05/20] staging/go7007: remove the BKL Arnd Bergmann 2011-01-25 22:17 ` [PATCH 06/20] staging: Remove autofs3 Arnd Bergmann 2011-01-26 7:41 ` H. Peter Anvin 2011-01-25 22:17 ` [PATCH 07/20] staging: remove smbfs Arnd Bergmann 2011-01-25 22:17 ` [PATCH 08/20] adfs: remove the big kernel lock Arnd Bergmann 2011-01-25 22:20 ` Russell King 2011-01-25 22:17 ` [PATCH 09/20] hpfs: rename big kernel lock to hpfs_lock Arnd Bergmann 2011-01-25 22:17 ` [PATCH 10/20] hpfs: replace BKL with a global mutex Arnd Bergmann 2011-01-26 0:15 ` Andi Kleen 2011-01-26 0:19 ` Andi Kleen 2011-01-26 12:48 ` [PATCH v2] hpfs: remove the BKL Arnd Bergmann 2011-01-26 12:50 ` [PATCH 10/20] hpfs: replace BKL with a global mutex Arnd Bergmann 2011-01-26 16:52 ` Andi Kleen 2011-01-27 5:01 ` Nick Piggin 2011-01-27 10:57 ` Miklos Szeredi 2011-01-25 22:17 ` [PATCH 11/20] hpfs: move to drivers/staging Arnd Bergmann 2011-02-07 16:17 ` Mikulas Patocka 2011-02-07 19:31 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 12/20] x25: remove the BKL Arnd Bergmann 2011-01-27 10:07 ` Andrew Hendry 2011-01-27 12:17 ` Arnd Bergmann 2011-01-27 12:38 ` [PATCH v2] " Arnd Bergmann 2011-01-27 13:20 ` Eric Dumazet 2011-01-27 13:43 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 13/20] appletalk: move to staging Arnd Bergmann 2011-01-25 22:17 ` Arnd Bergmann [this message] 2011-01-25 22:29 ` [PATCH 14/20] staging/appletalk: remove the BKL David Miller 2011-01-26 12:57 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 15/20] ufs: " Arnd Bergmann 2011-01-26 2:30 ` Nick Bowler 2011-01-26 12:53 ` Arnd Bergmann 2011-01-27 5:47 ` Nick Piggin 2011-01-27 13:13 ` Arnd Bergmann 2011-01-25 22:17 ` [PATCH 16/20] ipx: " Arnd Bergmann 2011-01-25 22:17 ` [PATCH 17/20] tracing: don't trace " Arnd Bergmann 2011-01-25 22:28 ` Frederic Weisbecker 2011-01-25 22:17 ` [PATCH 18/20] rtmutex-tester: remove BKL tests Arnd Bergmann 2011-01-26 15:00 ` [tip:core/locking] rtmutex-tester: Remove " tip-bot for Arnd Bergmann 2011-02-22 20:57 ` [tip:irq/core] rtmutex: tester: " tip-bot for Arnd Bergmann 2011-01-25 22:17 ` [PATCH 19/20] drivers: remove extraneous includes of smp_lock.h Arnd Bergmann 2011-01-25 22:17 ` [PATCH 20/20] BKL: That's all, folks Arnd Bergmann 2011-01-26 6:19 ` Ingo Molnar 2011-01-26 8:47 ` Alan Cox 2011-01-26 11:01 ` Ingo Molnar 2011-01-26 11:22 ` Thomas Gleixner 2011-01-26 2:22 ` [RFC 00/20] Proposal for remaining BKL users Greg KH 2011-01-26 2:22 ` Greg KH 2011-01-26 11:31 ` Arnd Bergmann 2011-01-26 11:31 ` Arnd Bergmann 2011-01-26 11:58 ` Mauro Carvalho Chehab 2011-01-26 13:45 ` Arnd Bergmann 2011-01-26 13:45 ` Arnd Bergmann 2011-01-26 16:24 ` Palash Bandyopadhyay
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1295993854-4971-15-git-send-email-arnd@arndb.de \ --to=arnd@arndb.de \ --cc=acme@ghostprotocols.net \ --cc=linux-kernel@vger.kernel.org \ --cc=netdev@vger.kernel.org \ --subject='Re: [PATCH 14/20] staging/appletalk: remove the BKL' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.