Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1761959ybt; Sat, 27 Jun 2020 19:59:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQNJxoRFdiASqQn/yy103C2RW94IHqdvrqree3aI432oDsIHoD+uHD0VITPrwrRtrosFxx X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr11386102edr.126.1593313173449; Sat, 27 Jun 2020 19:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593313173; cv=none; d=google.com; s=arc-20160816; b=iOz738c7s32YB4bPqGyVWXBH8cI12eM9Ve1K/KxRnSrCndZKDfUCWQSLWhw/+87xmF mtBu83KJkAJ+x5O+6bmh7gdZq2KhCjT7mV0t63vqZTqagDQc9Gl2n3TUaJ/JUpqCNMo6 O/OYXMw/Mzwc7RS36nVfnJxPNSGJNp0Egamvq3/6/X1cGyL6qFfFVbGSm8ijrn5ffoQn 4zOgFGMb3UC+afCUhsbfONPi/TAwx9wJBWbslc287cxoPgu73nYmRTz6xrk17XPDYCFI M4oS0/J6lJEavPV5Q8nHzsRu2Jb6uMr4b7JviYAVf2wrNbHSVbJAhcby00QiPuXwruV/ /c4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=LJ75Y8YHd6tS45piorhyniOGebPz9H8wwX3YB3P6DzQ=; b=tAtdWBdy/grhROgCcl7QvnzRJVTuGTDhomECjpZzTHgXFnyRZRnP2G6BPRcBHGwHT9 cYtYsUmrO5+fr5d42Ysfvmm283g6hEs/uJBRC5xVZGo3dqygR7SQweVk90hBvVZfsTEE MNY/Uf22IMAoDQsrCG8r8vpKEtASEpGlZZElW3uOnGIjZW2IQ14peInBzsU08p6qlqY/ DqsnXwPQVdVurG+EAB8zYC9m4VMq1J8Ie+KtmdZrUc6Mqkwi6aMo4wRBvBpRpiidS8Nu SR+wS+c7WKXbK/xFKERByQqDu5Ldl3ibzEQUPiCTmNXQQXKdAveZel9am+gUSFIqEZZp 1elQ== 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 p15si7077174ejg.22.2020.06.27.19.59.10; Sat, 27 Jun 2020 19:59:33 -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 S1725946AbgF1C6h (ORCPT + 99 others); Sat, 27 Jun 2020 22:58:37 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44796 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725880AbgF1C6h (ORCPT ); Sat, 27 Jun 2020 22:58:37 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C0C51489BF0EB5B79EAD; Sun, 28 Jun 2020 10:58:34 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Sun, 28 Jun 2020 10:58:27 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH v2 1/5] f2fs: fix to wait page writeback before update Date: Sun, 28 Jun 2020 10:58:17 +0800 Message-ID: <20200628025817.90623-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 Filesystem including f2fs should support stable page for special device like software raid, however there is one missing path that page could be updated while it is writeback state as below, fix this. - gc_node_segment - f2fs_move_node_page - __write_node_page - set_page_writeback - do_read_inode - f2fs_init_extent_tree - __f2fs_init_extent_tree i_ext->len = 0; Signed-off-by: Chao Yu --- v2: - add call path into message. - remove unrelated changes. fs/f2fs/extent_cache.c | 18 +++++++++--------- fs/f2fs/f2fs.h | 2 +- fs/f2fs/inode.c | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) 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 cba9c0129f09..54cde692d88d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3821,7 +3821,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/inode.c b/fs/f2fs/inode.c index 33affa788588..66969ae852b9 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.26.2