6060
6161static  struct  svc_sock  * svc_setup_socket (struct  svc_serv  * , struct  socket  * ,
6262					 int  flags );
63- static  void 		svc_udp_data_ready (struct  sock  * );
6463static  int 		svc_udp_recvfrom (struct  svc_rqst  * );
6564static  int 		svc_udp_sendto (struct  svc_rqst  * );
6665static  void 		svc_sock_detach (struct  svc_xprt  * );
@@ -398,48 +397,21 @@ static int svc_sock_secure_port(struct svc_rqst *rqstp)
398397	return  svc_port_is_privileged (svc_addr (rqstp ));
399398}
400399
401- static  bool  sunrpc_waitqueue_active (wait_queue_head_t  * wq )
402- {
403- 	if  (!wq )
404- 		return  false;
405- 	/* 
406- 	 * There should normally be a memory * barrier here--see 
407- 	 * wq_has_sleeper(). 
408- 	 * 
409- 	 * It appears that isn't currently necessary, though, basically 
410- 	 * because callers all appear to have sufficient memory barriers 
411- 	 * between the time the relevant change is made and the 
412- 	 * time they call these callbacks. 
413- 	 * 
414- 	 * The nfsd code itself doesn't actually explicitly wait on 
415- 	 * these waitqueues, but it may wait on them for example in 
416- 	 * sendpage() or sendmsg() calls.  (And those may be the only 
417- 	 * places, since it it uses nonblocking reads.) 
418- 	 * 
419- 	 * Maybe we should add the memory barriers anyway, but these are 
420- 	 * hot paths so we'd need to be convinced there's no sigificant 
421- 	 * penalty. 
422- 	 */ 
423- 	return  waitqueue_active (wq );
424- }
425- 
426400/* 
427401 * INET callback when data has been received on the socket. 
428402 */ 
429- static  void  svc_udp_data_ready (struct  sock  * sk )
403+ static  void  svc_data_ready (struct  sock  * sk )
430404{
431405	struct  svc_sock 	* svsk  =  (struct  svc_sock  * )sk -> sk_user_data ;
432- 	wait_queue_head_t  * wq  =  sk_sleep (sk );
433406
434407	if  (svsk ) {
435408		dprintk ("svc: socket %p(inet %p), busy=%d\n" ,
436409			svsk , sk ,
437410			test_bit (XPT_BUSY , & svsk -> sk_xprt .xpt_flags ));
411+ 		svsk -> sk_odata (sk );
438412		set_bit (XPT_DATA , & svsk -> sk_xprt .xpt_flags );
439413		svc_xprt_enqueue (& svsk -> sk_xprt );
440414	}
441- 	if  (sunrpc_waitqueue_active (wq ))
442- 		wake_up_interruptible (wq );
443415}
444416
445417/* 
@@ -448,19 +420,13 @@ static void svc_udp_data_ready(struct sock *sk)
448420static  void  svc_write_space (struct  sock  * sk )
449421{
450422	struct  svc_sock 	* svsk  =  (struct  svc_sock  * )(sk -> sk_user_data );
451- 	wait_queue_head_t  * wq  =  sk_sleep (sk );
452423
453424	if  (svsk ) {
454425		dprintk ("svc: socket %p(inet %p), write_space busy=%d\n" ,
455426			svsk , sk , test_bit (XPT_BUSY , & svsk -> sk_xprt .xpt_flags ));
427+ 		svsk -> sk_owspace (sk );
456428		svc_xprt_enqueue (& svsk -> sk_xprt );
457429	}
458- 
459- 	if  (sunrpc_waitqueue_active (wq )) {
460- 		dprintk ("RPC svc_write_space: someone sleeping on %p\n" ,
461- 		       svsk );
462- 		wake_up_interruptible (wq );
463- 	}
464430}
465431
466432static  int  svc_tcp_has_wspace (struct  svc_xprt  * xprt )
@@ -485,11 +451,15 @@ static void svc_tcp_write_space(struct sock *sk)
485451	struct  svc_sock  * svsk  =  (struct  svc_sock  * )(sk -> sk_user_data );
486452	struct  socket  * sock  =  sk -> sk_socket ;
487453
454+ 	if  (!svsk )
455+ 		return ;
456+ 
488457	if  (!sk_stream_is_writeable (sk ) ||  !sock )
489458		return ;
490- 	if  (! svsk   ||   svc_tcp_has_wspace (& svsk -> sk_xprt ))
459+ 	if  (svc_tcp_has_wspace (& svsk -> sk_xprt )) { 
491460		clear_bit (SOCK_NOSPACE , & sock -> flags );
492- 	svc_write_space (sk );
461+ 		svc_write_space (sk );
462+ 	}
493463}
494464
495465static  void  svc_tcp_adjust_wspace (struct  svc_xprt  * xprt )
@@ -746,7 +716,7 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
746716	svc_xprt_init (sock_net (svsk -> sk_sock -> sk ), & svc_udp_class ,
747717		      & svsk -> sk_xprt , serv );
748718	clear_bit (XPT_CACHE_AUTH , & svsk -> sk_xprt .xpt_flags );
749- 	svsk -> sk_sk -> sk_data_ready  =  svc_udp_data_ready ;
719+ 	svsk -> sk_sk -> sk_data_ready  =  svc_data_ready ;
750720	svsk -> sk_sk -> sk_write_space  =  svc_write_space ;
751721
752722	/* initialise setting must have enough space to 
@@ -786,11 +756,12 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
786756static  void  svc_tcp_listen_data_ready (struct  sock  * sk )
787757{
788758	struct  svc_sock 	* svsk  =  (struct  svc_sock  * )sk -> sk_user_data ;
789- 	wait_queue_head_t  * wq ;
790759
791760	dprintk ("svc: socket %p TCP (listen) state change %d\n" ,
792761		sk , sk -> sk_state );
793762
763+ 	if  (svsk )
764+ 		svsk -> sk_odata (sk );
794765	/* 
795766	 * This callback may called twice when a new connection 
796767	 * is established as a child socket inherits everything 
@@ -808,10 +779,6 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
808779		} else 
809780			printk ("svc: socket %p: no user data\n" , sk );
810781	}
811- 
812- 	wq  =  sk_sleep (sk );
813- 	if  (sunrpc_waitqueue_active (wq ))
814- 		wake_up_interruptible_all (wq );
815782}
816783
817784/* 
@@ -820,34 +787,17 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
820787static  void  svc_tcp_state_change (struct  sock  * sk )
821788{
822789	struct  svc_sock 	* svsk  =  (struct  svc_sock  * )sk -> sk_user_data ;
823- 	wait_queue_head_t  * wq  =  sk_sleep (sk );
824790
825791	dprintk ("svc: socket %p TCP (connected) state change %d (svsk %p)\n" ,
826792		sk , sk -> sk_state , sk -> sk_user_data );
827793
828794	if  (!svsk )
829795		printk ("svc: socket %p: no user data\n" , sk );
830796	else  {
797+ 		svsk -> sk_ostate (sk );
831798		set_bit (XPT_CLOSE , & svsk -> sk_xprt .xpt_flags );
832799		svc_xprt_enqueue (& svsk -> sk_xprt );
833800	}
834- 	if  (sunrpc_waitqueue_active (wq ))
835- 		wake_up_interruptible_all (wq );
836- }
837- 
838- static  void  svc_tcp_data_ready (struct  sock  * sk )
839- {
840- 	struct  svc_sock  * svsk  =  (struct  svc_sock  * )sk -> sk_user_data ;
841- 	wait_queue_head_t  * wq  =  sk_sleep (sk );
842- 
843- 	dprintk ("svc: socket %p TCP data ready (svsk %p)\n" ,
844- 		sk , sk -> sk_user_data );
845- 	if  (svsk ) {
846- 		set_bit (XPT_DATA , & svsk -> sk_xprt .xpt_flags );
847- 		svc_xprt_enqueue (& svsk -> sk_xprt );
848- 	}
849- 	if  (sunrpc_waitqueue_active (wq ))
850- 		wake_up_interruptible (wq );
851801}
852802
853803/* 
@@ -901,6 +851,11 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)
901851	dprintk ("%s: connect from %s\n" , serv -> sv_name ,
902852		__svc_print_addr (sin , buf , sizeof (buf )));
903853
854+ 	/* Reset the inherited callbacks before calling svc_setup_socket */ 
855+ 	newsock -> sk -> sk_state_change  =  svsk -> sk_ostate ;
856+ 	newsock -> sk -> sk_data_ready  =  svsk -> sk_odata ;
857+ 	newsock -> sk -> sk_write_space  =  svsk -> sk_owspace ;
858+ 
904859	/* make sure that a write doesn't block forever when 
905860	 * low on memory 
906861	 */ 
@@ -1357,7 +1312,7 @@ static void svc_tcp_init(struct svc_sock *svsk, struct svc_serv *serv)
13571312	} else  {
13581313		dprintk ("setting up TCP socket for reading\n" );
13591314		sk -> sk_state_change  =  svc_tcp_state_change ;
1360- 		sk -> sk_data_ready  =  svc_tcp_data_ready ;
1315+ 		sk -> sk_data_ready  =  svc_data_ready ;
13611316		sk -> sk_write_space  =  svc_tcp_write_space ;
13621317
13631318		svsk -> sk_reclen  =  0 ;
@@ -1606,7 +1561,6 @@ static void svc_sock_detach(struct svc_xprt *xprt)
16061561{
16071562	struct  svc_sock  * svsk  =  container_of (xprt , struct  svc_sock , sk_xprt );
16081563	struct  sock  * sk  =  svsk -> sk_sk ;
1609- 	wait_queue_head_t  * wq ;
16101564
16111565	dprintk ("svc: svc_sock_detach(%p)\n" , svsk );
16121566
@@ -1617,10 +1571,6 @@ static void svc_sock_detach(struct svc_xprt *xprt)
16171571	sk -> sk_write_space  =  svsk -> sk_owspace ;
16181572	sk -> sk_user_data  =  NULL ;
16191573	release_sock (sk );
1620- 
1621- 	wq  =  sk_sleep (sk );
1622- 	if  (sunrpc_waitqueue_active (wq ))
1623- 		wake_up_interruptible (wq );
16241574}
16251575
16261576/* 
0 commit comments