Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3529963iog; Tue, 21 Jun 2022 00:02:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sl1jZgU2yD56leQ95QlFjoPZSZcEcNi677PiP4utDB4dHM9c4on5zEczsvgExMxWTVxeaV X-Received: by 2002:a17:906:194b:b0:710:967d:ba18 with SMTP id b11-20020a170906194b00b00710967dba18mr23847247eje.705.1655794943068; Tue, 21 Jun 2022 00:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655794943; cv=none; d=google.com; s=arc-20160816; b=SLsFvrGG9A98bxsB0Zu+uVfgmgcFIRA/DLrw/nW5a6ijdnyzurUGHNknjjlR22RAWJ qmvDbKcBkhuFBMrDrr99tJ57PD5Xd0hjOG0L2G83jLM2jrQ0W8a2UKzVWhHNHUI7aNHf N5L0fD0JvwANglew5UpbyKwZiUsaUyQQ3HSdw/LB2CveY27Exm8AG7pFSn0Db9w0+x/s FFs3FZ4LOLRRAYzOZb43mJ7zTQa+JZP7RfaH5l/dAecraQBykLMCOExxN4IPnCPata14 HvWlYeNqbrxa7rSU0qyrPS9C/suDMTxdHU/m7NKozBiJEdhurO9LBG5htwsRYUq2nBuZ hiSQ== 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=lrtTaXmDH4j2G9DmDgYy3Hx6WoOoJlaM6bssxvYmN/s=; b=PD5bX+CaVR/RxYqNhczWPIg+BJUs8CAI77cRU6OwwiNpUj8Qtn0hGL6l6zQAbf+1rN +Co5uJw8aaacuMVFDr9zOjs2IrFw5GwMxTk6FZwLQtVf7ERWjoOdEe8Svd10QL667ZOG t1SHyxw6QKQlcdJdWn40eq5bnjXbBo5yEuPeGWlcePe2qFvEEye5SAFXm3v+nOq880jP Kad0zrytW2wnBnF2MQJKHTIejovEMETfKTdSjwssJ6/rGcdAhuBJc4rCzo6vODO4J1Fp qR78GWcphpj/Zg5UCR3DO2nyYw+EHaAnIpZN1aquU1+92JTUcth4QLaSKrWO9NQa+e5h gtaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="U/6RCn5/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js15-20020a17090797cf00b006fea0e9ba89si17577507ejc.743.2022.06.21.00.01.58; Tue, 21 Jun 2022 00:02:23 -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=@gmail.com header.s=20210112 header.b="U/6RCn5/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346270AbiFUGzs (ORCPT + 99 others); Tue, 21 Jun 2022 02:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbiFUGzq (ORCPT ); Tue, 21 Jun 2022 02:55:46 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7DDF1CFCF for ; Mon, 20 Jun 2022 23:55:45 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id y13-20020a17090a154d00b001eaaa3b9b8dso12416855pja.2 for ; Mon, 20 Jun 2022 23:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lrtTaXmDH4j2G9DmDgYy3Hx6WoOoJlaM6bssxvYmN/s=; b=U/6RCn5/rnlCWPEvZmw/CvlDBd7e7AuS8iDEETwq+hrEH+sdjwYLrsXxea6i48NMrs Us2vRiB6BQRD8MOtGP7RS1KLIB0GU00JbD87+Fsk0BkmrLxxQE2R+0IGo6HfLaVl+15w W7ol69OS3VwQEgHJMGDwVjZQRkVm0tr6EuTz/OKifAyh1KsRlHB5EOEZ0GEz8LnAvNws u2fDrLpN2sOA/dvHcR7+7241kVt3vpHpYnIGGxKY3rJrpYM7iVwImg6BZfwrAxtSnM9m YBqRn5/b8rdrdidYVsr2xvfc/2grb8CTwV39h0O3LDATqjVDB6UMoNNWTgVTSM1Pc48v 5Zpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lrtTaXmDH4j2G9DmDgYy3Hx6WoOoJlaM6bssxvYmN/s=; b=iDljhzexXEtWWzpkOOGRbmp8t05jSLmPeuUyLAht7MOCR4uoYlSfekY3tje/EK8A/2 aUuQBdG8vCZuN/HcR/Ip3tgFApxRMRguKlTFP2mhAjIYHEkRPIwhB7swt+aNE11K1FsA fjznlzVQZU1rjDVb4rNBO0SiPx64avOFGZFwWZnZSCakJgMW4b8MWbpeYPwptUqbTYtP CN0219dJKWFFSghS7JTDxvVpzI4jhndP//bTTz+uSLpBJ3lBW4rGMGWnO9U3RWbG3mS+ 1Bc1a4OTR7NxN2N/gjGuAlCmPXhL25QDx9fG99Fh5jEtMN/j+eNN1iBDUsXDTlA9R37Q m7zg== X-Gm-Message-State: AJIora86ck8K4qKLUKBV6U3x+aGBHrV4wtgvEsjTCwhJg5EUUNNm1dQS CaZzUD3i/RTWXAOJtZTJNBqZEpVoRFyRGKP+ X-Received: by 2002:a17:902:d2d0:b0:168:b0b2:f068 with SMTP id n16-20020a170902d2d000b00168b0b2f068mr26766089plc.45.1655794545155; Mon, 20 Jun 2022 23:55:45 -0700 (PDT) Received: from localhost.localdomain ([156.236.96.165]) by smtp.gmail.com with ESMTPSA id x10-20020a1709028eca00b0016368840c41sm8230471plo.14.2022.06.20.23.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 23:55:43 -0700 (PDT) From: Chao Liu To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yue Hu , Wayne Zhang , Xiaoyu Qi , Chao Liu Subject: [PATCH] f2fs: fix to remove F2FS_COMPR_FL and tag F2FS_NOCOMP_FL at the same time Date: Tue, 21 Jun 2022 14:48:33 +0800 Message-Id: <20220621064833.1079383-1-chaoliu719@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 From: Chao Liu If the inode has the compress flag, it will fail to use 'chattr -c +m' to remove its compress flag and tag no compress flag. However, the same command will be successful when executed again, as shown below: $ touch foo.txt $ chattr +c foo.txt $ chattr -c +m foo.txt chattr: Invalid argument while setting flags on foo.txt $ chattr -c +m foo.txt $ f2fs_io getflags foo.txt get a flag on foo.txt ret=0, flags=nocompression,inline_data Fix this by removing some checks in f2fs_setflags_common() that do not affect the original logic. I go through all the possible scenarios, and the results are as follows. Bold is the only thing that has changed. +---------------+-----------+-----------+----------+ | | file flags | + command +-----------+-----------+----------+ | | no flag | compr | nocompr | +---------------+-----------+-----------+----------+ | chattr +c | compr | compr | -EINVAL | | chattr -c | no flag | no flag | nocompr | | chattr +m | nocompr | -EINVAL | nocompr | | chattr -m | no flag | compr | no flag | | chattr +c +m | -EINVAL | -EINVAL | -EINVAL | | chattr +c -m | compr | compr | compr | | chattr -c +m | nocompr | *nocompr* | nocompr | | chattr -c -m | no flag | no flag | no flag | +---------------+-----------+-----------+----------+ Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Chao Liu --- This patch depends on the the patch "f2fs: allow compression of files without blocks" sent earlier this day. fs/f2fs/file.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index daaa0dfd2d2e..0c3ae5993b7a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1873,10 +1873,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) if (masked_flags & F2FS_COMPR_FL) { if (!f2fs_disable_compressed_file(inode)) return -EINVAL; - } - if (iflags & F2FS_NOCOMP_FL) - return -EINVAL; - if (iflags & F2FS_COMPR_FL) { + } else { if (!f2fs_may_compress(inode)) return -EINVAL; if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode)) @@ -1885,10 +1882,6 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) set_compress_context(inode); } } - if ((iflags ^ masked_flags) & F2FS_NOCOMP_FL) { - if (masked_flags & F2FS_COMPR_FL) - return -EINVAL; - } fi->i_flags = iflags | (fi->i_flags & ~mask); f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) && -- 2.36.1