xfs
[Top] [All Lists]

Re: [RFC PATCH 4/4] xfs: allow linkat() on O_TMPFILE files

To: Zhi Yong Wu <zwu.kernel@xxxxxxxxx>
Subject: Re: [RFC PATCH 4/4] xfs: allow linkat() on O_TMPFILE files
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Mon, 25 Nov 2013 05:51:49 -0800
Cc: xfs@xxxxxxxxxxx, Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1385379154-3802-5-git-send-email-zwu.kernel@xxxxxxxxx>
References: <1385379154-3802-1-git-send-email-zwu.kernel@xxxxxxxxx> <1385379154-3802-5-git-send-email-zwu.kernel@xxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
> -     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.

<Prev in Thread] Current Thread [Next in Thread>