2023-03-22 09:16:59

by Qu Wenruo

[permalink] [raw]
Subject: A new special orphan inode 12 in ext4 only?

Hi,

Recently I observed newer mkfs.ext4 seems to create a new orphan inode
12, with some file extents.

Which seems to have no direct parent directory, thus tools like
btrfs-convert would also follow the ext4 inodes by creating an orphan
inode too.

On the other hand, if I go mkfs.ext3, the mysterious inode seems to be gone.

Is this inode 12 a known special inode?
If so, how can we avoid such special inode?
(s_special_ino is still 11, thus checking against that value doesn't
seem to help).


Some details of btrfs-convert:

It goes with ext2fs_open_inode_scan() to iterate all inodes of an ext4.

And if we hit an directory inode, we iterate the directory by using
ext2fs_dir_iterate2() to insert the dir entries between parent and child
inodes.

So if we hit an inode without any parent dir, an equivalent btrfs inode
would still be created, but btrfs-check would complain about such orphan
inode.

Thanks,
Qu


2023-03-22 17:36:12

by Andrei Borzenkov

[permalink] [raw]
Subject: Re: A new special orphan inode 12 in ext4 only?

On 22.03.2023 12:09, Qu Wenruo wrote:
> Hi,
>
> Recently I observed newer mkfs.ext4 seems to create a new orphan inode
> 12, with some file extents.
>
> Which seems to have no direct parent directory, thus tools like
> btrfs-convert would also follow the ext4 inodes by creating an orphan
> inode too.
>
> On the other hand, if I go mkfs.ext3, the mysterious inode seems to be gone.
>
> Is this inode 12 a known special inode?

This is orphan file. It is normal file; mke2fs creates first normal
inode for lost+found (11) and if enabled creates orphan file next which
gets next inode number (12). Inode number is recorded in superblock as
s_orphan_file_num.

/*27c*/ __le16 s_encoding; /* Filename charset encoding */
__le16 s_encoding_flags; /* Filename charset encoding
flags */
__le32 s_orphan_file_inum; /* Inode for tracking orphan
inodes */


> If so, how can we avoid such special inode?
> (s_special_ino is still 11, thus checking against that value doesn't
> seem to help).
>
>
> Some details of btrfs-convert:
>
> It goes with ext2fs_open_inode_scan() to iterate all inodes of an ext4.
>
> And if we hit an directory inode, we iterate the directory by using
> ext2fs_dir_iterate2() to insert the dir entries between parent and child
> inodes.
>
> So if we hit an inode without any parent dir, an equivalent btrfs inode
> would still be created, but btrfs-check would complain about such orphan
> inode.
>
> Thanks,
> Qu

2023-03-23 08:57:00

by Qu Wenruo

[permalink] [raw]
Subject: Re: A new special orphan inode 12 in ext4 only?



On 2023/3/23 01:27, Andrei Borzenkov wrote:
> On 22.03.2023 12:09, Qu Wenruo wrote:
>> Hi,
>>
>> Recently I observed newer mkfs.ext4 seems to create a new orphan inode
>> 12, with some file extents.
>>
>> Which seems to have no direct parent directory, thus tools like
>> btrfs-convert would also follow the ext4 inodes by creating an orphan
>> inode too.
>>
>> On the other hand, if I go mkfs.ext3, the mysterious inode seems to be
>> gone.
>>
>> Is this inode 12 a known special inode?
>
> This is orphan file. It is normal file; mke2fs creates first normal
> inode for lost+found (11) and if enabled creates orphan file next which
> gets next inode number (12). Inode number is recorded in superblock as
> s_orphan_file_num.
>
> /*27c*/ __le16  s_encoding;             /* Filename charset encoding */
>         __le16  s_encoding_flags;       /* Filename charset encoding
> flags */
>         __le32  s_orphan_file_inum;     /* Inode for tracking orphan
> inodes */

Thanks for the info.

Now btrfs-convert can skip that orphan file if the COMPAT_ORPHAN_FILE
feature is enabled.

Thanks,
Qu
>
>
>> If so, how can we avoid such special inode?
>> (s_special_ino is still 11, thus checking against that value doesn't
>> seem to help).
>>
>>
>> Some details of btrfs-convert:
>>
>> It goes with ext2fs_open_inode_scan() to iterate all inodes of an ext4.
>>
>> And if we hit an directory inode, we iterate the directory by using
>> ext2fs_dir_iterate2() to insert the dir entries between parent and child
>> inodes.
>>
>> So if we hit an inode without any parent dir, an equivalent btrfs inode
>> would still be created, but btrfs-check would complain about such orphan
>> inode.
>>
>> Thanks,
>> Qu
>