Re: [PATCH 2/3] xfs: don't ever put nlink > 0 inodes on the unlinked list

Christoph Hellwig
2019-02-14T08:15:56Z

On Wed, Feb 13, 2019 at 12:50:53PM -0800, Darrick J. Wong wrote:
> + if (tmpfile) {
> + /*
> + * The VFS requires that any inode fed to d_tmpfile must have
> + * nlink == 1 so that it can decrement the nlink in d_tmpfile.
> + * However, we created the temp file with nlink == 0 because
> + * we're not allowed to put an inode with nlink > 0 on the
> + * unlinked list. Therefore we have to set nlink to 1 so that
> + * d_tmpfile can immediately set it back to zero.
> + */
> + set_nlink(inode, 1);
> d_tmpfile(dentry, inode);
> + } else

At least btrtfs has to work around these d_tmpfile assumptions as well.
Instead of piling hacks over hacks I'd rather move the call to
inode_dec_link_count from d_tmpfile, which should lead to a saner
interface.