BACKPORT: f2fs: invalidate meta pages only for post_read required inode
After commit e3b49ea36802 ("f2fs: invalidate META_MAPPING before
IPU/DIO write"), invalidate_mapping_pages() will be called to
avoid race condition in between IPU/DIO and readahead for GC.
However, readahead flow is only used for post_read required inode,
so this patch adds check condition to avoids unnecessary page cache
invalidating for non-post_read inode.
Bug: 243874214
Signed-off-by: Chao Yu <chao.yu@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
(cherry picked from commit 0d5b9d8156396bbe1c982708b38ab9e188c45ec9)
Change-Id: I39a8da4183b59b34522f445d25d8ab9fd2d6319c
(cherry picked from commit 22b447e9bdb357e62fa1bfd85a2e8072e489b68a)
This commit is contained in:
committed by
Treehugger Robot
parent
9b96bd8907
commit
f9bfdf7a59
@@ -1683,8 +1683,6 @@ sync_out:
|
||||
*/
|
||||
f2fs_wait_on_block_writeback_range(inode,
|
||||
map->m_pblk, map->m_len);
|
||||
invalidate_mapping_pages(META_MAPPING(sbi),
|
||||
map->m_pblk, map->m_pblk);
|
||||
|
||||
if (map->m_multidev_dio) {
|
||||
block_t blk_addr = map->m_pblk;
|
||||
@@ -2737,6 +2735,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
|
||||
.submitted = false,
|
||||
.compr_blocks = compr_blocks,
|
||||
.need_lock = LOCK_RETRY,
|
||||
.post_read = f2fs_post_read_required(inode),
|
||||
.io_type = io_type,
|
||||
.io_wbc = wbc,
|
||||
.bio = bio,
|
||||
|
||||
@@ -1208,6 +1208,7 @@ struct f2fs_io_info {
|
||||
bool retry; /* need to reallocate block address */
|
||||
int compr_blocks; /* # of compressed block addresses */
|
||||
bool encrypted; /* indicate file is encrypted */
|
||||
bool post_read; /* require post read */
|
||||
enum iostat_type io_type; /* io type */
|
||||
struct writeback_control *io_wbc; /* writeback control */
|
||||
struct bio **bio; /* bio for ipu */
|
||||
|
||||
@@ -3658,7 +3658,8 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
|
||||
goto drop_bio;
|
||||
}
|
||||
|
||||
invalidate_mapping_pages(META_MAPPING(sbi),
|
||||
if (fio->post_read)
|
||||
invalidate_mapping_pages(META_MAPPING(sbi),
|
||||
fio->new_blkaddr, fio->new_blkaddr);
|
||||
|
||||
stat_inc_inplace_blocks(fio->sbi);
|
||||
@@ -3841,10 +3842,16 @@ void f2fs_wait_on_block_writeback(struct inode *inode, block_t blkaddr)
|
||||
void f2fs_wait_on_block_writeback_range(struct inode *inode, block_t blkaddr,
|
||||
block_t len)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||
block_t i;
|
||||
|
||||
if (!f2fs_post_read_required(inode))
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
f2fs_wait_on_block_writeback(inode, blkaddr + i);
|
||||
|
||||
invalidate_mapping_pages(META_MAPPING(sbi), blkaddr, blkaddr + len - 1);
|
||||
}
|
||||
|
||||
static int read_compacted_summaries(struct f2fs_sb_info *sbi)
|
||||
|
||||
Reference in New Issue
Block a user