Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3479172imu; Sun, 11 Nov 2018 16:02:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cNh67scPCXA+cweQGkaC09Auz01wwZgfS0EmNdK69W4qKWohHPxM2OufdXgTWeiKDCe9gG X-Received: by 2002:a63:151f:: with SMTP id v31mr15297261pgl.34.1541980978241; Sun, 11 Nov 2018 16:02:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980978; cv=none; d=google.com; s=arc-20160816; b=c4STI7OIYcozGsE91WoQNcNphOASfRI9N+rPrPEApVktkps0xqXoy0864ww0gMyGFm ff+mpFHmCc6GIy+FTrIG8B3VKTeI0xRJd4+AcwCsNA+m+SXif95O6Z2ZjRA2/qdq4kWh g43YRTG3GJMFDwLnDVZCSDIjWY/f6t8smVgm3/y7MSoivsn1LQMRnbKs8LBK1/Pyu2vc gLGCML2lmK7lYMhQ82VO1/6MM+ErMP4vpksFOBINdcJcJQHMVkZeFVBjKeAc7vbRAfuG M12cxCJuv0PZQtDcbBzp3CMkDS+2xqKrgZdNuBHu5UKsQDvbwEL9QBE8k5+mQv4V77eO 5XVw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kYAIla3cueBJehZpxAKngk2WvOEwxBc8RBpW93M8y5c=; b=x6uC/lctbpaYWQhWQcEva3yUkd29KSLvAh0MaT+oFM58txB8ccJIRMASaxE5Y8/kLg 9Vt8pae47xUodFXnaRJgVeG5D4WYyC2LD80A2Buq+DZxJungM0HDfFqsgcWnat04865z 0J5nbgygdXSwLK+Nij1xye1W177WCsyaY1eOa8+Ihxd9OHwMDOwL4BWZt9cTRYdrZW7V FFj0AX4khd5sLXcI/QRxURsgjEn7LXxLBo6U5l7MEEd4HK5iDXYOLXxr0LIvZQ2L4O5w l3nukTGsdWmYD6NsSlyKF07UbxnY5OVitux1vM8ixoS8kXuWRQza1DI8a7twt1VfI0wg JJqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmW5BMl7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o69-v6si18374865pfo.78.2018.11.11.16.02.43; Sun, 11 Nov 2018 16:02:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmW5BMl7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732351AbeKLJwq (ORCPT + 99 others); Mon, 12 Nov 2018 04:52:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:35248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732160AbeKLIRy (ORCPT ); Mon, 12 Nov 2018 03:17:54 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C840F208A3; Sun, 11 Nov 2018 22:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975278; bh=7YDpWqabAM6r4eKMfHZEaWlLcHuXnwVPS5h/81o7Td0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmW5BMl7FCjvryLLmYfHCJ2DvCoHgvsKSrFSLb2KUuUYIfZjM0jMGWXeIZXnBKeGZ r8hhKqRcvPhNutq3XEOO8+4VeBl6jzjaLW0u2fUOrkE38cF6J9bjVNSibUehOJX3nv L7g3RRJDqVLNmA0qhUfliJR2wMj5UlklUqRpM3MA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 4.19 194/361] f2fs: fix to recover cold bit of inode block during POR Date: Sun, 11 Nov 2018 14:19:01 -0800 Message-Id: <20181111221647.732727870@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu commit ef2a007134b4eaa39264c885999f296577bc87d2 upstream. Testcase to reproduce this bug: 1. mkfs.f2fs /dev/sdd 2. mount -t f2fs /dev/sdd /mnt/f2fs 3. touch /mnt/f2fs/file 4. sync 5. chattr +A /mnt/f2fs/file 6. xfs_io -f /mnt/f2fs/file -c "fsync" 7. godown /mnt/f2fs 8. umount /mnt/f2fs 9. mount -t f2fs /dev/sdd /mnt/f2fs 10. chattr -A /mnt/f2fs/file 11. xfs_io -f /mnt/f2fs/file -c "fsync" 12. umount /mnt/f2fs 13. mount -t f2fs /dev/sdd /mnt/f2fs 14. lsattr /mnt/f2fs/file -----------------N- /mnt/f2fs/file But actually, we expect the corrct result is: -------A---------N- /mnt/f2fs/file The reason is in step 9) we missed to recover cold bit flag in inode block, so later, in fsync, we will skip write inode block due to below condition check, result in lossing data in another SPOR. f2fs_fsync_node_pages() if (!IS_DNODE(page) || !is_cold_node(page)) continue; Note that, I guess that some non-dir inode has already lost cold bit during POR, so in order to reenable recovery for those inode, let's try to recover cold bit in f2fs_iget() to save more fsynced data. Fixes: c56675750d7c ("f2fs: remove unneeded set_cold_node()") Cc: 4.17+ Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/inode.c | 6 ++++++ fs/f2fs/node.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -368,6 +368,12 @@ static int do_read_inode(struct inode *i if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) __recover_inline_status(inode, node_page); + /* try to recover cold bit for non-dir inode */ + if (!S_ISDIR(inode->i_mode) && !is_cold_node(node_page)) { + set_cold_node(node_page, false); + set_page_dirty(node_page); + } + /* get rdev by using inline_info */ __get_inode_rdev(inode, ri); --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2539,7 +2539,7 @@ retry: if (!PageUptodate(ipage)) SetPageUptodate(ipage); fill_node_footer(ipage, ino, ino, 0, true); - set_cold_node(page, false); + set_cold_node(ipage, false); src = F2FS_INODE(page); dst = F2FS_INODE(ipage);