All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Steve French (smfltc)" <smfltc@us.ibm.com>
To: Wilhelm Meier <wilhelm.meier@fh-kl.de>
Cc: linux-cifs-client@lists.samba.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: cifs and kthread_run / kernel_thread
Date: Mon, 02 Apr 2007 10:55:15 -0500	[thread overview]
Message-ID: <46112763.9070205@us.ibm.com> (raw)
In-Reply-To: <200704021740.48668.wilhelm.meier@fh-kl.de>

Wilhelm Meier wrote:

>m Montag, 2. April 2007 schrieb Wilhelm Meier:
>  
>
>>>It seems to me that I rewrote cifs_demultiplex_thread to use kthread_run
>>>in DFS patch.
>>>      
>>>
>>o.k., I found the patch on the list. Will do some testing with it.
>>    
>>
>
>o.k., the patch seems to be fine for linux-vserver. cifs-mounting inside the 
>guest is now possible.
>
>Do you see any possiblility to include this part of Igors work (not the whole 
>DFS thing) to the mainline? It fixes the use of the deprecated api.
>
>-
>Wilhelm
>  
>
>------------------------------------------------------------------------
>
>Index: connect.c
>===================================================================
>--- connect.c	(.../2.6.19.1)	(revision 20)
>+++ connect.c	(.../kthread_support)	(revision 20)
>@@ -30,6 +30,7 @@
> #include <linux/mempool.h>
> #include <linux/delay.h>
> #include <linux/completion.h>
>+#include <linux/kthread.h>
> #include <linux/pagevec.h>
> #include <asm/uaccess.h>
> #include <asm/processor.h>
>@@ -119,7 +120,7 @@
> 	struct mid_q_entry * mid_entry;
> 	
> 	spin_lock(&GlobalMid_Lock);
>-	if(server->tcpStatus == CifsExiting) {
>+	if( kthread_should_stop() ) {
> 		/* the demux thread will exit normally 
> 		next time through the loop */
> 		spin_unlock(&GlobalMid_Lock);
>@@ -181,7 +182,7 @@
> 	spin_unlock(&GlobalMid_Lock);
> 	up(&server->tcpSem); 
>
>-	while ((server->tcpStatus != CifsExiting) && (server->tcpStatus != CifsGood))
>+	while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood))
> 	{
> 		try_to_freeze();
> 		if(server->protocolType == IPV6) {
>@@ -198,7 +199,7 @@
> 		} else {
> 			atomic_inc(&tcpSesReconnectCount);
> 			spin_lock(&GlobalMid_Lock);
>-			if(server->tcpStatus != CifsExiting)
>+			if( !kthread_should_stop() )
> 				server->tcpStatus = CifsGood;
> 			server->sequence_number = 0;
> 			spin_unlock(&GlobalMid_Lock);			
>@@ -344,7 +345,6 @@
> 	int isMultiRsp;
> 	int reconnect;
>
>-	daemonize("cifsd");
> 	allow_signal(SIGKILL);
> 	current->flags |= PF_MEMALLOC;
> 	server->tsk = current;	/* save process info to wake at shutdown */
>@@ -360,7 +360,7 @@
> 			GFP_KERNEL);
> 	}
>
>-	while (server->tcpStatus != CifsExiting) {
>+	while (!kthread_should_stop()) {
> 		if (try_to_freeze())
> 			continue;
> 		if (bigbuf == NULL) {
>@@ -399,7 +399,7 @@
> 		    kernel_recvmsg(csocket, &smb_msg,
> 				 &iov, 1, 4, 0 /* BB see socket.h flags */);
>
>-		if (server->tcpStatus == CifsExiting) {
>+		if ( kthread_should_stop() ) {
> 			break;
> 		} else if (server->tcpStatus == CifsNeedReconnect) {
> 			cFYI(1, ("Reconnect after server stopped responding"));
>@@ -523,7 +523,7 @@
> 		     total_read += length) {
> 			length = kernel_recvmsg(csocket, &smb_msg, &iov, 1,
> 						pdu_length - total_read, 0);
>-			if((server->tcpStatus == CifsExiting) ||
>+			if( kthread_should_stop() ||
> 			    (length == -EINTR)) {
> 				/* then will exit */
> 				reconnect = 2;
>@@ -756,7 +756,6 @@
> 			GFP_KERNEL);
> 	}
> 	
>-	complete_and_exit(&cifsd_complete, 0);
> 	return 0;
> }
>
>@@ -1779,10 +1778,11 @@
> 			so no need to spinlock this init of tcpStatus */
> 			srvTcp->tcpStatus = CifsNew;
> 			init_MUTEX(&srvTcp->tcpSem);
>-			rc = (int)kernel_thread((void *)(void *)cifs_demultiplex_thread, srvTcp,
>-				      CLONE_FS | CLONE_FILES | CLONE_VM);
>-			if(rc < 0) {
>-				rc = -ENOMEM;
>+			srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd");
>+			if( IS_ERR(srvTcp->tsk) ) {
>+				rc = PTR_ERR(srvTcp->tsk);
>+				cERROR(1,("error %d create cifsd thread", rc));
>+				srvTcp->tsk = NULL;
> 				sock_release(csocket);
> 				kfree(volume_info.UNC);
> 				kfree(volume_info.password);
>@@ -1973,7 +1973,7 @@
> 			spin_unlock(&GlobalMid_Lock);
> 			if(srvTcp->tsk) {
> 				send_sig(SIGKILL,srvTcp->tsk,1);
>-				wait_for_completion(&cifsd_complete);
>+				kthread_stop(srvTcp->tsk);
> 			}
> 		}
> 		 /* If find_unc succeeded then rc == 0 so we can not end */
>@@ -1987,9 +1987,9 @@
> 					temp_rc = CIFSSMBLogoff(xid, pSesInfo);
> 					/* if the socketUseCount is now zero */
> 					if((temp_rc == -ESHUTDOWN) &&
>-					   (pSesInfo->server->tsk)) {
>+					   (pSesInfo->server) && (pSesInfo->server->tsk)) {
> 						send_sig(SIGKILL,pSesInfo->server->tsk,1);
>-						wait_for_completion(&cifsd_complete);
>+						kthread_stop(pSesInfo->server->tsk);
> 					}
> 				} else
> 					cFYI(1, ("No session or bad tcon"));
>@@ -3273,7 +3273,7 @@
> 				cFYI(1,("Waking up socket by sending it signal"));
> 				if(cifsd_task) {
> 					send_sig(SIGKILL,cifsd_task,1);
>-					wait_for_completion(&cifsd_complete);
>+					kthread_stop(cifsd_task);
> 				}
> 				rc = 0;
> 			} /* else - we have an smb session
>  
>
Yes.   I can merge this today in cifs-2.6 development tree after I try 
it out (and to 2.6.22 when it opens up
soon).

I also plan to merge a somewhat simpler change tothe inet_pton related 
change that Q made, since that can be
pulled out to make the final dfs change smaller to finish review (but it 
requires an additional change to
fs/cifs/connect.c to recognize ipv6 connections)..

  reply	other threads:[~2007-04-02 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070331120030.BE6A916387F@lists.samba.org>
2007-04-01 19:12 ` cifs and kthread_run / kernel_thread Steve French (smfltc)
2007-04-02  8:00   ` [linux-cifs-client] " Q (Igor Mammedov)
2007-04-02  8:58     ` Wilhelm Meier
2007-04-02 15:40       ` Wilhelm Meier
2007-04-02 15:55         ` Steve French (smfltc) [this message]
2007-04-02 15:12     ` Steve French (smfltc)
2007-04-03 19:17 Steve French

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=46112763.9070205@us.ibm.com \
    --to=smfltc@us.ibm.com \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wilhelm.meier@fh-kl.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.