Re: [PATCH for 6.19-rc1] fs: preserve file type in make_bad_inode() unless invalid

From: Al Viro
Date: Wed Dec 10 2025 - 16:14:11 EST


On Wed, Dec 10, 2025 at 11:24:40AM +0100, Mateusz Guzik wrote:

> I'm delighted to see the call is considered bogus.
>
> As for being able to assert on it, I noted the current flag handling
> for lifecycle tracking is unhelpful.
>
> Per your response, i_state == 0 is overloaded to mean the inode is
> fully sorted out *and* that it is brand new.
>
> Instead clear-cut indicators are needed to track where the inode is in
> its lifecycle.
>
> I proposed 2 ways: a dedicated enum or fucking around with flags.
>
> Indeed the easiest stepping stone for the time being would be to push
> up I_NEW to alloc_inode and assert on it in places which set the flag.
> I'm going to cook it up.

You are misinterpreting what I_NEW is about - it is badly named, no
arguments here, but it's _not_ "inode is new".

It's "it's in inode hash, but if you find it on lookup, you'll need to wait -
it's not entirely set up".

A plenty of inodes never enter that state at all. Hell, consider pipes.
Or sockets. Or anything on procfs. Or sysfs, or...

We never look those up by inumber and there'd be no sane way to do that
anyway. They never get hashed, nor should they.