From: Chi Zhiling <chizhiling@163.com>
To: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>
Cc: "brauner@kernel.org" <brauner@kernel.org>,
"chizhiling@kylinos.cn" <chizhiling@kylinos.cn>,
"jack@suse.cz" <jack@suse.cz>,
"linkinjeon@kernel.org" <linkinjeon@kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"sj1557.seo@samsung.com" <sj1557.seo@samsung.com>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"willy@infradead.org" <willy@infradead.org>
Subject: Re: [PATCH v1 3/9] exfat: reuse cache to improve exfat_get_cluster
Date: Mon, 5 Jan 2026 11:07:15 +0800 [thread overview]
Message-ID: <53c38e14-13bb-4857-85cf-221408669475@163.com> (raw)
In-Reply-To: <PUZPR04MB6316842140CBEDFC8E30CDE081B9A@PUZPR04MB6316.apcprd04.prod.outlook.com>
On 1/4/26 15:56, Yuezhang.Mo@sony.com wrote:
>> On 12/30/25 17:05, Yuezhang.Mo@sony.com wrote:
>>>> - if (exfat_ent_get(sb, *dclus, &content, NULL))
>>>> - return -EIO;
>>>> + if (exfat_ent_get(sb, *dclus, &content, &bh))
>>>> + goto err;
>>>
>>> As you commented, the buffer_head needs release if no error return.
>>> Here, an error was returned, buffer_head had been released.
>>
>>
>> I mean, it seems like a duplicate release in there, but in fact it's not.
>>
>> When exfat_ent_get return an error, *bh is released and set to NULL. So
>> the second brelse() call in exfat_get_cluster() does nothing.
>>
>> ~~~
>> int exfat_ent_get(struct super_block *sb, unsigned int loc,
>> unsigned int *content, struct buffer_head **last)
>> {
>>
>> ...
>>
>> err:
>> if (last) {
>> brelse(*last);
>>
>> /* Avoid double release */
>> *last = NULL;
>> }
>> return -EIO;
>> }
>> ~~~
>>
>> The reason using "goto err" is that I want to handle all errors in the
>> same way. Although this does seem a bit strange and confusing with the
>> comment in exfat_ent_get.
>
> I don't think it's necessary to handle all errors in the same way.
>
> - Only the following error handling requires calling brelse.
> /* prevent the infinite loop of cluster chain */
> if (fclus > limit) {
> exfat_fs_error(sb,
> "detected the cluster chain loop (i_pos %u)",
> fclus);
> goto err;
> }
> - This makes confused with the comment in exfat_ent_get.
> - Unnecessary code modifications are avoided.
Okay, V2 is ready:
diff --git a/fs/exfat/cache.c b/fs/exfat/cache.c
index 61af3fa05ab7..a5e6858e5a20 100644
--- a/fs/exfat/cache.c
+++ b/fs/exfat/cache.c
@@ -241,6 +241,7 @@ int exfat_get_cluster(struct inode *inode, unsigned
int cluster,
struct exfat_sb_info *sbi = EXFAT_SB(sb);
unsigned int limit = sbi->num_clusters;
struct exfat_inode_info *ei = EXFAT_I(inode);
+ struct buffer_head *bh = NULL;
struct exfat_cache_id cid;
unsigned int content;
@@ -284,10 +285,10 @@ int exfat_get_cluster(struct inode *inode,
unsigned int cluster,
exfat_fs_error(sb,
"detected the cluster chain loop (i_pos
%u)",
(*fclus));
- return -EIO;
+ goto err;
}
- if (exfat_ent_get(sb, *dclus, &content, NULL))
+ if (exfat_ent_get(sb, *dclus, &content, &bh))
return -EIO;
*last_dclus = *dclus;
@@ -299,7 +300,7 @@ int exfat_get_cluster(struct inode *inode, unsigned
int cluster,
exfat_fs_error(sb,
"invalid cluster chain (i_pos
%u, last_clus 0x%08x is EOF)",
*fclus, (*last_dclus));
- return -EIO;
+ goto err; // will remove in patch 6/9
}
break;
@@ -309,6 +310,10 @@ int exfat_get_cluster(struct inode *inode, unsigned
int cluster,
cache_init(&cid, *fclus, *dclus);
}
+ brelse(bh);
exfat_cache_add(inode, &cid);
return 0;
+err:
+ brelse(bh);
+ return -EIO;
}
Thanks,
>
>>>
>>>>
>>>> *last_dclus = *dclus;
>>>> *dclus = content;
>>>> @@ -299,7 +300,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
>>>> exfat_fs_error(sb,
>>>> "invalid cluster chain (i_pos %u, last_clus 0x%08x is EOF)",
>>>> *fclus, (*last_dclus));
>>>> - return -EIO;
>>>> + goto err;
>>>> }
>>>>
>>>> break;
>>>> @@ -309,6 +310,10 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
>>>> cache_init(&cid, *fclus, *dclus);
>>>> }
>>>>
>>>> + brelse(bh);
>>>> exfat_cache_add(inode, &cid);
>>>> return 0;
>>>> +err:
>>>> + brelse(bh);
>>>> + return -EIO;
>>>> }
>>>
>>>
>
>
next prev parent reply other threads:[~2026-01-05 3:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 9:05 Yuezhang.Mo
2025-12-31 1:37 ` Chi Zhiling
2026-01-04 7:56 ` Yuezhang.Mo
2026-01-05 3:07 ` Chi Zhiling [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-12-26 9:44 [PATCH v1 0/9] Enable exfat_get_block to support obtaining multiple clusters Chi Zhiling
2025-12-26 9:44 ` [PATCH v1 3/9] exfat: reuse cache to improve exfat_get_cluster 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=53c38e14-13bb-4857-85cf-221408669475@163.com \
--to=chizhiling@163.com \
--cc=Yuezhang.Mo@sony.com \
--cc=brauner@kernel.org \
--cc=chizhiling@kylinos.cn \
--cc=jack@suse.cz \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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®