sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / fs / smbfs / smbiod.c
index 481a97a..6bd9b69 100644 (file)
@@ -5,7 +5,6 @@
  *  Copyright (C) 2001, Urban Widmark
  */
 
-#include <linux/config.h>
 
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -17,9 +16,9 @@
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/dcache.h>
-#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/net.h>
+#include <linux/kthread.h>
 #include <net/ip.h>
 
 #include <linux/smb_fs.h>
@@ -40,13 +39,13 @@ enum smbiod_state {
 };
 
 static enum smbiod_state smbiod_state = SMBIOD_DEAD;
-static pid_t smbiod_pid;
+static struct task_struct *smbiod_thread;
 static DECLARE_WAIT_QUEUE_HEAD(smbiod_wait);
 static LIST_HEAD(smb_servers);
 static DEFINE_SPINLOCK(servers_lock);
 
 #define SMBIOD_DATA_READY      (1<<0)
-static long smbiod_flags;
+static unsigned long smbiod_flags;
 
 static int smbiod(void *);
 static int smbiod_start(void);
@@ -67,20 +66,29 @@ void smbiod_wake_up(void)
  */
 static int smbiod_start(void)
 {
-       pid_t pid;
+       struct task_struct *tsk;
+       int err = 0;
+
        if (smbiod_state != SMBIOD_DEAD)
                return 0;
        smbiod_state = SMBIOD_STARTING;
        __module_get(THIS_MODULE);
        spin_unlock(&servers_lock);
-       pid = kernel_thread(smbiod, NULL, 0);
-       if (pid < 0)
+       tsk = kthread_run(smbiod, NULL, "smbiod");
+       if (IS_ERR(tsk)) {
+               err = PTR_ERR(tsk);
                module_put(THIS_MODULE);
+       }
 
        spin_lock(&servers_lock);
-       smbiod_state = pid < 0 ? SMBIOD_DEAD : SMBIOD_RUNNING;
-       smbiod_pid = pid;
-       return pid;
+       if (err < 0) {
+               smbiod_state = SMBIOD_DEAD;
+               smbiod_thread = NULL;
+       } else {
+               smbiod_state = SMBIOD_RUNNING;
+               smbiod_thread = tsk;
+       }
+       return err;
 }
 
 /*
@@ -143,7 +151,7 @@ int smbiod_retry(struct smb_sb_info *server)
 {
        struct list_head *head;
        struct smb_request *req;
-       pid_t pid = server->conn_pid;
+       struct pid *pid = get_pid(server->conn_pid);
        int result = 0;
 
        VERBOSE("state: %d\n", server->state);
@@ -183,8 +191,7 @@ int smbiod_retry(struct smb_sb_info *server)
                if (req->rq_flags & SMB_REQ_RETRY) {
                        /* must move the request to the xmitq */
                        VERBOSE("retrying request %p on recvq\n", req);
-                       list_del(&req->rq_queue);
-                       list_add(&req->rq_queue, &server->xmitq);
+                       list_move(&req->rq_queue, &server->xmitq);
                        continue;
                }
 #endif
@@ -199,7 +206,7 @@ int smbiod_retry(struct smb_sb_info *server)
 
        smb_close_socket(server);
 
-       if (pid == 0) {
+       if (!pid) {
                /* FIXME: this is fatal, umount? */
                printk(KERN_ERR "smb_retry: no connection process\n");
                server->state = CONN_RETRIED;
@@ -214,17 +221,18 @@ int smbiod_retry(struct smb_sb_info *server)
        /*
         * Note: use the "priv" flag, as a user process may need to reconnect.
         */
-       result = kill_proc(pid, SIGUSR1, 1);
+       result = kill_pid(pid, SIGUSR1, 1);
        if (result) {
                /* FIXME: this is most likely fatal, umount? */
                printk(KERN_ERR "smb_retry: signal failed [%d]\n", result);
                goto out;
        }
-       VERBOSE("signalled pid %d\n", pid);
+       VERBOSE("signalled pid %d\n", pid_nr(pid));
 
        /* FIXME: The retried requests should perhaps get a "time boost". */
 
 out:
+       put_pid(pid);
        return result;
 }
 
@@ -290,10 +298,6 @@ out:
  */
 static int smbiod(void *unused)
 {
-       daemonize("smbiod");
-
-       allow_signal(SIGKILL);
-
        VERBOSE("SMB Kernel thread starting (%d) ...\n", current->pid);
 
        for (;;) {