From: Hongzhen Luo <hongzhen@linux.alibaba.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>, linux-erofs@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] erofs: use Z_EROFS_LCLUSTER_TYPE_MAX to simplify switches
Date: Mon, 10 Feb 2025 11:08:54 +0800 [thread overview]
Message-ID: <1cbdb820-22e6-4cef-8f60-60799e674499@linux.alibaba.com> (raw)
In-Reply-To: <5c55806f-56b2-4e00-8b88-ac97e5733b57@linux.alibaba.com>
On 2025/2/10 10:59, Gao Xiang wrote:
>
>
> On 2025/2/7 17:14, Gao Xiang wrote:
>>
>>
>> On 2025/2/7 16:50, Hongzhen Luo wrote:
>>> There's no need to enumerate each type. No logic changes.
>>>
>>> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
>>> ---> v3: Code cleanup, remove logically inequivalent changes.
>>> v2:
>>> https://lore.kernel.org/all/20250207080829.2405528-1-hongzhen@linux.alibaba.com/
>>> v1:
>>> https://lore.kernel.org/all/20250207064135.2249529-1-hongzhen@linux.alibaba.com/
>>> ---
>>> fs/erofs/zmap.c | 60
>>> +++++++++++++++++++------------------------------
>>> 1 file changed, 23 insertions(+), 37 deletions(-)
>>>
>>> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
>>> index 689437e99a5a..7dba1573498b 100644
>>> --- a/fs/erofs/zmap.c
>>> +++ b/fs/erofs/zmap.c
>>> @@ -265,23 +265,20 @@ static int z_erofs_extent_lookback(struct
>>> z_erofs_maprecorder *m,
>>> if (err)
>>> return err;
>>> - switch (m->type) {
>>> - case Z_EROFS_LCLUSTER_TYPE_NONHEAD:
>>> + if (m->type >= Z_EROFS_LCLUSTER_TYPE_MAX) {
>>> + erofs_err(sb, "unknown type %u @ lcn %lu of nid %llu",
>>> + m->type, lcn, vi->nid);
>>> + DBG_BUGON(1);
>>> + return -EOPNOTSUPP;
>>> + } else if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
>>> lookback_distance = m->delta[0];
>>> if (!lookback_distance)
>>> goto err_bogus;'
>>
>> Maybe just kill `goto err_bogus;` too, like:
>> if (!lookback_distance) {
>> erofs_err(sb, "bogus lookback
>> distance %u @ lcn %lu of nid %llu",
>> lookback_distance, m->lcn,
>> vi->nid);
>> DBG_BUGON(1);
>> return -EFSCORRUPTED;
>> }
>>
>> Otherwise it looks good to me.
>
> Sorry, I was wrong. I was missing the part of the end of
> function, how about the following diff?
>
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index 7dba1573498b..d278ebd60281 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -273,7 +273,7 @@ static int z_erofs_extent_lookback(struct
> z_erofs_maprecorder *m,
> } else if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
> lookback_distance = m->delta[0];
> if (!lookback_distance)
> - goto err_bogus;
> + break;
> continue;
> } else {
> m->headtype = m->type;
> @@ -281,7 +281,6 @@ static int z_erofs_extent_lookback(struct
> z_erofs_maprecorder *m,
> return 0;
> }
> }
> -err_bogus:
> erofs_err(sb, "bogus lookback distance %u @ lcn %lu of nid %llu",
> lookback_distance, m->lcn, vi->nid);
> DBG_BUGON(1);
>
> Thanks,
> Gao Xiang
Sure, I will send an updated version later.
Thanks,
Hongzhen Luo
prev parent reply other threads:[~2025-02-10 3:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 8:50 Hongzhen Luo
2025-02-07 9:14 ` Gao Xiang
2025-02-07 9:16 ` Hongzhen Luo
2025-02-10 2:59 ` Gao Xiang
2025-02-10 3:08 ` Hongzhen Luo [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=1cbdb820-22e6-4cef-8f60-60799e674499@linux.alibaba.com \
--to=hongzhen@linux.alibaba.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
/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®