On 2019/3/28 下午9:57, David Sterba wrote:
> On Thu, Mar 28, 2019 at 09:42:59PM +0800, Qu Wenruo wrote:
>>
>>
>> On 2019/3/28 下午9:38, David Sterba wrote:
>>> On Wed, Mar 20, 2019 at 02:37:16PM +0800, Qu Wenruo wrote:
>>>> + if (S_ISDIR(mode) && btrfs_inode_nlink(leaf, iitem) > 1) {
>>>> + inode_item_err(fs_info, leaf, slot,
>>>> + "invalid nlink: has %u expect no more than 1 for
>>>> dir",
>>>> + btrfs_inode_nlink(leaf, iitem));
>>>> + goto error;
>>>> + }
>>>
>>> I'm not sure about this check, the number of links for a directory is 1,
>>> but the exact count could be implemented (there's a project idea for
>>> that). I don't know if this will require an incompat bit or not.
>>
>> That means we have hard link for directories.
>
> Yes, hard links of directories are forbidden by VFS but that's not the
> point here:
>
> https://btrfs.wiki.kernel.org/index.php/Project_ideas#Track_link_count_for_directories
>
> "The link count for directories is traditionally used to count the number
> of subdirectores iff the link count is >= 2."
Oh, got it.
But for that case, it would be much better to go for things like nbytes
or size, as by all means, those two members are less meaningful than
nlinks for directory.
Thanks,
Qu
>
- Re: [PATCh v2 9/9] btrfs: inode: Verify in... David Sterba
- [PATCh v2 8/9] btrfs: tree-checker: Verify inode item Qu Wenruo
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify ino... Johannes Thumshirn
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify ino... Qu Wenruo
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify... David Sterba
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify ino... David Sterba
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify ino... David Sterba
- Re: [PATCh v2 8/9] btrfs: tree-checker: Verify... Qu Wenruo
- Re: [PATCh v2 8/9] btrfs: tree-checker: Ve... David Sterba
- Re: [PATCh v2 8/9] btrfs: tree-checker... Qu Wenruo
- Re: [PATCh v2 8/9] btrfs: tree-ch... David Sterba
- Re: [PATCh v2 8/9] btrfs: tre... Qu Wenruo
- Re: [PATCh v2 8/9] btrfs: tre... David Sterba
- Re: [PATCh v2 8/9] btrfs: tre... Qu Wenruo
- [PATCh v2 3/9] btrfs: tree-checker: Make btrfs_check_ch... Qu Wenruo
- Re: [PATCh v2 3/9] btrfs: tree-checker: Make btrfs... Johannes Thumshirn
- [PATCh v2 6/9] btrfs: Check the first key and level for... Qu Wenruo
- Re: [PATCh v2 6/9] btrfs: Check the first key and ... Johannes Thumshirn
- [PATCh v2 1/9] btrfs: Move btrfs_check_chunk_valid() to... Qu Wenruo
- Re: [PATCh v2 1/9] btrfs: Move btrfs_check_chunk_v... Johannes Thumshirn
