Skip to content

Commit

Permalink
[XFS] Switch kernel thread handling to the kthread_ API
Browse files Browse the repository at this point in the history
SGI-PV: 942063
SGI-Modid: xfs-linux:xfs-kern:198388a

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Nathan Scott <[email protected]>
  • Loading branch information
Christoph Hellwig authored and natoscott committed Sep 4, 2005
1 parent 2f92658 commit 4df08c5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 46 deletions.
24 changes: 8 additions & 16 deletions fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <linux/percpu.h>
#include <linux/blkdev.h>
#include <linux/hash.h>
#include <linux/kthread.h>

#include "xfs_linux.h"

Expand Down Expand Up @@ -1742,9 +1743,7 @@ pagebuf_runall_queues(
}

/* Defines for pagebuf daemon */
STATIC DECLARE_COMPLETION(xfsbufd_done);
STATIC struct task_struct *xfsbufd_task;
STATIC int xfsbufd_active;
STATIC int xfsbufd_force_flush;
STATIC int xfsbufd_force_sleep;

Expand All @@ -1770,14 +1769,8 @@ xfsbufd(
xfs_buftarg_t *target;
xfs_buf_t *pb, *n;

/* Set up the thread */
daemonize("xfsbufd");
current->flags |= PF_MEMALLOC;

xfsbufd_task = current;
xfsbufd_active = 1;
barrier();

INIT_LIST_HEAD(&tmp);
do {
if (unlikely(freezing(current))) {
Expand Down Expand Up @@ -1825,9 +1818,9 @@ xfsbufd(
purge_addresses();

xfsbufd_force_flush = 0;
} while (xfsbufd_active);
} while (!kthread_should_stop());

complete_and_exit(&xfsbufd_done, 0);
return 0;
}

/*
Expand Down Expand Up @@ -1910,9 +1903,11 @@ xfs_buf_daemons_start(void)
if (!xfsdatad_workqueue)
goto out_destroy_xfslogd_workqueue;

error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES);
if (error < 0)
xfsbufd_task = kthread_run(xfsbufd, NULL, "xfsbufd");
if (IS_ERR(xfsbufd_task)) {
error = PTR_ERR(xfsbufd_task);
goto out_destroy_xfsdatad_workqueue;
}
return 0;

out_destroy_xfsdatad_workqueue:
Expand All @@ -1929,10 +1924,7 @@ xfs_buf_daemons_start(void)
STATIC void
xfs_buf_daemons_stop(void)
{
xfsbufd_active = 0;
barrier();
wait_for_completion(&xfsbufd_done);

kthread_stop(xfsbufd_task);
destroy_workqueue(xfslogd_workqueue);
destroy_workqueue(xfsdatad_workqueue);
}
Expand Down
36 changes: 9 additions & 27 deletions fs/xfs/linux-2.6/xfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include <linux/mount.h>
#include <linux/mempool.h>
#include <linux/writeback.h>
#include <linux/kthread.h>

STATIC struct quotactl_ops linvfs_qops;
STATIC struct super_operations linvfs_sops;
Expand Down Expand Up @@ -516,25 +517,16 @@ xfssyncd(
{
long timeleft;
vfs_t *vfsp = (vfs_t *) arg;
struct list_head tmp;
struct vfs_sync_work *work, *n;
LIST_HEAD (tmp);

daemonize("xfssyncd");

vfsp->vfs_sync_work.w_vfs = vfsp;
vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
vfsp->vfs_sync_task = current;
wmb();
wake_up(&vfsp->vfs_wait_sync_task);

INIT_LIST_HEAD(&tmp);
timeleft = (xfs_syncd_centisecs * HZ) / 100;
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
timeleft = schedule_timeout(timeleft);
/* swsusp */
try_to_freeze();
if (vfsp->vfs_flag & VFS_UMOUNT)
if (kthread_should_stop())
break;

spin_lock(&vfsp->vfs_sync_lock);
Expand Down Expand Up @@ -563,36 +555,26 @@ xfssyncd(
}
}

vfsp->vfs_sync_task = NULL;
wmb();
wake_up(&vfsp->vfs_wait_sync_task);

return 0;
}

STATIC int
linvfs_start_syncd(
vfs_t *vfsp)
{
int pid;

pid = kernel_thread(xfssyncd, (void *) vfsp,
CLONE_VM | CLONE_FS | CLONE_FILES);
if (pid < 0)
return -pid;
wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
vfsp->vfs_sync_work.w_vfs = vfsp;
vfsp->vfs_sync_task = kthread_run(xfssyncd, vfsp, "xfssyncd");
if (IS_ERR(vfsp->vfs_sync_task))
return -PTR_ERR(vfsp->vfs_sync_task);
return 0;
}

STATIC void
linvfs_stop_syncd(
vfs_t *vfsp)
{
vfsp->vfs_flag |= VFS_UMOUNT;
wmb();

wake_up_process(vfsp->vfs_sync_task);
wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
kthread_stop(vfsp->vfs_sync_task);
}

STATIC void
Expand Down
1 change: 0 additions & 1 deletion fs/xfs/linux-2.6/xfs_vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ vfs_allocate( void )
bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
INIT_LIST_HEAD(&vfsp->vfs_sync_list);
spin_lock_init(&vfsp->vfs_sync_lock);
init_waitqueue_head(&vfsp->vfs_wait_sync_task);
init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
return vfsp;
}
Expand Down
2 changes: 0 additions & 2 deletions fs/xfs/linux-2.6/xfs_vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ typedef struct vfs {
spinlock_t vfs_sync_lock; /* work item list lock */
int vfs_sync_seq; /* sync thread generation no. */
wait_queue_head_t vfs_wait_single_sync_task;
wait_queue_head_t vfs_wait_sync_task;
} vfs_t;

#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
Expand Down Expand Up @@ -96,7 +95,6 @@ typedef enum {
#define VFS_RDONLY 0x0001 /* read-only vfs */
#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
#define VFS_UMOUNT 0x0008 /* unmount in progress */
#define VFS_END 0x0008 /* max flag */

#define SYNC_ATTR 0x0001 /* sync attributes */
Expand Down

0 comments on commit 4df08c5

Please sign in to comment.