Skip to content

Commit 2dff752

Browse files
authored
Replace usage of schedule_timeout with schedule_timeout_interruptible (#16150)
This commit replaces current usages of schedule_timeout() with schedule_timeout_interruptible() in code paths that expect the running task to sleep for a short period of time. When schedule_timeout() is called without previously calling set_current_state(), the running task never sleeps because the task state remains in TASK_RUNNING. By calling schedule_timeout_interruptible() to set the task state to TASK_INTERRUPTIBLE before calling schedule_timeout() we achieve the intended/desired behavior of putting the task to sleep for the specified timeout. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Daniel Perry <[email protected]> Closes #16150
1 parent 04bae5e commit 2dff752

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

module/os/linux/spl/spl-taskq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ task_alloc(taskq_t *tq, uint_t flags, unsigned long *irqflags)
158158
* throttling the task dispatch rate.
159159
*/
160160
spin_unlock_irqrestore(&tq->tq_lock, *irqflags);
161-
schedule_timeout(HZ / 100);
161+
schedule_timeout_interruptible(HZ / 100);
162162
spin_lock_irqsave_nested(&tq->tq_lock, *irqflags,
163163
tq->tq_lock_class);
164164
if (count < 100) {

module/os/linux/zfs/vdev_disk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
397397
if (v->vdev_removed)
398398
break;
399399

400-
schedule_timeout(MSEC_TO_TICK(10));
400+
schedule_timeout_interruptible(MSEC_TO_TICK(10));
401401
} else if (unlikely(BDH_PTR_ERR(bdh) == -ERESTARTSYS)) {
402402
timeout = MSEC2NSEC(zfs_vdev_open_timeout_ms * 10);
403403
continue;

module/os/linux/zfs/zvol_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,8 @@ zvol_open(struct block_device *bdev, fmode_t flag)
798798
if ((gethrtime() - start) > timeout)
799799
return (SET_ERROR(-ERESTARTSYS));
800800

801-
schedule_timeout(MSEC_TO_TICK(10));
801+
schedule_timeout_interruptible(
802+
MSEC_TO_TICK(10));
802803
goto retry;
803804
#endif
804805
} else {

0 commit comments

Comments
 (0)