Skip to content

Commit 76e780d

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: introduce f2fs_schedule_timeout()
In f2fs retry logic, we will call f2fs_io_schedule_timeout() to sleep as uninterruptible state (waiting for IO) for a while, however, in several paths below, we are not blocked by IO: - f2fs_write_single_data_page() return -EAGAIN due to racing on cp_rwsem. - f2fs_flush_device_cache() failed to submit preflush command. - __issue_discard_cmd_range() sleeps periodically in between two in batch discard submissions. So, in order to reveal state of task more accurate, let's introduce f2fs_schedule_timeout() and call it in above paths in where we are waiting for non-IO reasons. Then we can get real reason of uninterruptible sleep for a thread in tracepoint, perfetto, etc. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 30a8496 commit 76e780d

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

fs/f2fs/checkpoint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ void f2fs_wait_on_all_pages(struct f2fs_sb_info *sbi, int type)
13181318
f2fs_submit_merged_write(sbi, DATA);
13191319

13201320
prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE);
1321-
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
1321+
io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
13221322
}
13231323
finish_wait(&sbi->cp_wait, &wait);
13241324
}
@@ -1974,7 +1974,7 @@ void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi)
19741974

19751975
/* Let's wait for the previous dispatched checkpoint. */
19761976
while (atomic_read(&cprc->queued_ckpt))
1977-
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
1977+
io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
19781978
}
19791979

19801980
void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi)

fs/f2fs/compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static void cancel_cluster_writeback(struct compress_ctx *cc,
10571057
f2fs_submit_merged_write(F2FS_I_SB(cc->inode), DATA);
10581058
while (atomic_read(&cic->pending_pages) !=
10591059
(cc->valid_nr_cpages - submitted + 1))
1060-
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
1060+
f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
10611061
}
10621062

10631063
/* Cancel writeback and stay locked. */
@@ -1574,7 +1574,7 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
15741574
*/
15751575
if (IS_NOQUOTA(cc->inode))
15761576
goto out;
1577-
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
1577+
f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
15781578
goto retry_write;
15791579
}
15801580
goto out;

fs/f2fs/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,8 +3141,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
31413141
} else if (ret == -EAGAIN) {
31423142
ret = 0;
31433143
if (wbc->sync_mode == WB_SYNC_ALL) {
3144-
f2fs_io_schedule_timeout(
3145-
DEFAULT_IO_TIMEOUT);
3144+
f2fs_schedule_timeout(
3145+
DEFAULT_SCHEDULE_TIMEOUT);
31463146
goto retry_write;
31473147
}
31483148
goto next;

fs/f2fs/f2fs.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ enum {
656656

657657
#define DEFAULT_RETRY_IO_COUNT 8 /* maximum retry read IO or flush count */
658658

659-
/* congestion wait timeout value, default: 20ms */
660-
#define DEFAULT_IO_TIMEOUT (msecs_to_jiffies(20))
659+
/* IO/non-IO congestion wait timeout value, default: 20ms */
660+
#define DEFAULT_SCHEDULE_TIMEOUT (msecs_to_jiffies(20))
661661

662662
/* timeout value injected, default: 1000ms */
663663
#define DEFAULT_FAULT_TIMEOUT (msecs_to_jiffies(1000))
@@ -4908,22 +4908,30 @@ static inline bool f2fs_block_unit_discard(struct f2fs_sb_info *sbi)
49084908
return F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_BLOCK;
49094909
}
49104910

4911-
static inline void f2fs_io_schedule_timeout(long timeout)
4911+
static inline void __f2fs_schedule_timeout(long timeout, bool io)
49124912
{
49134913
set_current_state(TASK_UNINTERRUPTIBLE);
4914-
io_schedule_timeout(timeout);
4914+
if (io)
4915+
io_schedule_timeout(timeout);
4916+
else
4917+
schedule_timeout(timeout);
49154918
}
49164919

4920+
#define f2fs_io_schedule_timeout(timeout) \
4921+
__f2fs_schedule_timeout(timeout, true)
4922+
#define f2fs_schedule_timeout(timeout) \
4923+
__f2fs_schedule_timeout(timeout, false)
4924+
49174925
static inline void f2fs_io_schedule_timeout_killable(long timeout)
49184926
{
49194927
while (timeout) {
49204928
if (fatal_signal_pending(current))
49214929
return;
49224930
set_current_state(TASK_UNINTERRUPTIBLE);
4923-
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
4924-
if (timeout <= DEFAULT_IO_TIMEOUT)
4931+
io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
4932+
if (timeout <= DEFAULT_SCHEDULE_TIMEOUT)
49254933
return;
4926-
timeout -= DEFAULT_IO_TIMEOUT;
4934+
timeout -= DEFAULT_SCHEDULE_TIMEOUT;
49274935
}
49284936
}
49294937

fs/f2fs/segment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ int f2fs_flush_device_cache(struct f2fs_sb_info *sbi)
750750
do {
751751
ret = __submit_flush_wait(sbi, FDEV(i).bdev);
752752
if (ret)
753-
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
753+
f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
754754
} while (ret && --count);
755755

756756
if (ret) {
@@ -3471,7 +3471,7 @@ static unsigned int __issue_discard_cmd_range(struct f2fs_sb_info *sbi,
34713471
blk_finish_plug(&plug);
34723472
mutex_unlock(&dcc->cmd_lock);
34733473
trimmed += __wait_all_discard_cmd(sbi, NULL);
3474-
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
3474+
f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
34753475
goto next;
34763476
}
34773477
skip:

fs/f2fs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2652,7 +2652,7 @@ static int f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26522652
/* we should flush all the data to keep data consistency */
26532653
while (get_pages(sbi, F2FS_DIRTY_DATA)) {
26542654
writeback_inodes_sb_nr(sbi->sb, nr_pages, WB_REASON_SYNC);
2655-
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
2655+
f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
26562656

26572657
if (f2fs_time_over(sbi, ENABLE_TIME))
26582658
break;

0 commit comments

Comments
 (0)