linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Yangtao Li <frank.li@vivo.com>, linux-f2fs-devel@lists.sourceforge.net
Cc: jaegeuk@kernel.org, terrelln@fb.com, linux-kernel@vger.kernel.org
Subject: Re: [f2fs-dev] [RESEND] f2fs: add sanity compress level check for compressed file
Date: Tue, 4 Apr 2023 09:16:30 +0800	[thread overview]
Message-ID: <5b766d0c-fae7-885a-0dc9-a16d90540260@kernel.org> (raw)
In-Reply-To: <20230403133359.6649-1-frank.li@vivo.com>

On 2023/4/3 21:33, Yangtao Li wrote:
> 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:

Hi Yangtao,

How about:

#ifdef CONFIG_F2FS_FS_ZSTD
	if (!compress_level || compress_level > zstd_max_clevel())
		goto err;
#endif
	break;

>                  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


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

      reply	other threads:[~2023-04-04  1:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 16:28 [f2fs-dev] [RESEND] f2fs: add sanity compress level check for compressed file Yangtao Li via Linux-f2fs-devel
2023-04-03  3:46 ` Chao Yu
2023-04-03 13:01   ` Chao Yu
2023-04-03 13:33 ` Yangtao Li via Linux-f2fs-devel
2023-04-04  1:16   ` Chao Yu [this message]

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=5b766d0c-fae7-885a-0dc9-a16d90540260@kernel.org \
    --to=chao@kernel.org \
    --cc=frank.li@vivo.com \
    --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;
as well as URLs for NNTP newsgroup(s).