Bug 821161

Summary: ls -l command always outputs 1 as the number of hardlinks on btrfs
Product: [Fedora] Fedora Reporter: Vratislav Podzimek <vpodzime>
Component: kernelAssignee: Zach Brown <zab>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: 16CC: gansalmon, itamar, jonathan, kdudka, kernel-maint, madhu.chinakonda, maxamillion, ovasik, p, sweil, twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-26 23:42:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vratislav Podzimek 2012-05-12 15:48:20 UTC
Description of problem:
When using 'ls -l' command on the btrfs filesystem, it outputs 1 as the number of hardlinks for every directory, no matter how its content looks like. Other filesystems seem to be ok.

Version-Release number of selected component (if applicable):
coreutils-8.12-7.fc16.i686

How reproducible:
100 %

Steps to Reproduce:
1. create a directory on the btrfs filesystem and create a subdirectory in it
2. run 'ls -ld' on the toplevel directory
3. see that there is 1 on the place of the number of hardlinks
  
Actual results:
although there is a subdirectory in the toplevel directory, the number of hardlinks is 1

Expected results:
number of hardlinks is 2, because 'toplevel_dir/subdir/..' is the a link to the toplevel directory

Additional info:
I hope this is not an expected behaviour on the btrfs. Please reassing this bug to kernel if this is a btrfs bug.

Comment 1 Ondrej Vasik 2012-05-12 16:00:13 UTC
When other filesystems are ok, it is most probably filesystem issue. Reassigning to kernel and Josef Bacik.

Comment 3 Zach Brown 2012-06-26 23:42:39 UTC
> I hope this is not an expected behaviour on the btrfs.

It is.

In addition to the previous comment with the link to a discussion about this, here's a link to the thread where the upstream maintainer rejects patches to track nlink in directories:

http://comments.gmane.org/gmane.comp.file-systems.btrfs/4583

Arguably btrfs could behave like ext4 and track the link count until it hits a max and then goes to 1, but that's a discussion to have upstream.  This isn't a bug in Fedora.