Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43b17743 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: introduce DEFAULT_IO_TIMEOUT



As Geert Uytterhoeven reported:

for parameter HZ/50 in congestion_wait(BLK_RW_ASYNC, HZ/50);

On some platforms, HZ can be less than 50, then unexpected 0 timeout
jiffies will be set in congestion_wait().

This patch introduces a macro DEFAULT_IO_TIMEOUT to wrap a determinate
value with msecs_to_jiffies(20) to instead HZ/50 to avoid such issue.

Quoted from Geert Uytterhoeven:

"A timeout of HZ means 1 second.
HZ/50 means 20 ms, but has the risk of being zero, if HZ < 50.

If you want to use a timeout of 20 ms, you best use msecs_to_jiffies(20),
as that takes care of the special cases, and never returns 0."

Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b5fe8c8f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1260,7 +1260,7 @@ void f2fs_wait_on_all_pages(struct f2fs_sb_info *sbi, int type)
		if (unlikely(f2fs_cp_error(sbi)))
			break;

		io_schedule_timeout(HZ/50);
		io_schedule_timeout(DEFAULT_IO_TIMEOUT);
	}
	finish_wait(&sbi->cp_wait, &wait);
}
+2 −1
Original line number Diff line number Diff line
@@ -988,7 +988,8 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
			} else if (ret == -EAGAIN) {
				ret = 0;
				cond_resched();
				congestion_wait(BLK_RW_ASYNC, HZ/50);
				congestion_wait(BLK_RW_ASYNC,
						DEFAULT_IO_TIMEOUT);
				lock_page(cc->rpages[i]);
				clear_page_dirty_for_io(cc->rpages[i]);
				goto retry_write;
+2 −2
Original line number Diff line number Diff line
@@ -2317,7 +2317,7 @@ int f2fs_encrypt_one_page(struct f2fs_io_info *fio)
		/* flush pending IOs and wait for a while in the ENOMEM case */
		if (PTR_ERR(fio->encrypted_page) == -ENOMEM) {
			f2fs_flush_merged_writes(fio->sbi);
			congestion_wait(BLK_RW_ASYNC, HZ/50);
			congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
			gfp_flags |= __GFP_NOFAIL;
			goto retry_encrypt;
		}
@@ -2908,7 +2908,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
					if (wbc->sync_mode == WB_SYNC_ALL) {
						cond_resched();
						congestion_wait(BLK_RW_ASYNC,
								HZ/50);
							DEFAULT_IO_TIMEOUT);
						goto retry_write;
					}
					goto next;
+3 −0
Original line number Diff line number Diff line
@@ -558,6 +558,9 @@ enum {

#define DEFAULT_RETRY_IO_COUNT	8	/* maximum retry read IO count */

/* congestion wait timeout value, default: 20ms */
#define	DEFAULT_IO_TIMEOUT	(msecs_to_jiffies(20))

/* maximum retry quota flush count */
#define DEFAULT_RETRY_QUOTA_FLUSH_COUNT		8

+2 −1
Original line number Diff line number Diff line
@@ -977,7 +977,8 @@ static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
		if (err) {
			clear_cold_data(page);
			if (err == -ENOMEM) {
				congestion_wait(BLK_RW_ASYNC, HZ/50);
				congestion_wait(BLK_RW_ASYNC,
						DEFAULT_IO_TIMEOUT);
				goto retry;
			}
			if (is_dirty)
Loading