mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>,
	Namjae Jeon <linkinjeon@kernel.org>,
	Sungjong Seo <sj1557.seo@samsung.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chi Zhiling <chizhiling@kylinos.cn>,
	"syzbot@syzkaller.appspotmail.com"
	<syzbot@syzkaller.appspotmail.com>
Subject: Re: [PATCH v2 5/6] exfat: introduce exfat_chain_advance helper
Date: Fri, 3 Apr 2026 12:28:45 +0800	[thread overview]
Message-ID: <df79035d-7cea-462e-9003-2236e66e0b52@163.com> (raw)
In-Reply-To: <PUZPR04MB6316FA116436AAB12EA72F18815EA@PUZPR04MB6316.apcprd04.prod.outlook.com>

On 4/3/26 11:33 AM, Yuezhang.Mo@sony.com wrote:
>> On 4/3/26 10:34 AM, Yuezhang.Mo@sony.com wrote:
>>>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>>>
>>>> Introduce exfat_chain_advance() to walk a exfat_chain structure by a
>>>> given step, updating both ->dir and ->size fields atomically. This
>>>> helper handles both ALLOC_NO_FAT_CHAIN and ALLOC_FAT_CHAIN modes with
>>>> proper boundary checking.
>>>>
>>>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>>>> Tested-by: syzbot@syzkaller.appspotmail.com
>>>>
>>>> ---
>>>> fs/exfat/exfat_fs.h | 17 +++++++++++++++++
>>>>    1 file changed, 17 insertions(+)
>>>>
>>>> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
>>>> index 530459ab9acc..1035d20ba563 100644
>>>> --- a/fs/exfat/exfat_fs.h
>>>> +++ b/fs/exfat/exfat_fs.h
>>>> @@ -552,6 +552,23 @@ int exfat_read_volume_label(struct super_block *sb,
>>>> int exfat_write_volume_label(struct super_block *sb,
>>>>                                struct exfat_uni_name *label);
>>>>
>>>> +static inline int exfat_chain_advance(struct super_block *sb,
>>>> +               struct exfat_chain *chain, unsigned int step)
>>>> +{
>>>> +       if (chain->size >= step)
>>>> +               chain->size -= step;
>>>
>>> It would be better to not change *chain if return an error.
>>
>> Okay,
>>
>> v3:
>>
>> static inline int exfat_chain_advance(struct super_block *sb,
>>                   struct exfat_chain *chain, unsigned int step)
>> {
>>           if (chain->size < step)
>>                   return -EIO;
>>
>>           chain->size -= step;
>>
>>           if (exfat_fat_walk(sb, &chain->dir, step, chain->flags))
>>                   return -EIO;
>>
>>           if (chain->size == 0 && chain->flags == ALLOC_NO_FAT_CHAIN)
>>                   chain->dir = EXFAT_EOF_CLUSTER;
>>
>>           return 0;
>> }
>>
> 
> chain->dir should also not be changed.
> 
> static inline int exfat_chain_advance(struct super_block *sb,
>                   struct exfat_chain *chain, unsigned int step)
> {
>           unsigned int clu = chain->dir;
> 
>           if (chain->size < step)
>                   return -EIO;
> 
>           if (exfat_fat_walk(sb, &clu, step, chain->flags))
>                   return -EIO;
> 
>           chain->size -= step;
> 
>           if (chain->size == 0 && chain->flags == ALLOC_NO_FAT_CHAIN)
>                   chain->dir = EXFAT_EOF_CLUSTER;
>           else
>                   chain->dir = clu;
> 
>           return 0;
> }

Alright, I got it, this is great.

I’ll update it in v3.


Thanks,

> 
>>
>> Thanks,
>>>
>>>> +       else
>>>> +               return -EIO;
>>>> +
>>>> +       if (exfat_fat_walk(sb, &chain->dir, step, chain->flags))
>>>> +               return -EIO;
>>>> +
>>>> +       if (chain->size == 0 && chain->flags == ALLOC_NO_FAT_CHAIN)
>>>> +               chain->dir = EXFAT_EOF_CLUSTER;
>>>> +
>>>> +       return 0;
>>>> +}
>>>> +
>>>>    /* inode.c */
>>>>    extern const struct inode_operations exfat_file_inode_operations;
>>>>    void exfat_sync_inode(struct inode *inode);
>>>> --
>>>> 2.43.0
>>>
>>>


  reply	other threads:[~2026-04-03  4:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  7:11 [PATCH v2 0/6] exfat: unify FAT chain walking helpers Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 1/6] exfat: fix incorrect directory checksum after rename to shorter name Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 2/6] exfat: introduce exfat_fat_walk helper Chi Zhiling
2026-04-03  2:34   ` Yuezhang.Mo
2026-04-03  2:44     ` Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 3/6] exfat: use exfat_fat_walk helper to simplify fat entry walking Chi Zhiling
2026-04-02 14:22   ` Sungjong Seo
2026-04-03  2:43     ` Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 4/6] exfat: remove NULL cache pointer case in exfat_ent_get Chi Zhiling
2026-04-01  7:11 ` [PATCH v2 5/6] exfat: introduce exfat_chain_advance helper Chi Zhiling
2026-04-03  2:34   ` Yuezhang.Mo
2026-04-03  2:47     ` Chi Zhiling
2026-04-03  3:33       ` Yuezhang.Mo
2026-04-03  4:28         ` Chi Zhiling [this message]
2026-04-01  7:11 ` [PATCH v2 6/6] exfat: use " Chi Zhiling

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=df79035d-7cea-462e-9003-2236e66e0b52@163.com \
    --to=chizhiling@163.com \
    --cc=Yuezhang.Mo@sony.com \
    --cc=chizhiling@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=syzbot@syzkaller.appspotmail.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®