[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>
This commit is contained in:
parent
2f92658751
commit
4df08c5258
|
@ -54,6 +54,7 @@
|
||||||
#include <linux/percpu.h>
|
#include <linux/percpu.h>
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
#include <linux/hash.h>
|
#include <linux/hash.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
|
|
||||||
#include "xfs_linux.h"
|
#include "xfs_linux.h"
|
||||||
|
|
||||||
|
@ -1742,9 +1743,7 @@ pagebuf_runall_queues(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Defines for pagebuf daemon */
|
/* Defines for pagebuf daemon */
|
||||||
STATIC DECLARE_COMPLETION(xfsbufd_done);
|
|
||||||
STATIC struct task_struct *xfsbufd_task;
|
STATIC struct task_struct *xfsbufd_task;
|
||||||
STATIC int xfsbufd_active;
|
|
||||||
STATIC int xfsbufd_force_flush;
|
STATIC int xfsbufd_force_flush;
|
||||||
STATIC int xfsbufd_force_sleep;
|
STATIC int xfsbufd_force_sleep;
|
||||||
|
|
||||||
|
@ -1770,14 +1769,8 @@ xfsbufd(
|
||||||
xfs_buftarg_t *target;
|
xfs_buftarg_t *target;
|
||||||
xfs_buf_t *pb, *n;
|
xfs_buf_t *pb, *n;
|
||||||
|
|
||||||
/* Set up the thread */
|
|
||||||
daemonize("xfsbufd");
|
|
||||||
current->flags |= PF_MEMALLOC;
|
current->flags |= PF_MEMALLOC;
|
||||||
|
|
||||||
xfsbufd_task = current;
|
|
||||||
xfsbufd_active = 1;
|
|
||||||
barrier();
|
|
||||||
|
|
||||||
INIT_LIST_HEAD(&tmp);
|
INIT_LIST_HEAD(&tmp);
|
||||||
do {
|
do {
|
||||||
if (unlikely(freezing(current))) {
|
if (unlikely(freezing(current))) {
|
||||||
|
@ -1825,9 +1818,9 @@ xfsbufd(
|
||||||
purge_addresses();
|
purge_addresses();
|
||||||
|
|
||||||
xfsbufd_force_flush = 0;
|
xfsbufd_force_flush = 0;
|
||||||
} while (xfsbufd_active);
|
} while (!kthread_should_stop());
|
||||||
|
|
||||||
complete_and_exit(&xfsbufd_done, 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1910,9 +1903,11 @@ xfs_buf_daemons_start(void)
|
||||||
if (!xfsdatad_workqueue)
|
if (!xfsdatad_workqueue)
|
||||||
goto out_destroy_xfslogd_workqueue;
|
goto out_destroy_xfslogd_workqueue;
|
||||||
|
|
||||||
error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES);
|
xfsbufd_task = kthread_run(xfsbufd, NULL, "xfsbufd");
|
||||||
if (error < 0)
|
if (IS_ERR(xfsbufd_task)) {
|
||||||
|
error = PTR_ERR(xfsbufd_task);
|
||||||
goto out_destroy_xfsdatad_workqueue;
|
goto out_destroy_xfsdatad_workqueue;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_destroy_xfsdatad_workqueue:
|
out_destroy_xfsdatad_workqueue:
|
||||||
|
@ -1929,10 +1924,7 @@ xfs_buf_daemons_start(void)
|
||||||
STATIC void
|
STATIC void
|
||||||
xfs_buf_daemons_stop(void)
|
xfs_buf_daemons_stop(void)
|
||||||
{
|
{
|
||||||
xfsbufd_active = 0;
|
kthread_stop(xfsbufd_task);
|
||||||
barrier();
|
|
||||||
wait_for_completion(&xfsbufd_done);
|
|
||||||
|
|
||||||
destroy_workqueue(xfslogd_workqueue);
|
destroy_workqueue(xfslogd_workqueue);
|
||||||
destroy_workqueue(xfsdatad_workqueue);
|
destroy_workqueue(xfsdatad_workqueue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
#include <linux/mount.h>
|
#include <linux/mount.h>
|
||||||
#include <linux/mempool.h>
|
#include <linux/mempool.h>
|
||||||
#include <linux/writeback.h>
|
#include <linux/writeback.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
|
|
||||||
STATIC struct quotactl_ops linvfs_qops;
|
STATIC struct quotactl_ops linvfs_qops;
|
||||||
STATIC struct super_operations linvfs_sops;
|
STATIC struct super_operations linvfs_sops;
|
||||||
|
@ -516,25 +517,16 @@ xfssyncd(
|
||||||
{
|
{
|
||||||
long timeleft;
|
long timeleft;
|
||||||
vfs_t *vfsp = (vfs_t *) arg;
|
vfs_t *vfsp = (vfs_t *) arg;
|
||||||
struct list_head tmp;
|
|
||||||
struct vfs_sync_work *work, *n;
|
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;
|
timeleft = (xfs_syncd_centisecs * HZ) / 100;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
timeleft = schedule_timeout(timeleft);
|
timeleft = schedule_timeout(timeleft);
|
||||||
/* swsusp */
|
/* swsusp */
|
||||||
try_to_freeze();
|
try_to_freeze();
|
||||||
if (vfsp->vfs_flag & VFS_UMOUNT)
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
spin_lock(&vfsp->vfs_sync_lock);
|
spin_lock(&vfsp->vfs_sync_lock);
|
||||||
|
@ -563,10 +555,6 @@ xfssyncd(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vfsp->vfs_sync_task = NULL;
|
|
||||||
wmb();
|
|
||||||
wake_up(&vfsp->vfs_wait_sync_task);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,13 +562,11 @@ STATIC int
|
||||||
linvfs_start_syncd(
|
linvfs_start_syncd(
|
||||||
vfs_t *vfsp)
|
vfs_t *vfsp)
|
||||||
{
|
{
|
||||||
int pid;
|
vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
|
||||||
|
vfsp->vfs_sync_work.w_vfs = vfsp;
|
||||||
pid = kernel_thread(xfssyncd, (void *) vfsp,
|
vfsp->vfs_sync_task = kthread_run(xfssyncd, vfsp, "xfssyncd");
|
||||||
CLONE_VM | CLONE_FS | CLONE_FILES);
|
if (IS_ERR(vfsp->vfs_sync_task))
|
||||||
if (pid < 0)
|
return -PTR_ERR(vfsp->vfs_sync_task);
|
||||||
return -pid;
|
|
||||||
wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,11 +574,7 @@ STATIC void
|
||||||
linvfs_stop_syncd(
|
linvfs_stop_syncd(
|
||||||
vfs_t *vfsp)
|
vfs_t *vfsp)
|
||||||
{
|
{
|
||||||
vfsp->vfs_flag |= VFS_UMOUNT;
|
kthread_stop(vfsp->vfs_sync_task);
|
||||||
wmb();
|
|
||||||
|
|
||||||
wake_up_process(vfsp->vfs_sync_task);
|
|
||||||
wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
|
|
|
@ -251,7 +251,6 @@ vfs_allocate( void )
|
||||||
bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
|
bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
|
||||||
INIT_LIST_HEAD(&vfsp->vfs_sync_list);
|
INIT_LIST_HEAD(&vfsp->vfs_sync_list);
|
||||||
spin_lock_init(&vfsp->vfs_sync_lock);
|
spin_lock_init(&vfsp->vfs_sync_lock);
|
||||||
init_waitqueue_head(&vfsp->vfs_wait_sync_task);
|
|
||||||
init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
|
init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
|
||||||
return vfsp;
|
return vfsp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ typedef struct vfs {
|
||||||
spinlock_t vfs_sync_lock; /* work item list lock */
|
spinlock_t vfs_sync_lock; /* work item list lock */
|
||||||
int vfs_sync_seq; /* sync thread generation no. */
|
int vfs_sync_seq; /* sync thread generation no. */
|
||||||
wait_queue_head_t vfs_wait_single_sync_task;
|
wait_queue_head_t vfs_wait_single_sync_task;
|
||||||
wait_queue_head_t vfs_wait_sync_task;
|
|
||||||
} vfs_t;
|
} vfs_t;
|
||||||
|
|
||||||
#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
|
#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
|
||||||
|
@ -96,7 +95,6 @@ typedef enum {
|
||||||
#define VFS_RDONLY 0x0001 /* read-only vfs */
|
#define VFS_RDONLY 0x0001 /* read-only vfs */
|
||||||
#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
|
#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
|
||||||
#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
|
#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
|
||||||
#define VFS_UMOUNT 0x0008 /* unmount in progress */
|
|
||||||
#define VFS_END 0x0008 /* max flag */
|
#define VFS_END 0x0008 /* max flag */
|
||||||
|
|
||||||
#define SYNC_ATTR 0x0001 /* sync attributes */
|
#define SYNC_ATTR 0x0001 /* sync attributes */
|
||||||
|
|
Loading…
Reference in New Issue