Bug 1471967 - st_nlink wrong for ext4 directory with 64998 subdirectories
st_nlink wrong for ext4 directory with 64998 subdirectories
Status: NEW
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
26
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Kernel Maintainer List
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-17 15:40 EDT by Paul Eggert
Modified: 2017-07-17 17:26 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Paul Eggert 2017-07-17 15:40:01 EDT
Description of problem:

lstat returns an incorrect link count for an ext4 directory with more than 64997 subdirectories. For example, if there are 64998 subdirectories, lstat reports the link count to be 1 rather than the correct 65000.

Version-Release number of selected component (if applicable):

Fedora 26 x86-64

How reproducible:

See the following shell transcript.

$ LC_ALL=C
$ export LC_ALL
$ mkdir d d/{1..64997}
$ strace -ve trace=%lstat ls -ld d
lstat("d", {st_dev=makedev(8, 2), st_ino=41565723, st_mode=S_IFDIR|0755, st_nlink=64999, st_uid=1000, st_gid=1000, st_blksize=4096, st_blocks=2744, st_size=1404928, st_atime=1500319812 /* 2017-07-17T12:30:12.934815840-0700 */, st_atime_nsec=934815840, st_mtime=1500319822 /* 2017-07-17T12:30:22.896866173-0700 */, st_mtime_nsec=896866173, st_ctime=1500319822 /* 2017-07-17T12:30:22.896866173-0700 */, st_ctime_nsec=896866173}) = 0
drwxr-xr-x. 64999 eggert eggert 1404928 Jul 17 12:30 d
+++ exited with 0 +++
$ mkdir d/64998
$ LC_ALL=C strace -ve trace=%lstat ls -ld d
lstat("d", {st_dev=makedev(8, 2), st_ino=41565723, st_mode=S_IFDIR|0755, st_nlink=1, st_uid=1000, st_gid=1000, st_blksize=4096, st_blocks=2744, st_size=1404928, st_atime=1500319812 /* 2017-07-17T12:30:12.934815840-0700 */, st_atime_nsec=934815840, st_mtime=1500319845 /* 2017-07-17T12:30:45.104978381-0700 */, st_mtime_nsec=104978381, st_ctime=1500319845 /* 2017-07-17T12:30:45.104978381-0700 */, st_ctime_nsec=104978381}) = 0
drwxr-xr-x. 1 eggert eggert 1404928 Jul 17 12:30 d


Expected results:

The last line should report a link count equal to 65000, not 1. The previous (lstat) line should report st_nlink=65000, not st_nlink=1.


Additional info:

This bug report follows up on a previous bug report for coreutils 'ls':

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27739
Comment 1 Laura Abbott 2017-07-17 16:18:55 EDT
Fedora isn't carrying anything special here, this needs to be reported to the upstream kernel developers.
Comment 2 Paul Eggert 2017-07-17 17:26:56 EDT
I reported the bug upstream here:

https://bugzilla.kernel.org/show_bug.cgi?id=196405

Note You need to log in before you can comment on or make changes to this bug.