diff -ruNp 214-syncthreads-old/fs/buffer.c 214-syncthreads-new/fs/buffer.c --- 214-syncthreads-old/fs/buffer.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/buffer.c 2005-05-02 14:50:03.000000000 +1000 @@ -171,6 +171,10 @@ EXPORT_SYMBOL(sync_blockdev); */ int fsync_super(struct super_block *sb) { + int ret; + + current->flags |= PF_SYNCTHREAD; + sync_inodes_sb(sb, 0); DQUOT_SYNC(sb); lock_super(sb); @@ -182,7 +186,10 @@ int fsync_super(struct super_block *sb) sync_blockdev(sb->s_bdev); sync_inodes_sb(sb, 1); - return sync_blockdev(sb->s_bdev); + ret = sync_blockdev(sb->s_bdev); + + current->flags &= ~PF_SYNCTHREAD; + return ret; } /* @@ -193,12 +200,19 @@ int fsync_super(struct super_block *sb) int fsync_bdev(struct block_device *bdev) { struct super_block *sb = get_super(bdev); + int ret; + + current->flags |= PF_SYNCTHREAD; + if (sb) { int res = fsync_super(sb); drop_super(sb); + current->flags &= ~PF_SYNCTHREAD; return res; } - return sync_blockdev(bdev); + ret = sync_blockdev(bdev); + current->flags &= ~PF_SYNCTHREAD; + return ret; } /** @@ -278,6 +292,8 @@ EXPORT_SYMBOL(thaw_bdev); */ static void do_sync(unsigned long wait) { + current->flags |= PF_SYNCTHREAD; + wakeup_bdflush(0); sync_inodes(0); /* All mappings, inodes and their blockdevs */ DQUOT_SYNC(NULL); @@ -289,6 +305,8 @@ static void do_sync(unsigned long wait) printk("Emergency Sync complete\n"); if (unlikely(laptop_mode)) laptop_sync_completion(); + + current->flags &= ~PF_SYNCTHREAD; } asmlinkage long sys_sync(void) @@ -314,6 +332,8 @@ int file_fsync(struct file *filp, struct struct super_block * sb; int ret, err; + current->flags |= PF_SYNCTHREAD; + /* sync the inode to buffers */ ret = write_inode_now(inode, 0); @@ -328,6 +348,8 @@ int file_fsync(struct file *filp, struct err = sync_blockdev(sb->s_bdev); if (!ret) ret = err; + + current->flags &= ~PF_SYNCTHREAD; return ret; } @@ -337,6 +359,8 @@ asmlinkage long sys_fsync(unsigned int f struct address_space *mapping; int ret, err; + current->flags |= PF_SYNCTHREAD; + ret = -EBADF; file = fget(fd); if (!file) @@ -370,6 +394,7 @@ asmlinkage long sys_fsync(unsigned int f out_putf: fput(file); out: + current->flags &= ~PF_SYNCTHREAD; return ret; } @@ -379,6 +404,8 @@ asmlinkage long sys_fdatasync(unsigned i struct address_space *mapping; int ret, err; + current->flags |= PF_SYNCTHREAD; + ret = -EBADF; file = fget(fd); if (!file) @@ -405,6 +432,7 @@ asmlinkage long sys_fdatasync(unsigned i out_putf: fput(file); out: + current->flags &= ~PF_SYNCTHREAD; return ret; } diff -ruNp 214-syncthreads-old/fs/jbd/journal.c 214-syncthreads-new/fs/jbd/journal.c --- 214-syncthreads-old/fs/jbd/journal.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/jbd/journal.c 2005-05-02 14:50:03.000000000 +1000 @@ -130,6 +130,7 @@ int kjournald(void *arg) current_journal = journal; daemonize("kjournald"); + current->flags |= PF_SYNCTHREAD; /* Set up an interval timer which can be used to trigger a commit wakeup after the commit interval expires */ diff -ruNp 214-syncthreads-old/fs/jffs/intrep.c 214-syncthreads-new/fs/jffs/intrep.c --- 214-syncthreads-old/fs/jffs/intrep.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/jffs/intrep.c 2005-05-02 14:50:03.000000000 +1000 @@ -3364,6 +3364,7 @@ jffs_garbage_collect_thread(void *ptr) D1(int i = 1); daemonize("jffs_gcd"); + current->flags |= PF_SYNCTHREAD; c->gc_task = current; @@ -3399,6 +3400,9 @@ jffs_garbage_collect_thread(void *ptr) siginfo_t info; unsigned long signr = 0; + if (try_to_freeze(PF_FREEZE)) + continue; + spin_lock_irq(¤t->sighand->siglock); signr = dequeue_signal(current, ¤t->blocked, &info); spin_unlock_irq(¤t->sighand->siglock); diff -ruNp 214-syncthreads-old/fs/jfs/jfs_logmgr.c 214-syncthreads-new/fs/jfs/jfs_logmgr.c --- 214-syncthreads-old/fs/jfs/jfs_logmgr.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/jfs/jfs_logmgr.c 2005-05-02 14:50:03.000000000 +1000 @@ -2321,6 +2321,7 @@ int jfsIOWait(void *arg) struct lbuf *bp; daemonize("jfsIO"); + current->flags |= PF_SYNCTHREAD; complete(&jfsIOwait); diff -ruNp 214-syncthreads-old/fs/jfs/jfs_txnmgr.c 214-syncthreads-new/fs/jfs/jfs_txnmgr.c --- 214-syncthreads-old/fs/jfs/jfs_txnmgr.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/jfs/jfs_txnmgr.c 2005-05-02 14:50:03.000000000 +1000 @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include "jfs_incore.h" @@ -2750,6 +2749,7 @@ int jfs_lazycommit(void *arg) struct jfs_sb_info *sbi; daemonize("jfsCommit"); + current->flags |= PF_SYNCTHREAD; complete(&jfsIOwait); diff -ruNp 214-syncthreads-old/fs/lockd/clntlock.c 214-syncthreads-new/fs/lockd/clntlock.c --- 214-syncthreads-old/fs/lockd/clntlock.c 2004-11-03 21:55:00.000000000 +1100 +++ 214-syncthreads-new/fs/lockd/clntlock.c 2005-05-02 14:50:03.000000000 +1000 @@ -200,6 +200,7 @@ reclaimer(void *ptr) struct inode *inode; daemonize("%s-reclaim", host->h_name); + current->flags |= PF_SYNCTHREAD; allow_signal(SIGKILL); /* This one ensures that our parent doesn't terminate while the @@ -222,6 +223,7 @@ restart: fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM; nlmclnt_reclaim(host, fl); + try_to_freeze(PF_FREEZE); if (signalled()) break; goto restart; diff -ruNp 214-syncthreads-old/fs/lockd/svc.c 214-syncthreads-new/fs/lockd/svc.c --- 214-syncthreads-old/fs/lockd/svc.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/lockd/svc.c 2005-05-02 14:50:03.000000000 +1000 @@ -115,6 +115,7 @@ lockd(struct svc_rqst *rqstp) up(&lockd_start); daemonize("lockd"); + current->flags |= PF_SYNCTHREAD; /* Process request with signals blocked, but allow SIGKILL. */ allow_signal(SIGKILL); @@ -138,6 +139,8 @@ lockd(struct svc_rqst *rqstp) while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) { long timeout = MAX_SCHEDULE_TIMEOUT; + try_to_freeze(PF_SYNCTHREAD); + if (signalled()) { flush_signals(current); if (nlmsvc_ops) { diff -ruNp 214-syncthreads-old/fs/nfsd/nfssvc.c 214-syncthreads-new/fs/nfsd/nfssvc.c --- 214-syncthreads-old/fs/nfsd/nfssvc.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/nfsd/nfssvc.c 2005-05-02 14:50:03.000000000 +1000 @@ -182,6 +182,7 @@ nfsd(struct svc_rqst *rqstp) /* Lock module and set up kernel thread */ lock_kernel(); daemonize("nfsd"); + current->flags |= PF_SYNCTHREAD; /* After daemonize() this kernel thread shares current->fs * with the init process. We need to create files with a diff -ruNp 214-syncthreads-old/fs/xfs/linux-2.6/xfs_buf.c 214-syncthreads-new/fs/xfs/linux-2.6/xfs_buf.c --- 214-syncthreads-old/fs/xfs/linux-2.6/xfs_buf.c 2005-05-02 15:39:36.000000000 +1000 +++ 214-syncthreads-new/fs/xfs/linux-2.6/xfs_buf.c 2005-05-02 14:50:03.000000000 +1000 @@ -1770,7 +1770,7 @@ pagebuf_daemon( /* Set up the thread */ daemonize("xfsbufd"); - current->flags |= PF_MEMALLOC; + current->flags |= PF_MEMALLOC | PF_SYNCTHREAD; pagebuf_daemon_task = current; pagebuf_daemon_active = 1; diff -ruNp 214-syncthreads-old/fs/xfs/linux-2.6/xfs_super.c 214-syncthreads-new/fs/xfs/linux-2.6/xfs_super.c --- 214-syncthreads-old/fs/xfs/linux-2.6/xfs_super.c 2005-04-22 23:32:19.000000000 +1000 +++ 214-syncthreads-new/fs/xfs/linux-2.6/xfs_super.c 2005-05-02 14:50:03.000000000 +1000 @@ -471,6 +471,7 @@ xfssyncd( struct vfs_sync_work *work, *n; daemonize("xfssyncd"); + current->flags |= PF_SYNCTHREAD; vfsp->vfs_sync_work.w_vfs = vfsp; vfsp->vfs_sync_work.w_syncer = vfs_sync_worker; diff -ruNp 214-syncthreads-old/include/linux/sched.h 214-syncthreads-new/include/linux/sched.h --- 214-syncthreads-old/include/linux/sched.h 2005-05-02 15:39:37.000000000 +1000 +++ 214-syncthreads-new/include/linux/sched.h 2005-05-02 15:19:04.000000000 +1000 @@ -788,6 +788,8 @@ do { if (atomic_dec_and_test(&(tsk)->usa #define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */ #define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */ #define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */ +#define PF_SYNCTHREAD 0x01000000 /* this thread can start activity during the ++ early part of freezing processes */ /* * Only the _current_ task can read/write to tsk->flags, but other diff -ruNp 214-syncthreads-old/mm/pdflush.c 214-syncthreads-new/mm/pdflush.c --- 214-syncthreads-old/mm/pdflush.c 2005-05-02 15:39:37.000000000 +1000 +++ 214-syncthreads-new/mm/pdflush.c 2005-05-02 14:50:03.000000000 +1000 @@ -89,7 +89,7 @@ struct pdflush_work { static int __pdflush(struct pdflush_work *my_work) { - current->flags |= PF_FLUSHER; + current->flags |= (PF_FLUSHER | PF_SYNCTHREAD); my_work->fn = NULL; my_work->who = current; INIT_LIST_HEAD(&my_work->list);