]> git.baikalelectronics.ru Git - kernel.git/commit
ext4: fix dir_nlink behaviour
authorAndreas Dilger <adilger@dilger.ca>
Sat, 5 Aug 2017 23:47:34 +0000 (19:47 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 5 Aug 2017 23:47:34 +0000 (19:47 -0400)
commitfe76c9c6670700a1ceda157339b3972ba72fda72
tree46027eb3079c9e58dbda801bdaf4e54ea46fb67f
parentcaa07499e210de5236906179695ccabdb4c4ef90
ext4: fix dir_nlink behaviour

The dir_nlink feature has been enabled by default for new ext4
filesystems since e2fsprogs-1.41 in 2008, and was automatically
enabled by the kernel for older ext4 filesystems since the
dir_nlink feature was added with ext4 in kernel 2.6.28+ when
the subdirectory count exceeded EXT4_LINK_MAX-1.

Automatically adding the file system features such as dir_nlink is
generally frowned upon, since it could cause the file system to not be
mountable on older kernel, thus preventing the administrator from
rolling back to an older kernel if necessary.

In this case, the administrator might also want to disable the feature
because glibc's fts_read() function does not correctly optimize
directory traversal for directories that use st_nlinks field of 1 to
indicate that the number of links in the directory are not tracked by
the file system, and could fail to traverse the full directory
hierarchy.  Fortunately, in the past ten years very few users have
complained about incomplete file system traversal by glibc's
fts_read().

This commit also changes ext4_inc_count() to allow i_nlinks to reach
the full EXT4_LINK_MAX links on the parent directory (including "."
and "..") before changing i_links_count to be 1.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196405
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/namei.c