Commit 041e0e3b authored by Nishanth Aravamudan's avatar Nishanth Aravamudan Committed by Linus Torvalds

[PATCH] fs: fix-up schedule_timeout() usage

Use schedule_timeout_{,un}interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.  Also use helper
functions to convert between human time units and jiffies rather than constant
HZ division to avoid rounding errors.
Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 373016e9
...@@ -3215,10 +3215,8 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) ...@@ -3215,10 +3215,8 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
} }
cifs_sb->tcon = NULL; cifs_sb->tcon = NULL;
if (ses) { if (ses)
set_current_state(TASK_INTERRUPTIBLE); schedule_timeout_interruptible(msecs_to_jiffies(500));
schedule_timeout(HZ / 2);
}
if (ses) if (ses)
sesInfoFree(ses); sesInfoFree(ses);
......
...@@ -1340,8 +1340,7 @@ int journal_stop(handle_t *handle) ...@@ -1340,8 +1340,7 @@ int journal_stop(handle_t *handle)
if (handle->h_sync) { if (handle->h_sync) {
do { do {
old_handle_count = transaction->t_handle_count; old_handle_count = transaction->t_handle_count;
set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout_uninterruptible(1);
schedule_timeout(1);
} while (old_handle_count != transaction->t_handle_count); } while (old_handle_count != transaction->t_handle_count);
} }
......
...@@ -299,8 +299,7 @@ nlmclnt_alloc_call(void) ...@@ -299,8 +299,7 @@ nlmclnt_alloc_call(void)
return call; return call;
} }
printk("nlmclnt_alloc_call: failed, waiting for memory\n"); printk("nlmclnt_alloc_call: failed, waiting for memory\n");
current->state = TASK_INTERRUPTIBLE; schedule_timeout_interruptible(5*HZ);
schedule_timeout(5*HZ);
} }
return NULL; return NULL;
} }
......
...@@ -34,8 +34,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) ...@@ -34,8 +34,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
res = rpc_call_sync(clnt, msg, flags); res = rpc_call_sync(clnt, msg, flags);
if (res != -EJUKEBOX) if (res != -EJUKEBOX)
break; break;
set_current_state(TASK_INTERRUPTIBLE); schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME);
schedule_timeout(NFS_JUKEBOX_RETRY_TIME);
res = -ERESTARTSYS; res = -ERESTARTSYS;
} while (!signalled()); } while (!signalled());
rpc_clnt_sigunmask(clnt, &oldset); rpc_clnt_sigunmask(clnt, &oldset);
......
...@@ -2418,14 +2418,11 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout) ...@@ -2418,14 +2418,11 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
*timeout = NFS4_POLL_RETRY_MAX; *timeout = NFS4_POLL_RETRY_MAX;
rpc_clnt_sigmask(clnt, &oldset); rpc_clnt_sigmask(clnt, &oldset);
if (clnt->cl_intr) { if (clnt->cl_intr) {
set_current_state(TASK_INTERRUPTIBLE); schedule_timeout_interruptible(*timeout);
schedule_timeout(*timeout);
if (signalled()) if (signalled())
res = -ERESTARTSYS; res = -ERESTARTSYS;
} else { } else
set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout_uninterruptible(*timeout);
schedule_timeout(*timeout);
}
rpc_clnt_sigunmask(clnt, &oldset); rpc_clnt_sigunmask(clnt, &oldset);
*timeout <<= 1; *timeout <<= 1;
return res; return res;
...@@ -2578,8 +2575,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4 ...@@ -2578,8 +2575,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
static unsigned long static unsigned long
nfs4_set_lock_task_retry(unsigned long timeout) nfs4_set_lock_task_retry(unsigned long timeout)
{ {
current->state = TASK_INTERRUPTIBLE; schedule_timeout_interruptible(timeout);
schedule_timeout(timeout);
timeout <<= 1; timeout <<= 1;
if (timeout > NFS4_LOCK_MAXTIMEOUT) if (timeout > NFS4_LOCK_MAXTIMEOUT)
return NFS4_LOCK_MAXTIMEOUT; return NFS4_LOCK_MAXTIMEOUT;
......
...@@ -2868,8 +2868,7 @@ static void let_transaction_grow(struct super_block *sb, unsigned long trans_id) ...@@ -2868,8 +2868,7 @@ static void let_transaction_grow(struct super_block *sb, unsigned long trans_id)
struct reiserfs_journal *journal = SB_JOURNAL(sb); struct reiserfs_journal *journal = SB_JOURNAL(sb);
unsigned long bcount = journal->j_bcount; unsigned long bcount = journal->j_bcount;
while (1) { while (1) {
set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout_uninterruptible(1);
schedule_timeout(1);
journal->j_current_jl->j_state |= LIST_COMMIT_PENDING; journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
while ((atomic_read(&journal->j_wcount) > 0 || while ((atomic_read(&journal->j_wcount) > 0 ||
atomic_read(&journal->j_jlock)) && atomic_read(&journal->j_jlock)) &&
......
...@@ -2397,8 +2397,7 @@ smb_proc_readdir_long(struct file *filp, void *dirent, filldir_t filldir, ...@@ -2397,8 +2397,7 @@ smb_proc_readdir_long(struct file *filp, void *dirent, filldir_t filldir,
if (req->rq_rcls == ERRSRV && req->rq_err == ERRerror) { if (req->rq_rcls == ERRSRV && req->rq_err == ERRerror) {
/* a damn Win95 bug - sometimes it clags if you /* a damn Win95 bug - sometimes it clags if you
ask it too fast */ ask it too fast */
current->state = TASK_INTERRUPTIBLE; schedule_timeout_interruptible(msecs_to_jiffies(200));
schedule_timeout(HZ/5);
continue; continue;
} }
......
...@@ -39,8 +39,7 @@ typedef struct timespec timespec_t; ...@@ -39,8 +39,7 @@ typedef struct timespec timespec_t;
static inline void delay(long ticks) static inline void delay(long ticks)
{ {
set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout_uninterruptible(ticks);
schedule_timeout(ticks);
} }
static inline void nanotime(struct timespec *tvp) static inline void nanotime(struct timespec *tvp)
......
...@@ -1780,10 +1780,10 @@ xfsbufd( ...@@ -1780,10 +1780,10 @@ xfsbufd(
xfsbufd_force_sleep = 0; xfsbufd_force_sleep = 0;
} }
set_current_state(TASK_INTERRUPTIBLE); schedule_timeout_interruptible
schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100); (xfs_buf_timer_centisecs * msecs_to_jiffies(10));
age = (xfs_buf_age_centisecs * HZ) / 100; age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
spin_lock(&pbd_delwrite_lock); spin_lock(&pbd_delwrite_lock);
list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) { list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb)); PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
......
...@@ -467,7 +467,7 @@ xfs_flush_inode( ...@@ -467,7 +467,7 @@ xfs_flush_inode(
igrab(inode); igrab(inode);
xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work); xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work);
delay(HZ/2); delay(msecs_to_jiffies(500));
} }
/* /*
...@@ -492,7 +492,7 @@ xfs_flush_device( ...@@ -492,7 +492,7 @@ xfs_flush_device(
igrab(inode); igrab(inode);
xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work); xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work);
delay(HZ/2); delay(msecs_to_jiffies(500));
xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
} }
...@@ -520,10 +520,9 @@ xfssyncd( ...@@ -520,10 +520,9 @@ xfssyncd(
struct vfs_sync_work *work, *n; struct vfs_sync_work *work, *n;
LIST_HEAD (tmp); LIST_HEAD (tmp);
timeleft = (xfs_syncd_centisecs * HZ) / 100; timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); timeleft = schedule_timeout_interruptible(timeleft);
timeleft = schedule_timeout(timeleft);
/* swsusp */ /* swsusp */
try_to_freeze(); try_to_freeze();
if (kthread_should_stop()) if (kthread_should_stop())
...@@ -537,7 +536,8 @@ xfssyncd( ...@@ -537,7 +536,8 @@ xfssyncd(
*/ */
if (!timeleft || list_empty(&vfsp->vfs_sync_list)) { if (!timeleft || list_empty(&vfsp->vfs_sync_list)) {
if (!timeleft) if (!timeleft)
timeleft = (xfs_syncd_centisecs * HZ) / 100; timeleft = xfs_syncd_centisecs *
msecs_to_jiffies(10);
INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list); INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list);
list_add_tail(&vfsp->vfs_sync_work.w_list, list_add_tail(&vfsp->vfs_sync_work.w_list,
&vfsp->vfs_sync_list); &vfsp->vfs_sync_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment