mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yangtao Li <frank.li@vivo.com>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: chao@kernel.org, frank.li@vivo.com, jaegeuk@kernel.org,
	linux-kernel@vger.kernel.org, terrelln@fb.com
Subject: Re: [RESEND] f2fs: add sanity compress level check for compressed file
Date: Mon,  3 Apr 2023 21:33:59 +0800	[thread overview]
Message-ID: <20230403133359.6649-1-frank.li@vivo.com> (raw)
In-Reply-To: <20230330162811.18923-1-frank.li@vivo.com>

Hi Chao,

> Why not zstd_max_clevel()?

zstd_max_clevel() is only defined when CONFIG_F2FS_FS_ZSTD is enabled,
using zstd_max_clevel() will result in compile errors otherwise.

If using the following code,

----------------------------------------------------------------------------
        switch (ri->i_compress_algorithm) {
        case COMPRESS_LZO:
        case COMPRESS_LZORLE:
                if (compress_level)
                        goto err;
                break;
        case COMPRESS_LZ4:
                if ((compress_level && compress_level < LZ4HC_MIN_CLEVEL) ||
                                compress_level > LZ4HC_MAX_CLEVEL)
                        goto err;
                break;
#ifdef CONFIG_F2FS_FS_ZSTD
        case COMPRESS_ZSTD:
                if (!compress_level || compress_level > zstd_max_clevel())
                        goto err;
                break;
#endif
        default:
                goto err;
        }
----------------------------------------------------------------------------

then we will get this result:

	F2FS-fs (loop0): sanity_check_compress_inode: inode (ino=4) has
			unsupported compress level: 0, run fsck to fix

Another way is to use the following code, which ignores the check for
level when CONFIG_F2FS_FS_ZSTD is not enabled.

----------------------------------------------------------------------------
        switch (ri->i_compress_algorithm) {
        case COMPRESS_LZO:
        case COMPRESS_LZORLE:
                if (compress_level)
                        goto err;
                break;
        case COMPRESS_LZ4:
                if ((compress_level && compress_level < LZ4HC_MIN_CLEVEL) ||
                                compress_level > LZ4HC_MAX_CLEVEL)
                        goto err;
                break;
        case COMPRESS_ZSTD:
#ifdef CONFIG_F2FS_FS_ZSTD
                if (!compress_level || compress_level > zstd_max_clevel())
                        goto err;
                break;
#else
                return true;
#endif
        default:
                goto err;
        }
----------------------------------------------------------------------------

Perhaps exporting ZSTD_MAX_CLEVEL is a better choice?

Thx,
Yangtao

  parent reply	other threads:[~2023-04-03 13:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 16:28 Yangtao Li
2023-04-03  3:46 ` Chao Yu
2023-04-03 13:01   ` [f2fs-dev] " Chao Yu
2023-04-03 13:33 ` Yangtao Li [this message]
2023-04-04  1:16   ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230403133359.6649-1-frank.li@vivo.com \
    --to=frank.li@vivo.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=terrelln@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®