From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46B89390DB3 for ; Wed, 17 Dec 2025 14:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765980300; cv=none; b=MoOtEDyLlAHe9LB0hWYIQWKG+8OnZbINUHzDKJH/Ja3nY5+ohW40o0n+mg8HPHtmnxmmBtHbTPV3fDH4MkrcRIsqK8U5pJ0WyWJ4181X2JrkgTTo3kyRwadCUjnF5QKzBffV6D39uh3QJp5ViKEj4RROebyw4X47tbXLhwbpsDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765980300; c=relaxed/simple; bh=Cgww5jKwdjSA3DT01yC112/QKeTALclgCMAcZLV3xNU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kf0NwO72ZNgyCv0mSwPHcXj3YgIy3WUUbwaMA31DRwhogHc/jaBqeBVlVvV1OQb14NIThcgIIQN1XIfigKKYnlSledb4tUZqz8IX4Kb+ih8laR6xtzbbS2mjH95VertLs1bSqfnqvXntLo7eJbb179dP8dwaZwhofFiLU2Nm7HU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=JVxYOnZr; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="JVxYOnZr" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765980289; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=T6SwEIqztnyl+AbhHyM6QAKi6+dvGvAiz1+AXpvlqAM=; b=JVxYOnZrM8I4H1BlXvF3zJqp4fV/LKO/zlDwGzSCXRN7BrcZztPbB642Yc39P2Wwge1+ycV+e0u2/oJRm8SIU7Q54aKFECTfBVjjSKjgYq1PZWe2u8gdWsTkX3aDcVQibGZinwjUCz8HihVY5sriyNUF4uxAgj2m/xlLL/RLWwc= Received: from 30.69.38.206(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Wv3qKoV_1765980279 cluster:ay36) by smtp.aliyun-inc.com; Wed, 17 Dec 2025 22:04:48 +0800 Message-ID: <09fdc2e3-c0ce-4c2a-8dd9-dad82e642b40@linux.alibaba.com> Date: Wed, 17 Dec 2025 22:04:38 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs: simplify the code using for_each_set_bit To: Yuwen Chen , xiang@kernel.org Cc: chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: From: Gao Xiang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > --- > 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;