Skip to content

Commit 71ac860

Browse files
Ming Leiaxboe
authored andcommitted
block: move blk_io_schedule() out of header file
blk_io_schedule() isn't called from performance sensitive code path, and it is easier to maintain by exporting it as symbol. Also blk_io_schedule() is only called by CONFIG_BLOCK code, so it is safe to do this way. Meantime fixes build failure when CONFIG_BLOCK is off. Cc: Christoph Hellwig <[email protected]> Fixes: e6249cd ("block: add blk_io_schedule() for avoiding task hung in sync dio") Reported-by: Satya Tangirala <[email protected]> Tested-by: Satya Tangirala <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 02ef12a commit 71ac860

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

block/blk-core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/debugfs.h>
3939
#include <linux/bpf.h>
4040
#include <linux/psi.h>
41+
#include <linux/sched/sysctl.h>
4142

4243
#define CREATE_TRACE_POINTS
4344
#include <trace/events/block.h>
@@ -1812,6 +1813,18 @@ void blk_finish_plug(struct blk_plug *plug)
18121813
}
18131814
EXPORT_SYMBOL(blk_finish_plug);
18141815

1816+
void blk_io_schedule(void)
1817+
{
1818+
/* Prevent hang_check timer from firing at us during very long I/O */
1819+
unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
1820+
1821+
if (timeout)
1822+
io_schedule_timeout(timeout);
1823+
else
1824+
io_schedule();
1825+
}
1826+
EXPORT_SYMBOL_GPL(blk_io_schedule);
1827+
18151828
int __init blk_dev_init(void)
18161829
{
18171830
BUILD_BUG_ON(REQ_OP_LAST >= (1 << REQ_OP_BITS));

include/linux/blkdev.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/percpu-refcount.h>
2828
#include <linux/scatterlist.h>
2929
#include <linux/blkzoned.h>
30-
#include <linux/sched/sysctl.h>
3130

3231
struct module;
3332
struct scsi_ioctl_command;
@@ -1221,6 +1220,8 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk)
12211220
!list_empty(&plug->cb_list));
12221221
}
12231222

1223+
extern void blk_io_schedule(void);
1224+
12241225
extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *);
12251226
extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
12261227
sector_t nr_sects, gfp_t gfp_mask, struct page *page);
@@ -1851,15 +1852,4 @@ static inline void blk_wake_io_task(struct task_struct *waiter)
18511852
wake_up_process(waiter);
18521853
}
18531854

1854-
static inline void blk_io_schedule(void)
1855-
{
1856-
/* Prevent hang_check timer from firing at us during very long I/O */
1857-
unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
1858-
1859-
if (timeout)
1860-
io_schedule_timeout(timeout);
1861-
else
1862-
io_schedule();
1863-
}
1864-
18651855
#endif

0 commit comments

Comments
 (0)