aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@sgi.com>2005-09-04 18:34:18 -0400
committerNathan Scott <nathans@sgi.com>2005-09-04 18:34:18 -0400
commit4df08c52582be558e12316ae60bf077ca8f17a1e (patch)
tree11d32ac6553e26198ec1be4b830f57c8668d7cca /fs
parent2f926587512869ebf6bc820bd5f030e127aae774 (diff)
[XFS] Switch kernel thread handling to the kthread_ API
SGI-PV: 942063 SGI-Modid: xfs-linux:xfs-kern:198388a Signed-off-by: Christoph Hellwig <hch@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c24
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c36
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h2
4 files changed, 17 insertions, 46 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index e6340906342c..655bf4a78afe 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -54,6 +54,7 @@
54#include <linux/percpu.h> 54#include <linux/percpu.h>
55#include <linux/blkdev.h> 55#include <linux/blkdev.h>
56#include <linux/hash.h> 56#include <linux/hash.h>
57#include <linux/kthread.h>
57 58
58#include "xfs_linux.h" 59#include "xfs_linux.h"
59 60
@@ -1742,9 +1743,7 @@ pagebuf_runall_queues(
1742} 1743}
1743 1744
1744/* Defines for pagebuf daemon */ 1745/* Defines for pagebuf daemon */
1745STATIC DECLARE_COMPLETION(xfsbufd_done);
1746STATIC struct task_struct *xfsbufd_task; 1746STATIC struct task_struct *xfsbufd_task;
1747STATIC int xfsbufd_active;
1748STATIC int xfsbufd_force_flush; 1747STATIC int xfsbufd_force_flush;
1749STATIC int xfsbufd_force_sleep; 1748STATIC int xfsbufd_force_sleep;
1750 1749
@@ -1770,14 +1769,8 @@ xfsbufd(
1770 xfs_buftarg_t *target; 1769 xfs_buftarg_t *target;
1771 xfs_buf_t *pb, *n; 1770 xfs_buf_t *pb, *n;
1772 1771
1773 /* Set up the thread */
1774 daemonize("xfsbufd");
1775 current->flags |= PF_MEMALLOC; 1772 current->flags |= PF_MEMALLOC;
1776 1773
1777 xfsbufd_task = current;
1778 xfsbufd_active = 1;
1779 barrier();
1780
1781 INIT_LIST_HEAD(&tmp); 1774 INIT_LIST_HEAD(&tmp);
1782 do { 1775 do {
1783 if (unlikely(freezing(current))) { 1776 if (unlikely(freezing(current))) {
@@ -1825,9 +1818,9 @@ xfsbufd(
1825 purge_addresses(); 1818 purge_addresses();
1826 1819
1827 xfsbufd_force_flush = 0; 1820 xfsbufd_force_flush = 0;
1828 } while (xfsbufd_active); 1821 } while (!kthread_should_stop());
1829 1822
1830 complete_and_exit(&xfsbufd_done, 0); 1823 return 0;
1831} 1824}
1832 1825
1833/* 1826/*
@@ -1910,9 +1903,11 @@ xfs_buf_daemons_start(void)
1910 if (!xfsdatad_workqueue) 1903 if (!xfsdatad_workqueue)
1911 goto out_destroy_xfslogd_workqueue; 1904 goto out_destroy_xfslogd_workqueue;
1912 1905
1913 error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES); 1906 xfsbufd_task = kthread_run(xfsbufd, NULL, "xfsbufd");
1914 if (error < 0) 1907 if (IS_ERR(xfsbufd_task)) {
1908 error = PTR_ERR(xfsbufd_task);
1915 goto out_destroy_xfsdatad_workqueue; 1909 goto out_destroy_xfsdatad_workqueue;
1910 }
1916 return 0; 1911 return 0;
1917 1912
1918 out_destroy_xfsdatad_workqueue: 1913 out_destroy_xfsdatad_workqueue:
@@ -1929,10 +1924,7 @@ xfs_buf_daemons_start(void)
1929STATIC void 1924STATIC void
1930xfs_buf_daemons_stop(void) 1925xfs_buf_daemons_stop(void)
1931{ 1926{
1932 xfsbufd_active = 0; 1927 kthread_stop(xfsbufd_task);
1933 barrier();
1934 wait_for_completion(&xfsbufd_done);
1935
1936 destroy_workqueue(xfslogd_workqueue); 1928 destroy_workqueue(xfslogd_workqueue);
1937 destroy_workqueue(xfsdatad_workqueue); 1929 destroy_workqueue(xfsdatad_workqueue);
1938} 1930}
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 910e43bfc95b..0da87bfc9999 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -72,6 +72,7 @@
72#include <linux/mount.h> 72#include <linux/mount.h>
73#include <linux/mempool.h> 73#include <linux/mempool.h>
74#include <linux/writeback.h> 74#include <linux/writeback.h>
75#include <linux/kthread.h>
75 76
76STATIC struct quotactl_ops linvfs_qops; 77STATIC struct quotactl_ops linvfs_qops;
77STATIC struct super_operations linvfs_sops; 78STATIC struct super_operations linvfs_sops;
@@ -516,25 +517,16 @@ xfssyncd(
516{ 517{
517 long timeleft; 518 long timeleft;
518 vfs_t *vfsp = (vfs_t *) arg; 519 vfs_t *vfsp = (vfs_t *) arg;
519 struct list_head tmp;
520 struct vfs_sync_work *work, *n; 520 struct vfs_sync_work *work, *n;
521 LIST_HEAD (tmp);
521 522
522 daemonize("xfssyncd");
523
524 vfsp->vfs_sync_work.w_vfs = vfsp;
525 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
526 vfsp->vfs_sync_task = current;
527 wmb();
528 wake_up(&vfsp->vfs_wait_sync_task);
529
530 INIT_LIST_HEAD(&tmp);
531 timeleft = (xfs_syncd_centisecs * HZ) / 100; 523 timeleft = (xfs_syncd_centisecs * HZ) / 100;
532 for (;;) { 524 for (;;) {
533 set_current_state(TASK_INTERRUPTIBLE); 525 set_current_state(TASK_INTERRUPTIBLE);
534 timeleft = schedule_timeout(timeleft); 526 timeleft = schedule_timeout(timeleft);
535 /* swsusp */ 527 /* swsusp */
536 try_to_freeze(); 528 try_to_freeze();
537 if (vfsp->vfs_flag & VFS_UMOUNT) 529 if (kthread_should_stop())
538 break; 530 break;
539 531
540 spin_lock(&vfsp->vfs_sync_lock); 532 spin_lock(&vfsp->vfs_sync_lock);
@@ -563,10 +555,6 @@ xfssyncd(
563 } 555 }
564 } 556 }
565 557
566 vfsp->vfs_sync_task = NULL;
567 wmb();
568 wake_up(&vfsp->vfs_wait_sync_task);
569
570 return 0; 558 return 0;
571} 559}
572 560
@@ -574,13 +562,11 @@ STATIC int
574linvfs_start_syncd( 562linvfs_start_syncd(
575 vfs_t *vfsp) 563 vfs_t *vfsp)
576{ 564{
577 int pid; 565 vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
578 566 vfsp->vfs_sync_work.w_vfs = vfsp;
579 pid = kernel_thread(xfssyncd, (void *) vfsp, 567 vfsp->vfs_sync_task = kthread_run(xfssyncd, vfsp, "xfssyncd");
580 CLONE_VM | CLONE_FS | CLONE_FILES); 568 if (IS_ERR(vfsp->vfs_sync_task))
581 if (pid < 0) 569 return -PTR_ERR(vfsp->vfs_sync_task);
582 return -pid;
583 wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
584 return 0; 570 return 0;
585} 571}
586 572
@@ -588,11 +574,7 @@ STATIC void
588linvfs_stop_syncd( 574linvfs_stop_syncd(
589 vfs_t *vfsp) 575 vfs_t *vfsp)
590{ 576{
591 vfsp->vfs_flag |= VFS_UMOUNT; 577 kthread_stop(vfsp->vfs_sync_task);
592 wmb();
593
594 wake_up_process(vfsp->vfs_sync_task);
595 wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
596} 578}
597 579
598STATIC void 580STATIC void
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c
index 669c61644959..34cc902ec119 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.c
+++ b/fs/xfs/linux-2.6/xfs_vfs.c
@@ -251,7 +251,6 @@ vfs_allocate( void )
251 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs"); 251 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
252 INIT_LIST_HEAD(&vfsp->vfs_sync_list); 252 INIT_LIST_HEAD(&vfsp->vfs_sync_list);
253 spin_lock_init(&vfsp->vfs_sync_lock); 253 spin_lock_init(&vfsp->vfs_sync_lock);
254 init_waitqueue_head(&vfsp->vfs_wait_sync_task);
255 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); 254 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
256 return vfsp; 255 return vfsp;
257} 256}
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 7ee1f714e9ba..f0ab574fb47a 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -65,7 +65,6 @@ typedef struct vfs {
65 spinlock_t vfs_sync_lock; /* work item list lock */ 65 spinlock_t vfs_sync_lock; /* work item list lock */
66 int vfs_sync_seq; /* sync thread generation no. */ 66 int vfs_sync_seq; /* sync thread generation no. */
67 wait_queue_head_t vfs_wait_single_sync_task; 67 wait_queue_head_t vfs_wait_single_sync_task;
68 wait_queue_head_t vfs_wait_sync_task;
69} vfs_t; 68} vfs_t;
70 69
71#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */ 70#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
@@ -96,7 +95,6 @@ typedef enum {
96#define VFS_RDONLY 0x0001 /* read-only vfs */ 95#define VFS_RDONLY 0x0001 /* read-only vfs */
97#define VFS_GRPID 0x0002 /* group-ID assigned from directory */ 96#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
98#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ 97#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
99#define VFS_UMOUNT 0x0008 /* unmount in progress */
100#define VFS_END 0x0008 /* max flag */ 98#define VFS_END 0x0008 /* max flag */
101 99
102#define SYNC_ATTR 0x0001 /* sync attributes */ 100#define SYNC_ATTR 0x0001 /* sync attributes */