Commit 60d9f461a20ba59219fdcdc30cbf8e3a4ad3f625

Authored by Arnd Bergmann
1 parent 77b2283604

appletalk: remove the BKL

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>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org

Showing 2 changed files with 16 additions and 25 deletions Side-by-side Diff

drivers/net/appletalk/Kconfig
... ... @@ -3,7 +3,6 @@
3 3 #
4 4 config ATALK
5 5 tristate "Appletalk protocol support"
6   - depends on BKL # waiting to be removed from net/appletalk/ddp.c
7 6 select LLC
8 7 ---help---
9 8 AppleTalk is the protocol that Apple computers can use to communicate
... ... @@ -54,7 +54,6 @@
54 54 #include <linux/capability.h>
55 55 #include <linux/module.h>
56 56 #include <linux/if_arp.h>
57   -#include <linux/smp_lock.h>
58 57 #include <linux/termios.h> /* For TIOCOUTQ/INQ */
59 58 #include <linux/compat.h>
60 59 #include <linux/slab.h>
61 60  
... ... @@ -1052,13 +1051,13 @@
1052 1051 {
1053 1052 struct sock *sk = sock->sk;
1054 1053  
1055   - lock_kernel();
  1054 + lock_sock(sk);
1056 1055 if (sk) {
1057 1056 sock_orphan(sk);
1058 1057 sock->sk = NULL;
1059 1058 atalk_destroy_socket(sk);
1060 1059 }
1061   - unlock_kernel();
  1060 + release_sock(sk);
1062 1061 return 0;
1063 1062 }
1064 1063  
... ... @@ -1143,7 +1142,7 @@
1143 1142 if (addr->sat_family != AF_APPLETALK)
1144 1143 return -EAFNOSUPPORT;
1145 1144  
1146   - lock_kernel();
  1145 + lock_sock(sk);
1147 1146 if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) {
1148 1147 struct atalk_addr *ap = atalk_find_primary();
1149 1148  
... ... @@ -1179,7 +1178,7 @@
1179 1178 sock_reset_flag(sk, SOCK_ZAPPED);
1180 1179 err = 0;
1181 1180 out:
1182   - unlock_kernel();
  1181 + release_sock(sk);
1183 1182 return err;
1184 1183 }
1185 1184  
... ... @@ -1215,7 +1214,7 @@
1215 1214 #endif
1216 1215 }
1217 1216  
1218   - lock_kernel();
  1217 + lock_sock(sk);
1219 1218 err = -EBUSY;
1220 1219 if (sock_flag(sk, SOCK_ZAPPED))
1221 1220 if (atalk_autobind(sk) < 0)
... ... @@ -1233,7 +1232,7 @@
1233 1232 sk->sk_state = TCP_ESTABLISHED;
1234 1233 err = 0;
1235 1234 out:
1236   - unlock_kernel();
  1235 + release_sock(sk);
1237 1236 return err;
1238 1237 }
1239 1238  
... ... @@ -1249,7 +1248,7 @@
1249 1248 struct atalk_sock *at = at_sk(sk);
1250 1249 int err;
1251 1250  
1252   - lock_kernel();
  1251 + lock_sock(sk);
1253 1252 err = -ENOBUFS;
1254 1253 if (sock_flag(sk, SOCK_ZAPPED))
1255 1254 if (atalk_autobind(sk) < 0)
1256 1255  
... ... @@ -1277,20 +1276,10 @@
1277 1276 memcpy(uaddr, &sat, sizeof(sat));
1278 1277  
1279 1278 out:
1280   - unlock_kernel();
  1279 + release_sock(sk);
1281 1280 return err;
1282 1281 }
1283 1282  
1284   -static unsigned int atalk_poll(struct file *file, struct socket *sock,
1285   - poll_table *wait)
1286   -{
1287   - int err;
1288   - lock_kernel();
1289   - err = datagram_poll(file, sock, wait);
1290   - unlock_kernel();
1291   - return err;
1292   -}
1293   -
1294 1283 #if defined(CONFIG_IPDDP) || defined(CONFIG_IPDDP_MODULE)
1295 1284 static __inline__ int is_ip_over_ddp(struct sk_buff *skb)
1296 1285 {
... ... @@ -1596,7 +1585,7 @@
1596 1585 if (len > DDP_MAXSZ)
1597 1586 return -EMSGSIZE;
1598 1587  
1599   - lock_kernel();
  1588 + lock_sock(sk);
1600 1589 if (usat) {
1601 1590 err = -EBUSY;
1602 1591 if (sock_flag(sk, SOCK_ZAPPED))
1603 1592  
... ... @@ -1651,7 +1640,9 @@
1651 1640 sk, size, dev->name);
1652 1641  
1653 1642 size += dev->hard_header_len;
  1643 + release_sock(sk);
1654 1644 skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err);
  1645 + lock_sock(sk);
1655 1646 if (!skb)
1656 1647 goto out;
1657 1648  
... ... @@ -1738,7 +1729,7 @@
1738 1729 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len);
1739 1730  
1740 1731 out:
1741   - unlock_kernel();
  1732 + release_sock(sk);
1742 1733 return err ? : len;
1743 1734 }
1744 1735  
1745 1736  
... ... @@ -1753,9 +1744,10 @@
1753 1744 int err = 0;
1754 1745 struct sk_buff *skb;
1755 1746  
1756   - lock_kernel();
1757 1747 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1758 1748 flags & MSG_DONTWAIT, &err);
  1749 + lock_sock(sk);
  1750 +
1759 1751 if (!skb)
1760 1752 goto out;
1761 1753  
... ... @@ -1787,7 +1779,7 @@
1787 1779 skb_free_datagram(sk, skb); /* Free the datagram. */
1788 1780  
1789 1781 out:
1790   - unlock_kernel();
  1782 + release_sock(sk);
1791 1783 return err ? : copied;
1792 1784 }
1793 1785  
... ... @@ -1887,7 +1879,7 @@
1887 1879 .socketpair = sock_no_socketpair,
1888 1880 .accept = sock_no_accept,
1889 1881 .getname = atalk_getname,
1890   - .poll = atalk_poll,
  1882 + .poll = datagram_poll,
1891 1883 .ioctl = atalk_ioctl,
1892 1884 #ifdef CONFIG_COMPAT
1893 1885 .compat_ioctl = atalk_compat_ioctl,