From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "david.shane.hunter@gmail.com" <david.shane.hunter@gmail.com>,
"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
"frank.li@vivo.com" <frank.li@vivo.com>,
"slava@dubeyko.com" <slava@dubeyko.com>,
"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
"jkoolstra@xs4all.nl" <jkoolstra@xs4all.nl>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"syzbot+17cc9bb6d8d69b4139f0@syzkaller.appspotmail.com"
<syzbot+17cc9bb6d8d69b4139f0@syzkaller.appspotmail.com>
Subject: RE: [PATCH] hfs: Replace BUG_ON with error handling in hfs_new_inode()
Date: Mon, 24 Nov 2025 19:29:36 +0000 [thread overview]
Message-ID: <0e678a65d147e642a09861ea833efbd40b098d10.camel@ibm.com> (raw)
In-Reply-To: <1287044022.2349785.1763841059344@kpc.webmail.kpnmail.nl>
On Sat, 2025-11-22 at 20:50 +0100, Jori Koolstra wrote:
> >
> > I am terribly sorry, I've missed the patch. But, please, please,
> > please, add prefix 'hfs:' to the topic. This is the reason why I've
> > missed the patch. I expected to see something like this:
> >
> > hfs: Replace BUG_ON with error handling in hfs_new_inode()
> >
> > I need to process dozens emails every day. So, if I don't see proper
> > keyword in the topic, then I skip the emails.
>
> My bad, I didn't know this convention. Is this LKML-wide? Because I have
> also been waiting for a few weeks on feedback on jfs patches. Normally,
> it would not matter, but I am in the Linux Foundation Kernel Mentorship
> Program and we need to get several patches in before the deadline to
> succeed :)
>
You can take a look here [1]. Usually, yes, everybody expects kernel subsystem's
name as the prefix:
Subject: [PATCH 001/123] subsystem: summary phrase
> > OK. I see. You have modified the hfs_new_inode() with the goal to
> > return error code instead of NULL.
> >
> > Frankly speaking, I am not sure that inode is NULL, then it means
> > always that we are out of memory (-ENOMEM).
> >
>
> I think this is correct. See for instance fs/ext4/ialloc.c at __ext4_new_inode.
>
Probably, you are right. I simply took a look into alloc_inode():
struct inode *alloc_inode(struct super_block *sb)
{
const struct super_operations *ops = sb->s_op;
struct inode *inode;
if (ops->alloc_inode)
inode = ops->alloc_inode(sb);
else
inode = alloc_inode_sb(sb, inode_cachep, GFP_KERNEL);
if (!inode)
return NULL;
if (unlikely(inode_init_always(sb, inode))) {
if (ops->destroy_inode) {
ops->destroy_inode(inode);
if (!ops->free_inode)
return NULL;
}
inode->free_inode = ops->free_inode;
i_callback(&inode->i_rcu);
return NULL;
}
return inode;
}
Second part of the method could return NULL even if inode has been allocated.
But we can consider -ENOMEM in hfs_new_inode(). I am OK with that.
Thanks,
Slava.
> >
> > Why do we use -ENOSPC here? If next_id > U32_MAX, then it doesn't mean
> > that volume is full. Probably, we have corrupted volume, then code
> > error should be completely different (maybe, -EIO).
> >
>
> ext4 uses EFSCORRUPTED which is defined as EUCLEAN, I can change that.
>
> I wasn't exactly sure of the limits in place in hfs. But looking more closely,
> there can only be 65,535 allocation blocks, and I think you need at least one
> per inode. But then why are the CNID, max files, max directories 32-bit values
> in the MBD? What limits indicate corruption?
>
>
> > The 'hfs:' prefix is not necessary here. It could be not only file but
> > folder ID too. So, maybe, it makes sense to mention "next CNID". The
> > whole comment needs to be on one line. Also, I believe it makes sense
> > to recommend run FSCK tool here.
> >
>
> Will fix this.
>
> > >
> > > void hfs_delete_inode(struct inode *inode)
> > > @@ -251,7 +271,6 @@ void hfs_delete_inode(struct inode *inode)
> > >
> > > hfs_dbg("ino %lu\n", inode->i_ino);
> > > if (S_ISDIR(inode->i_mode)) {
> > > - BUG_ON(atomic64_read(&HFS_SB(sb)->folder_count) >
> > > U32_MAX);
> >
> > I don't agree with complete removal of this check. Because, we could
> > have bugs in file system logic that can increase folder_count
> > wrongfully above U32_MAX limit.
> >
> > So, I prefer to have this check in some way. Error code sounds good.
> >
>
> Will add these back with error handling instead of BUG_ON.
>
>
>
[1]
https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format
prev parent reply other threads:[~2025-11-24 19:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 13:10 [PATCH] Replace BUG_ON with error handling in hfs_new_inode() Jori Koolstra
2025-11-20 19:53 ` Viacheslav Dubeyko
2025-11-22 19:50 ` [PATCH] hfs: " Jori Koolstra
2025-11-24 19:29 ` Viacheslav Dubeyko [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=0e678a65d147e642a09861ea833efbd40b098d10.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=david.shane.hunter@gmail.com \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=jkoolstra@xs4all.nl \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=slava@dubeyko.com \
--cc=syzbot+17cc9bb6d8d69b4139f0@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;
as well as URLs for NNTP newsgroup(s).