Skip to content

Commit 05d6f62

Browse files
Dan-Perrytonyhutter
authored andcommitted
Replace usage of schedule_timeout with schedule_timeout_interruptible (openzfs#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 openzfs#16150
1 parent deddfdd commit 05d6f62

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
@@ -401,7 +401,7 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
401401
if (v->vdev_removed)
402402
break;
403403

404-
schedule_timeout(MSEC_TO_TICK(10));
404+
schedule_timeout_interruptible(MSEC_TO_TICK(10));
405405
} else if (unlikely(BDH_PTR_ERR(bdh) == -ERESTARTSYS)) {
406406
timeout = MSEC2NSEC(zfs_vdev_open_timeout_ms * 10);
407407
continue;

module/os/linux/zfs/zvol_os.c

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

803-
schedule_timeout(MSEC_TO_TICK(10));
803+
schedule_timeout_interruptible(
804+
MSEC_TO_TICK(10));
804805
goto retry;
805806
#endif
806807
} else {

0 commit comments

Comments
 (0)