aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/sunrpc/svcsock.h2
-rw-r--r--net/sunrpc/svc.c21
-rw-r--r--net/sunrpc/svcsock.c16
3 files changed, 25 insertions, 14 deletions
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index cccea0a0feb4..7909687557bf 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -66,7 +66,7 @@ struct svc_sock {
66 * Function prototypes. 66 * Function prototypes.
67 */ 67 */
68int svc_makesock(struct svc_serv *, int, unsigned short, int flags); 68int svc_makesock(struct svc_serv *, int, unsigned short, int flags);
69void svc_close_socket(struct svc_sock *); 69void svc_force_close_socket(struct svc_sock *);
70int svc_recv(struct svc_rqst *, long); 70int svc_recv(struct svc_rqst *, long);
71int svc_send(struct svc_rqst *); 71int svc_send(struct svc_rqst *);
72void svc_drop(struct svc_rqst *); 72void svc_drop(struct svc_rqst *);
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 8353829bc5c6..f960b138236f 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -367,6 +367,7 @@ void
367svc_destroy(struct svc_serv *serv) 367svc_destroy(struct svc_serv *serv)
368{ 368{
369 struct svc_sock *svsk; 369 struct svc_sock *svsk;
370 struct svc_sock *tmp;
370 371
371 dprintk("svc: svc_destroy(%s, %d)\n", 372 dprintk("svc: svc_destroy(%s, %d)\n",
372 serv->sv_program->pg_name, 373 serv->sv_program->pg_name,
@@ -382,21 +383,17 @@ svc_destroy(struct svc_serv *serv)
382 383
383 del_timer_sync(&serv->sv_temptimer); 384 del_timer_sync(&serv->sv_temptimer);
384 385
385 while (!list_empty(&serv->sv_tempsocks)) { 386 list_for_each_entry_safe(svsk, tmp, &serv->sv_tempsocks, sk_list)
386 svsk = list_entry(serv->sv_tempsocks.next, 387 svc_force_close_socket(svsk);
387 struct svc_sock, 388
388 sk_list);
389 svc_close_socket(svsk);
390 }
391 if (serv->sv_shutdown) 389 if (serv->sv_shutdown)
392 serv->sv_shutdown(serv); 390 serv->sv_shutdown(serv);
393 391
394 while (!list_empty(&serv->sv_permsocks)) { 392 list_for_each_entry_safe(svsk, tmp, &serv->sv_permsocks, sk_list)
395 svsk = list_entry(serv->sv_permsocks.next, 393 svc_force_close_socket(svsk);
396 struct svc_sock, 394
397 sk_list); 395 BUG_ON(!list_empty(&serv->sv_permsocks));
398 svc_close_socket(svsk); 396 BUG_ON(!list_empty(&serv->sv_tempsocks));
399 }
400 397
401 cache_clean_deferred(serv); 398 cache_clean_deferred(serv);
402 399
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index e957ce55fd91..f6e1eb1ea720 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -82,6 +82,7 @@ static void svc_delete_socket(struct svc_sock *svsk);
82static void svc_udp_data_ready(struct sock *, int); 82static void svc_udp_data_ready(struct sock *, int);
83static int svc_udp_recvfrom(struct svc_rqst *); 83static int svc_udp_recvfrom(struct svc_rqst *);
84static int svc_udp_sendto(struct svc_rqst *); 84static int svc_udp_sendto(struct svc_rqst *);
85static void svc_close_socket(struct svc_sock *svsk);
85 86
86static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk); 87static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
87static int svc_deferred_recv(struct svc_rqst *rqstp); 88static int svc_deferred_recv(struct svc_rqst *rqstp);
@@ -1787,7 +1788,7 @@ svc_delete_socket(struct svc_sock *svsk)
1787 spin_unlock_bh(&serv->sv_lock); 1788 spin_unlock_bh(&serv->sv_lock);
1788} 1789}
1789 1790
1790void svc_close_socket(struct svc_sock *svsk) 1791static void svc_close_socket(struct svc_sock *svsk)
1791{ 1792{
1792 set_bit(SK_CLOSE, &svsk->sk_flags); 1793 set_bit(SK_CLOSE, &svsk->sk_flags);
1793 if (test_and_set_bit(SK_BUSY, &svsk->sk_flags)) 1794 if (test_and_set_bit(SK_BUSY, &svsk->sk_flags))
@@ -1800,6 +1801,19 @@ void svc_close_socket(struct svc_sock *svsk)
1800 svc_sock_put(svsk); 1801 svc_sock_put(svsk);
1801} 1802}
1802 1803
1804void svc_force_close_socket(struct svc_sock *svsk)
1805{
1806 set_bit(SK_CLOSE, &svsk->sk_flags);
1807 if (test_bit(SK_BUSY, &svsk->sk_flags)) {
1808 /* Waiting to be processed, but no threads left,
1809 * So just remove it from the waiting list
1810 */
1811 list_del_init(&svsk->sk_ready);
1812 clear_bit(SK_BUSY, &svsk->sk_flags);
1813 }
1814 svc_close_socket(svsk);
1815}
1816
1803/** 1817/**
1804 * svc_makesock - Make a socket for nfsd and lockd 1818 * svc_makesock - Make a socket for nfsd and lockd
1805 * @serv: RPC server structure 1819 * @serv: RPC server structure