From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760393AbcBYJpA (ORCPT ); Thu, 25 Feb 2016 04:45:00 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:51677 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758409AbcBYJo6 (ORCPT ); Thu, 25 Feb 2016 04:44:58 -0500 X-AuditID: cbfee61a-f79266d000003652-75-56cecd175224 From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] f2fs: update inode page under cp_rwsem lock Date: Thu, 25 Feb 2016 17:44:01 +0800 Message-id: <013301d16fb1$302a2d20$907e8760$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdFvsPcYYyfSJ53tQVuVtI9qsLyraw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jQV3xs+fCDN6vM7d4sn4Ws8WlRe4W l3fNYXNg9ti0qpPNY/eCz0wenzfJBTBHcdmkpOZklqUW6dslcGV8+Ode0MVZ8eL4V+YGxk3s XYycHBICJhKbDpxjhLDFJC7cW8/WxcjFISQwi1FiavcKsCIhgVeMEse/cYHYbAIqEss7/jOB 2CJA9qFFl8FqmAU8JBo7vrOC2MICDhKvr3wCs1kEVCVWnmkAs3kFLCUO3boOZQtK/Jh8jwWi V0ti/c7jTBC2vMTmNW+ZIQ5SkNhx9jUjxC49iSVLXrNB1IhLbDxyi2UCI9CVCKNmIRk1C8mo WUhaFjCyrGKUSC1ILihOSs81zEst1ytOzC0uzUvXS87P3cQIDuFnUjsYD+5yP8QowMGoxMPL 8PNsmBBrYllxZe4hRgkOZiUR3qDT58KEeFMSK6tSi/Lji0pzUosPMUpzsCiJ8z7+vy5MSCA9 sSQ1OzW1ILUIJsvEwSnVwKj072NW0eGyJZX3p7nEe2g38+5/98YwmXn9VaGNVjLbqy38ft36 dTQ1vmu1W+be3RwKZwNmziz72uVZKrE+7vBE9atvzVy5eXuO6jiZ/DGYVmNydMWdZtYN0wzL xKOTTAxC+YJ/GejndczsvuGlXxB0NzfU92v1uc25thvf3lt9nXPa3yf7HiqxFGckGmoxFxUn AgAMPg8hXQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should update inode page under protection of cp_rwsem lock, otherwise new dirty inode pages will generated by ->fsync or ->write_inode during checkpoint, which should not be allowed. Signed-off-by: Chao Yu --- fs/f2fs/inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index cb269c4..cdfe114 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -295,6 +295,7 @@ retry: int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + bool updated; if (inode->i_ino == F2FS_NODE_INO(sbi) || inode->i_ino == F2FS_META_INO(sbi)) @@ -307,7 +308,11 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) * We need to balance fs here to prevent from producing dirty node pages * during the urgent cleaning time when runing out of free sections. */ - if (update_inode_page(inode)) + f2fs_lock_op(sbi); + updated = update_inode_page(inode); + f2fs_unlock_op(sbi); + + if (updated) f2fs_balance_fs(sbi, true); return 0; } -- 2.7.0