Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1090011ybt; Wed, 17 Jun 2020 23:38:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqwoDiqc+GzcwxgEw7ekO/4C2ezR9VR1Ph4lr/raoGw39rosXZu52Itg1JCYMjjqk7ANzG X-Received: by 2002:a17:907:20db:: with SMTP id qq27mr2539357ejb.232.1592462331664; Wed, 17 Jun 2020 23:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592462331; cv=none; d=google.com; s=arc-20160816; b=RF3AifIWxcLR6HsN7fWmlA1b50kHyiNzAHN/PVkMKL82Dci/Iqx6G+jgD9qaM8JRp8 oMUIUHSQHGBM6FwST58yLoMUCvtE9IJxjNPGZf//J4G96dy8NWozWq2QP0iALwD4WUu0 Fd+Nt3F6BfVFyHN9cPrVX+VQUeAMmoi6ZunT9R9q/ADpDntn8Xi7oLiS80g2wfZv8+x6 tYJ5BKn3ZDsGEXq/aL1pwmZ1fhGlZXa6d5qP/vL0fxJt39lKx7JCoEIuoXoUINIeqJc7 PCuuSI4FTDl/zut9gCeV4YoPz0UqnHbt+RVeFrnT7aNrRzT5mrmkh8sEhp4+wlvvpdnN qknQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=9Dl8N+tb63STIq0R//sfoPwX/qpQ3sXir2LwLFGxeY8=; b=NzJL3QvhRvjIdDFXeJc+/zpOhEUrKl4bwIQwYzIM3qiOa2smspb7DGxIC199sYCGgW KZx9ztLoJLZ3h+F2vc1m1mX2nrnZy2V8Fo6IuRmQ/Lp29vVtuLQl2rDP4b4iDcWrERyG FPijCiCsHbQmn2BCvhvJchq8wl/affb1gtcjb8+++tsIilYKyUJTZuKGwrvwpbw7KjU/ 3FElVjnLL3L50C0ZCi/l7UG+kplKxZpqWmThNTOOFdYhbhTi5DaVWzRJ8ZmiHlh6vNDD Z7T5sMh7qEqSRiAQ/vy9x5WzETkMMSpAAcmY/luhg/5dUlaZwXpUS6Oje+8ug13mqq27 7mww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si1440320eds.404.2020.06.17.23.38.28; Wed, 17 Jun 2020 23:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbgFRGgq (ORCPT + 99 others); Thu, 18 Jun 2020 02:36:46 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6359 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726940AbgFRGgo (ORCPT ); Thu, 18 Jun 2020 02:36:44 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 798B494F5464E55442C0; Thu, 18 Jun 2020 14:36:40 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Thu, 18 Jun 2020 14:36:30 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 1/5] f2fs: fix to wait page writeback before update Date: Thu, 18 Jun 2020 14:36:21 +0800 Message-ID: <20200618063625.110273-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org to make page content stable for special device like raid. Signed-off-by: Chao Yu --- fs/f2fs/dir.c | 2 ++ fs/f2fs/extent_cache.c | 18 +++++++++--------- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 1 + fs/f2fs/inline.c | 2 ++ fs/f2fs/inode.c | 3 +-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index d35976785e8c..91e86747a604 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -495,6 +495,8 @@ static int make_empty_dir(struct inode *inode, if (IS_ERR(dentry_page)) return PTR_ERR(dentry_page); + f2fs_bug_on(F2FS_I_SB(inode), PageWriteback(dentry_page)); + dentry_blk = page_address(dentry_page); make_dentry_ptr_block(NULL, &d, dentry_blk); diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index e60078460ad1..686c68b98610 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -325,9 +325,10 @@ static void __drop_largest_extent(struct extent_tree *et, } /* return true, if inode page is changed */ -static bool __f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) +static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct f2fs_extent *i_ext = ipage ? &F2FS_INODE(ipage)->i_ext : NULL; struct extent_tree *et; struct extent_node *en; struct extent_info ei; @@ -335,16 +336,18 @@ static bool __f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_e if (!f2fs_may_extent_tree(inode)) { /* drop largest extent */ if (i_ext && i_ext->len) { + f2fs_wait_on_page_writeback(ipage, NODE, true, true); i_ext->len = 0; - return true; + set_page_dirty(ipage); + return; } - return false; + return; } et = __grab_extent_tree(inode); if (!i_ext || !i_ext->len) - return false; + return; get_extent_info(&ei, i_ext); @@ -360,17 +363,14 @@ static bool __f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_e } out: write_unlock(&et->lock); - return false; } -bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) +void f2fs_init_extent_tree(struct inode *inode, struct page *ipage) { - bool ret = __f2fs_init_extent_tree(inode, i_ext); + __f2fs_init_extent_tree(inode, ipage); if (!F2FS_I(inode)->extent_tree) set_inode_flag(inode, FI_NO_EXTENT); - - return ret; } static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index b35a50f4953c..326c12fa0da5 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3795,7 +3795,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi, struct rb_root_cached *root); unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink); -bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext); +void f2fs_init_extent_tree(struct inode *inode, struct page *ipage); void f2fs_drop_extent_tree(struct inode *inode); unsigned int f2fs_destroy_extent_node(struct inode *inode); void f2fs_destroy_extent_tree(struct inode *inode); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 3268f8dd59bb..1862073b96d2 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1250,6 +1250,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode, f2fs_put_page(psrc, 1); return PTR_ERR(pdst); } + f2fs_wait_on_page_writeback(pdst, DATA, true, true); f2fs_copy_page(psrc, pdst); set_page_dirty(pdst); f2fs_put_page(pdst, 1); diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index dbade310dc79..4bcbc486c9e2 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -340,6 +340,8 @@ int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent, struct f2fs_dentry_ptr d; void *inline_dentry; + f2fs_wait_on_page_writeback(ipage, NODE, true, true); + inline_dentry = inline_data_addr(inode, ipage); make_dentry_ptr_inline(inode, &d, inline_dentry); diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 44582a4db513..7c156eb26dd7 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -367,8 +367,7 @@ static int do_read_inode(struct inode *inode) fi->i_pino = le32_to_cpu(ri->i_pino); fi->i_dir_level = ri->i_dir_level; - if (f2fs_init_extent_tree(inode, &ri->i_ext)) - set_page_dirty(node_page); + f2fs_init_extent_tree(inode, node_page); get_inline_info(inode, ri); -- 2.18.0.rc1