Re: Does btrfs get nlink on directories wrong? -- was Re: [PATCH 2/4] xfstests: Add first statx test [ver #5]

David Sterba
2017-04-05T12:30:55Z

On Wed, Apr 05, 2017 at 11:53:41AM +0100, David Howells wrote:
> I've added a test to xfstests that exercises the new statx syscall. However,
> it fails on btrfs:
>
> Test statx on a directory
> +[!] stx_nlink differs, 1 != 2
> +Failed
> +stat_test failed
>
> because a new directory it creates has an nlink of 1, not 2. Is this a case
> of my making an incorrect assumption or is it an fs bug?

Afaik nlink == 1 means that there's no accounting of subdirectories, and
it's a valid value. The 'find' utility can use nlink to optimize
directory traversal but otherwise I'm not aware of other usage.

All directories in btrfs have nlink == 1.