From: "Sungjong Seo" <sj1557.seo@samsung.com>
To: <Yuezhang.Mo@sony.com>, <linkinjeon@kernel.org>
Cc: <linux-fsdevel@vger.kernel.org>, <Andy.Wu@sony.com>,
<Wataru.Aoyama@sony.com>
Subject: RE: [PATCH v2 02/10] exfat: add exfat_get_empty_dentry_set() helper
Date: Thu, 7 Mar 2024 20:07:07 +0900 [thread overview]
Message-ID: <664457955.21709855702359.JavaMail.epsvc@epcpadp3> (raw)
In-Reply-To: <PUZPR04MB631617947452ADC288E8FD9281232@PUZPR04MB6316.apcprd04.prod.outlook.com>
> Wataru.Aoyama@sony.com
> Subject: RE: [PATCH v2 02/10] exfat: add exfat_get_empty_dentry_set()
> helper
>
> > From: Sungjong Seo <sj1557.seo@samsung.com>
> > Sent: Monday, March 4, 2024 4:43 PM
> > To: Mo, Yuezhang <Yuezhang.Mo@sony.com>; linkinjeon@kernel.org
> >
> > >
> > > The following code still exists if without this patch set. It does
> > > not allow deleted dentries to follow unused dentries.
> >
> > It may be the same part as the code you mentioned, but remember that
> > the first if-statement handles both an unused dentry and a deleted
> > dentry together.
>
> Thanks for your detailed explanation.
>
> I will update the code as follows, and I think it is very necessary to add
> such comments.
I think so :)
>
> for (i = 0; i < es->num_entries; i++) {
> ep = exfat_get_dentry_cached(es, i);
> if (ep->type == EXFAT_UNUSED)
> unused_hit = true;
> else if (IS_EXFAT_DELETED(ep->type)) {
> /*
> * Although it violates the specification for a
> * deleted entry to follow an unused entry, some
> * exFAT implementations could work like this.
> * Therefore, to improve compatibility, allow it.
> */
> if (unused_hit)
However, I don't think it's good idea to check for unused_hit here.
How about moving the comment at the start of the for-loop and changing
the code as follows?
/*
* ONLY UNUSED OR DELETED DENTRIES ARE ALLOWED:
* Although it violates the specification for a deleted entry to
* follow an unused entry, some exFAT implementations could work
* like this. Therefore, to improve compatibility, let's allow it.
*/
for (i = 0; i < es->num_entries; i++) {
ep = exfat_get_dentry_cached(es, i);
if (ep->type == EXFAT_UNUSED) {
unused_hit = true;
continue;
}
if (IS_EXFAT_DELETED(ep->type))
continue;
if (unused_hit)
goto err_used_follow_unused;
i++;
goto count_skip_entries;
}
Or we could use if / else-if as follows.
for (i = 0; i < es->num_entries; i++) {
ep = exfat_get_dentry_cached(es, i);
if (ep->type == EXFAT_UNUSED) {
unused_hit = true;
} else if (!IS_EXFAT_DELETED(ep->type)) {
if (unused_hit)
goto err_used_follow_unused;
i++;
goto count_skip_entries;
}
}
> continue;
> } else {
> /* Used entry are not allowed to follow unused
entry */
> if (unused_hit)
> goto err_used_follow_unused;
>
> i++;
> goto count_skip_entries;
> }
> }
next prev parent reply other threads:[~2024-03-07 23:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20231228065938epcas1p3112d227f22639ca54849441146d9bdbf@epcms1p1>
2024-03-04 4:43 ` [PATCH v2 02/10] exfat: add exfat_get_empty_dentry_set() helper 서성종
2024-03-04 7:29 ` Yuezhang.Mo
2024-03-04 8:42 ` Sungjong Seo
2024-03-04 11:37 ` Yuezhang.Mo
2024-03-07 11:07 ` Sungjong Seo [this message]
[not found] <CGME20231228065938epcas1p3112d227f22639ca54849441146d9bdbf@epcas1p3.samsung.com>
2023-12-28 6:59 ` Yuezhang.Mo
2024-02-29 6:18 ` Sungjong Seo
2024-02-29 9:37 ` Yuezhang.Mo
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=664457955.21709855702359.JavaMail.epsvc@epcpadp3 \
--to=sj1557.seo@samsung.com \
--cc=Andy.Wu@sony.com \
--cc=Wataru.Aoyama@sony.com \
--cc=Yuezhang.Mo@sony.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).