[RFC PATCH 4/4] xfs: allow linkat() on O_TMPFILE files
Christoph Hellwig
hch at infradead.org
Mon Nov 25 07:51:49 CST 2013
> - ASSERT(ip->i_d.di_nlink > 0);
> + if ((VFS_I(ip)->i_nlink == 0) &&
> + !(VFS_I(ip)->i_state & I_LINKABLE))
> + ASSERT(ip->i_d.di_nlink > 0);
ASSERT(ip->i_d.di_nlink > 0 || (VFS_I(ip)->i_state & I_LINKABLE));
> @@ -1498,7 +1503,14 @@ xfs_link(
> tp = xfs_trans_alloc(mp, XFS_TRANS_LINK);
> cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
> resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
> - error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0);
> +
> + if ((VFS_I(sip)->i_nlink == 0) &&
> + (VFS_I(sip)->i_state & I_LINKABLE))
> + tres = &M_RES(mp)->tr_link_tmpfile;
> + else
> + tres = &M_RES(mp)->tr_link;
Just check i_nlink, and for consistency it might make sense to just use
the xfs_inode one. The VFS already made sure we don't inodes with
I_LINKABLE and a zero link count.
> + if ((VFS_I(sip)->i_nlink == 0) &&
> + (VFS_I(sip)->i_state & I_LINKABLE)) {
Same here.
More information about the xfs
mailing list