Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp856441iog; Fri, 17 Jun 2022 15:38:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMqHmImeg7MtyZIn4P08ZETZDJdcCEe5KXqwDBE5JAuk6kgTgok13Tm4au6MAc/2N39P0x X-Received: by 2002:a17:906:ce36:b0:711:d032:e99 with SMTP id sd22-20020a170906ce3600b00711d0320e99mr11548884ejb.242.1655505521113; Fri, 17 Jun 2022 15:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655505521; cv=none; d=google.com; s=arc-20160816; b=VpMvh2qbSbzsWJUuC84fABvHldoymcYdYXRvkPynMQG+g6fr1bdWvgNSVhCM8dKyNl u5pcJP2JzILlKa4obss04mi9/dQEv0B2KfnorZs5Da2A0xvLKuRTPvio/+CN2Zxo3Nkh SLvyA2FfLg5tExo2XqVk03aIR60E4YObPp4MgEo8CxeA7ve/Qt0dbWB8iX1WrlDmz96R idf1fKLUuwNSs6KSm6hDnYueVRrAs+oLsn2Q0bgG+9hHdpq8txZYfj5OAtwNT1Le8kfE VGz7WHVxzXku2hGmJByJa6+mCAvsPxPX5LTjJyYylI/OoZ773IEUMIbNlO7ElLysIM5W 8jmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=g8NrGc5w5lL73F+pp+dUVWOn7yuIx+GYMu7GqYXSCEo=; b=yrHkWB+/3v1fDv33qF1v93eIfZuTi1ZhmAJfof2SZq5XZUePwEYMrTRahcqdxG8y+6 x1ByYBlJuIZrCp6nZ6/4oBY/+9WUfJHVXR7GKpykFP7CZfHk4JVN//i1TOAPgYhpNWMo T6F/EC5c54hiwsdOpGiCBF6JhWD/JhnDMHTXZwK4xeD77ErZAuNuWBkjxIuTdYjF0SKz BSCjGu18pWRPCjztVBJivjnptodgyGHYjdSfCJV4BOIxQb2f9fuly98/p0zaem/TrkF1 b56i0d3CO+GXdxu0XQlwBHcmuXaeno/3e3JeAD0a/AaWSfir1Gxq0ZEu7tElzfF1+ojT Uvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cfe2aC3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d23-20020a50fe97000000b0042bc9f106dcsi1798287edt.192.2022.06.17.15.38.15; Fri, 17 Jun 2022 15:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cfe2aC3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235826AbiFQWbZ (ORCPT + 99 others); Fri, 17 Jun 2022 18:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235060AbiFQWbY (ORCPT ); Fri, 17 Jun 2022 18:31:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3352C62125; Fri, 17 Jun 2022 15:31:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3374B82B1E; Fri, 17 Jun 2022 22:31:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FB69C3411B; Fri, 17 Jun 2022 22:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655505080; bh=Jp4eIONtSs6CWILka62alidYJLIpx9VDEl4Ouzu1iBE=; h=From:To:Cc:Subject:Date:From; b=cfe2aC3SsNv0taX/O9yxiekxXZfxv7Xte5M7lNEsPf9x0mhp1IskXj9gxyIHxJQeM SMXqmYDl6hCotPpO7UIzpuF5kXqA/b561wOipbmHC6YV1wYklHKqHaZmmi1HGGnajd Mxhthm91pBBjLjNK2knc9Royz6jSdAjxwpTtwQFWE8UYt9hnGD5e6IcSn6qIx+aRyi qMvIReINpOQ++H5QLWm4pDap7NU8sZiiBCagoXMnDWeFOrH1lg5c0lkj1pIlEnWWm+ OaYHWWY6rsZRtmxOZLoDYNkTvhR10qy1yj/rBNEsN+Rn248lpISKV7bKA6ND7yPRla 3uIeLQYhieXBg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , stable@vger.kernel.org Subject: [PATCH 1/3] f2fs: attach inline_data after setting compression Date: Fri, 17 Jun 2022 15:31:04 -0700 Message-Id: <20220617223106.3517374-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes the below corruption. [345393.335389] F2FS-fs (vdb): sanity_check_inode: inode (ino=6d0, mode=33206) should not have inline_data, run fsck to fix Cc: Fixes: 677a82b44ebf ("f2fs: fix to do sanity check for inline inode") Signed-off-by: Jaegeuk Kim --- fs/f2fs/namei.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index c549acb52ac4..a841abe6a071 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -89,8 +89,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, if (test_opt(sbi, INLINE_XATTR)) set_inode_flag(inode, FI_INLINE_XATTR); - if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode)) - set_inode_flag(inode, FI_INLINE_DATA); if (f2fs_may_inline_dentry(inode)) set_inode_flag(inode, FI_INLINE_DENTRY); @@ -107,10 +105,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, f2fs_init_extent_tree(inode, NULL); - stat_inc_inline_xattr(inode); - stat_inc_inline_inode(inode); - stat_inc_inline_dir(inode); - F2FS_I(inode)->i_flags = f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED); @@ -127,6 +121,14 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, set_compress_context(inode); } + /* Should enable inline_data after compression set */ + if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode)) + set_inode_flag(inode, FI_INLINE_DATA); + + stat_inc_inline_xattr(inode); + stat_inc_inline_inode(inode); + stat_inc_inline_dir(inode); + f2fs_set_inode_flags(inode); trace_f2fs_new_inode(inode, 0); @@ -325,6 +327,8 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, if (!is_extension_exist(name, ext[i], false)) continue; + /* Do not use inline_data with compression */ + clear_inode_flag(inode, FI_INLINE_DATA); set_compress_context(inode); return; } -- 2.36.1.476.g0c4daa206d-goog