Re: [PATCH 3/3] fs: befs: Increment i_count when inode is found
From: Al Viro
Date: Sat Jun 04 2016 - 15:32:57 EST
On Sat, Jun 04, 2016 at 07:53:21PM +0100, Salah Triki wrote:
> As VFS expects, i_count field is incremented when the named inode is found.
VFS expects no such thing. Incidentally, you have neither bothered to
check other filesystems nor cared to look at fs/inode.c. OK, suppose you
have found a huge multi-filesystem bug - such things happen from time to
time. But you have not even bothered to test your conjecture; this "fix"
had never been tried or even compiled.
What actually happens is that iget_locked() acquires a reference to inode.
That reference is either dropped by iget_failed() (called by befs_iget()
in case of failure to read and initialized the sucker) or used up by
d_add() as a reference to hold dentry->d_inode.
Similar situation holds for other filesystems; they do not need to manipulate
i_count at all.