]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Fix directory hardlinks from deleted directories
authorDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 1 Feb 2016 14:04:46 +0000 (14:04 +0000)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:45:30 +0000 (15:45 -0700)
commitdb37129231bf199ef87effcdd44924180a3eaf79
tree1401690e64652f4b24814277bd22d37e56fc9bdb
parent22de3caf6329a6ef32b235eeb02f18fe851dbced
Fix directory hardlinks from deleted directories

Orabug: 23330972

[ Upstream commit be629c62a603e5935f8177fd8a19e014100a259e ]

When a directory is deleted, we don't take too much care about killing off
all the dirents that belong to it — on the basis that on remount, the scan
will conclude that the directory is dead anyway.

This doesn't work though, when the deleted directory contained a child
directory which was moved *out*. In the early stages of the fs build
we can then end up with an apparent hard link, with the child directory
appearing both in its true location, and as a child of the original
directory which are this stage of the mount process we don't *yet* know
is defunct.

To resolve this, take out the early special-casing of the "directories
shall not have hard links" rule in jffs2_build_inode_pass1(), and let the
normal nlink processing happen for directories as well as other inodes.

Then later in the build process we can set ic->pino_nlink to the parent
inode#, as is required for directories during normal operaton, instead
of the nlink. And complain only *then* about hard links which are still
in evidence even after killing off all the unreachable paths.

Reported-by: Liu Song <liu.song11@zte.com.cn>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 49f76896f87b49592781f09d6e6c3f868051a6d7)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/jffs2/build.c
fs/jffs2/nodelist.h