Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2839486rdb; Tue, 12 Sep 2023 13:52:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4c+vYbtZ2UfkSmNi/L/5lN4x9CeCWhmK/L0Q5A0MhbvjjYHGKs1IFxr3AslqjAGTSVMdn X-Received: by 2002:a05:6a20:f3a0:b0:153:24c2:c93b with SMTP id qr32-20020a056a20f3a000b0015324c2c93bmr578118pzb.1.1694551934863; Tue, 12 Sep 2023 13:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694551934; cv=none; d=google.com; s=arc-20160816; b=Y97qoHzH0jjUJf1zxAb/OIgOcMVfqBj6AYH80vGlTNCqJh5THwCdTiiDnpr8NMP0/1 l11YWkuYMTL852g+wApLez+SUWZPHD+kpBJWAlCCe6rLC2uhonAE4ESXSbQuN4FFP9Xr 5ldFWNVILVrayTC4Rh1OeMwqir7Kolo+hsiXNhwVFtYfabqUxco+0x9OmpY8Ks81sLLS KAjnj9C1Cox85JYM39o7FtaPJFRFkUMiQTeKSkHzz/99+f4CNmXGzlFd999L69t2ua4m Xc6v6mbgI37wSd7YWkAThvtLWyxlC83sb0nPClthhcUQfsDsqWowUp/VGV6b89sbT8OW IXAg== 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=/4+DlByDh920r1YDdLeT0aMwBKpfhn5wCDMvPBKPJ0U=; fh=XyknH2dKxXaYureS1ob7B/HoELHeQyucGl57UvCGnrw=; b=cRkd4deAnRKiEgKGyhka669VnhIyCdOH0zRgOUz22qQJGG4jsevw/WTjlX6QbSJTfg ObsoDvvi90ptjPdm9aVyE1JTXTApWBdKiskZT1nBR+xvQY7PnlO6j8LBzlcUKXyY5nwr snDlkvqlFBKIQ5l4w9t7FKSRyTKQ2ToUIeaWBAFDGp3H5Tupi/eVlL0PQ/qLyRrUx22p aVBKGieSjq4DFWYgYT2cFcla+xbzuw5s4GVlraHxuv2ctn67hSiVnsMu0Zc7TOjDSoWw XGtKTjIL239Sulju8yVy39PV/8EtJZlz/A67WwpoIgn7FGSY+Du5GfmT+TcUP6eqQIJV yFLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IvTGrqTj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id q66-20020a17090a17c800b002742f8fd989si43177pja.177.2023.09.12.13.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 13:52:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IvTGrqTj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id F2F14801B887; Tue, 12 Sep 2023 13:50:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjILUuV (ORCPT + 99 others); Tue, 12 Sep 2023 16:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjILUuV (ORCPT ); Tue, 12 Sep 2023 16:50:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58588199; Tue, 12 Sep 2023 13:50:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE7B6C433C8; Tue, 12 Sep 2023 20:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694551817; bh=x7nnTrA5RCHsYOnVqf+Mil/a7Ta+GR6SCAIeYqHvIbc=; h=From:To:Cc:Subject:Date:From; b=IvTGrqTjYpc66HYNpyca1dKQTqvON4oy3Y5oI1mOmwt4kzgpneZ92CxUSpvK68qBJ MgupqzBA/1myQM61eLotXPDMMGlno4OoCZm8uVuANMaP7K/E4gYekyVe7ljJs/bUw/ DNpxVP9/6T+TE/PxrAtUjH3Mf1ugRH1XcoH6Zap+JQwdCnEqjHJQc/kDYszntCOqJ9 2PXGfpwDsCvHAmDWZZV5vzfv9WmAH7IEdkKhLWwuytX0Z+gSrY+OgOTFStNy87Mkce AFOV0AFeScKfpB6eDCkZPpTYbJRZ1BoYtCF5mPdt1GcxjvPi4mRKSb0fmf36gIKZT0 4mdj6cBp88Y9Q== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , stable@vger.kernel.org Subject: [PATCH] f2fs: set the default compress_level on ioctl Date: Tue, 12 Sep 2023 13:50:15 -0700 Message-ID: <20230912205015.2582133-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Sep 2023 13:50:23 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Otherwise, we'll get a broken inode. # touch $FILE # f2fs_io setflags compression $FILE # f2fs_io set_coption 2 8 $FILE [ 112.227612] F2FS-fs (dm-51): sanity_check_compress_inode: inode (ino=8d3fe) has unsupported compress level: 0, run fsck to fix Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim --- fs/f2fs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index ca5904129b16..09716127e107 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4005,6 +4005,15 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) F2FS_I(inode)->i_compress_algorithm = option.algorithm; F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size; F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size); + /* Set default level */ + if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_ZSTD) + F2FS_I(inode)->i_compress_level = F2FS_ZSTD_DEFAULT_CLEVEL; + else + F2FS_I(inode)->i_compress_level = 0; + /* Adjust mount option level */ + if (option.algorithm == F2FS_OPTION(sbi).compress_algorithm && + F2FS_OPTION(sbi).compress_level) + F2FS_I(inode)->i_compress_level = F2FS_OPTION(sbi).compress_level; f2fs_mark_inode_dirty_sync(inode, true); if (!f2fs_is_compress_backend_ready(inode)) -- 2.42.0.283.g2d96d420d3-goog