Commit aaf737ad authored by Igor Mammedov's avatar Igor Mammedov Committed by Steve French

[CIFS] Switch cifsd to kthread_run from kernel_thread

cifsd was the only cifs thread that had not been switched to the newer
kthread interface

Signed-off-by: Igor Mammedov <niallain at gmail.com>
Signed-off-by: default avatarWilhelm Meier <wilhelm.meier@fh-kl.de>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent c33f8d32
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/mempool.h> #include <linux/mempool.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kthread.h>
#include <linux/pagevec.h> #include <linux/pagevec.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -120,7 +121,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -120,7 +121,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
struct mid_q_entry * mid_entry; struct mid_q_entry * mid_entry;
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if(server->tcpStatus == CifsExiting) { if( kthread_should_stop() ) {
/* the demux thread will exit normally /* the demux thread will exit normally
next time through the loop */ next time through the loop */
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
...@@ -182,7 +183,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -182,7 +183,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
up(&server->tcpSem); up(&server->tcpSem);
while ((server->tcpStatus != CifsExiting) && (server->tcpStatus != CifsGood)) while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood))
{ {
try_to_freeze(); try_to_freeze();
if(server->protocolType == IPV6) { if(server->protocolType == IPV6) {
...@@ -199,7 +200,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -199,7 +200,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
} else { } else {
atomic_inc(&tcpSesReconnectCount); atomic_inc(&tcpSesReconnectCount);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if(server->tcpStatus != CifsExiting) if( !kthread_should_stop() )
server->tcpStatus = CifsGood; server->tcpStatus = CifsGood;
server->sequence_number = 0; server->sequence_number = 0;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
...@@ -345,7 +346,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -345,7 +346,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
int isMultiRsp; int isMultiRsp;
int reconnect; int reconnect;
daemonize("cifsd");
allow_signal(SIGKILL); allow_signal(SIGKILL);
current->flags |= PF_MEMALLOC; current->flags |= PF_MEMALLOC;
server->tsk = current; /* save process info to wake at shutdown */ server->tsk = current; /* save process info to wake at shutdown */
...@@ -361,7 +361,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -361,7 +361,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
GFP_KERNEL); GFP_KERNEL);
} }
while (server->tcpStatus != CifsExiting) { while (!kthread_should_stop()) {
if (try_to_freeze()) if (try_to_freeze())
continue; continue;
if (bigbuf == NULL) { if (bigbuf == NULL) {
...@@ -400,7 +400,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -400,7 +400,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
kernel_recvmsg(csocket, &smb_msg, kernel_recvmsg(csocket, &smb_msg,
&iov, 1, 4, 0 /* BB see socket.h flags */); &iov, 1, 4, 0 /* BB see socket.h flags */);
if (server->tcpStatus == CifsExiting) { if ( kthread_should_stop() ) {
break; break;
} else if (server->tcpStatus == CifsNeedReconnect) { } else if (server->tcpStatus == CifsNeedReconnect) {
cFYI(1, ("Reconnect after server stopped responding")); cFYI(1, ("Reconnect after server stopped responding"));
...@@ -524,7 +524,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -524,7 +524,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
total_read += length) { total_read += length) {
length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, length = kernel_recvmsg(csocket, &smb_msg, &iov, 1,
pdu_length - total_read, 0); pdu_length - total_read, 0);
if((server->tcpStatus == CifsExiting) || if( kthread_should_stop() ||
(length == -EINTR)) { (length == -EINTR)) {
/* then will exit */ /* then will exit */
reconnect = 2; reconnect = 2;
...@@ -757,7 +757,6 @@ multi_t2_fnd: ...@@ -757,7 +757,6 @@ multi_t2_fnd:
GFP_KERNEL); GFP_KERNEL);
} }
complete_and_exit(&cifsd_complete, 0);
return 0; return 0;
} }
...@@ -1850,10 +1849,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1850,10 +1849,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
so no need to spinlock this init of tcpStatus */ so no need to spinlock this init of tcpStatus */
srvTcp->tcpStatus = CifsNew; srvTcp->tcpStatus = CifsNew;
init_MUTEX(&srvTcp->tcpSem); init_MUTEX(&srvTcp->tcpSem);
rc = (int)kernel_thread((void *)(void *)cifs_demultiplex_thread, srvTcp, srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd");
CLONE_FS | CLONE_FILES | CLONE_VM); if( IS_ERR(srvTcp->tsk) ) {
if(rc < 0) { rc = PTR_ERR(srvTcp->tsk);
rc = -ENOMEM; cERROR(1,("error %d create cifsd thread", rc));
srvTcp->tsk = NULL;
sock_release(csocket); sock_release(csocket);
kfree(volume_info.UNC); kfree(volume_info.UNC);
kfree(volume_info.password); kfree(volume_info.password);
...@@ -2050,7 +2050,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2050,7 +2050,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
if(srvTcp->tsk) { if(srvTcp->tsk) {
send_sig(SIGKILL,srvTcp->tsk,1); 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 */ /* If find_unc succeeded then rc == 0 so we can not end */
...@@ -2064,9 +2064,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2064,9 +2064,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
temp_rc = CIFSSMBLogoff(xid, pSesInfo); temp_rc = CIFSSMBLogoff(xid, pSesInfo);
/* if the socketUseCount is now zero */ /* if the socketUseCount is now zero */
if((temp_rc == -ESHUTDOWN) && if((temp_rc == -ESHUTDOWN) &&
(pSesInfo->server->tsk)) { (pSesInfo->server) && (pSesInfo->server->tsk)) {
send_sig(SIGKILL,pSesInfo->server->tsk,1); send_sig(SIGKILL,pSesInfo->server->tsk,1);
wait_for_completion(&cifsd_complete); kthread_stop(pSesInfo->server->tsk);
} }
} else } else
cFYI(1, ("No session or bad tcon")); cFYI(1, ("No session or bad tcon"));
...@@ -3316,7 +3316,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) ...@@ -3316,7 +3316,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
cFYI(1,("Waking up socket by sending it signal")); cFYI(1,("Waking up socket by sending it signal"));
if(cifsd_task) { if(cifsd_task) {
send_sig(SIGKILL,cifsd_task,1); send_sig(SIGKILL,cifsd_task,1);
wait_for_completion(&cifsd_complete); kthread_stop(cifsd_task);
} }
rc = 0; rc = 0;
} /* else - we have an smb session } /* else - we have an smb session
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment