From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Yuwen Chen <ywen.chen@foxmail.com>, xiang@kernel.org
Cc: chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com,
linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] erofs: simplify the code using for_each_set_bit
Date: Wed, 17 Dec 2025 22:04:38 +0800 [thread overview]
Message-ID: <09fdc2e3-c0ce-4c2a-8dd9-dad82e642b40@linux.alibaba.com> (raw)
In-Reply-To: <tencent_CB6FE08BB14BB368855B6D7CC515EDFC2C05@qq.com>
Hi Yuwen,
On 2025/12/17 17:09, Yuwen Chen wrote:
> When mounting the EROFS file system, it is necessary to check the
> available compression algorithms. At this time, the for_each_set_bit
> function can be used to simplify the code logic.
Anyway, I'm fine to simplify a bit.
>
> Signed-off-by: Yuwen Chen <ywen.chen@foxmail.com>
> ---
> fs/erofs/decompressor.c | 10 +++-------
> fs/erofs/internal.h | 2 +-
> 2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index 2ec9b2bb628d6..93e7ae2e363ff 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -405,7 +405,7 @@ int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb)
> {
> struct erofs_sb_info *sbi = EROFS_SB(sb);
> struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
> - unsigned int algs, alg;
> + unsigned int alg;
unsigned long algs, alg;
> erofs_off_t offset;
> int size, ret = 0;
>
> @@ -416,20 +416,16 @@ int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb)
>
> sbi->available_compr_algs = le16_to_cpu(dsb->u1.available_compr_algs);
algs = le16_to_cpu(dsb->u1.available_compr_algs);
sbi->available_compr_algs = algs;
if (algs & ~Z_EROFS_ALL_COMPR_ALGS) {
erofs_err(sb, "unidentified algorithms %lx, please upgrade kernel",
algs & ~Z_EROFS_ALL_COMPR_ALGS);
return -EOPNOTSUPP;
}
> if (sbi->available_compr_algs & ~Z_EROFS_ALL_COMPR_ALGS) {
> - erofs_err(sb, "unidentified algorithms %x, please upgrade kernel",
> + erofs_err(sb, "unidentified algorithms %lx, please upgrade kernel",
> sbi->available_compr_algs & ~Z_EROFS_ALL_COMPR_ALGS);
> return -EOPNOTSUPP;
> }
>
> erofs_init_metabuf(&buf, sb);
> offset = EROFS_SUPER_OFFSET + sbi->sb_size;
> - alg = 0;
> - for (algs = sbi->available_compr_algs; algs; algs >>= 1, ++alg) {
> + for_each_set_bit(alg, &sbi->available_compr_algs, Z_EROFS_COMPRESSION_MAX) {
for_each_set_bit(alg, &algs, Z_EROFS_COMPRESSION_MAX) {
> void *data;
>
> - if (!(algs & 1))
> - continue;
> -
> data = erofs_read_metadata(sb, &buf, &offset, &size);
> if (IS_ERR(data)) {
> ret = PTR_ERR(data);
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index c69174675caf7..c34cfcdf1e401 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -126,7 +126,7 @@ struct erofs_sb_info {
> struct xarray managed_pslots;
>
> unsigned int shrinker_run_no;
> - u16 available_compr_algs;
> + unsigned long available_compr_algs;
No need to change this line.
Thanks,
Gao Xiang
>
> /* pseudo inode to manage cached pages */
> struct inode *managed_cache;
prev parent reply other threads:[~2025-12-17 14:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 9:09 Yuwen Chen
2025-12-17 14:04 ` Gao Xiang [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=09fdc2e3-c0ce-4c2a-8dd9-dad82e642b40@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=huyue2@coolpad.com \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=ywen.chen@foxmail.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®