xfs
[Top] [All Lists]

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

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [RFC PATCH 4/4] xfs: allow linkat() on O_TMPFILE files
From: Zhi Yong Wu <zwu.kernel@xxxxxxxxx>
Date: Fri, 13 Dec 2013 19:34:43 +0800
Cc: xfstests <xfs@xxxxxxxxxxx>, Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Q7qfjm/iMcL/rDKPMalpQoi7p0ESu0RXZ/Yfd9adLQI=; b=zF5j5Bxn+Qpr1ExelkL6KUGXrtP9mznE2RIb574uyOV6fphU29xsWy1ugr84K2WC19 4J0IgktNWvmBkj0QsnM4t2ge1CcpIegPWSEtoz5Nrt0uqQX0YTNPOK8aPvFbcq+BLdjb 7F+GpIsy6zqqX5uts58Nh+ngKROfYSpQjo1qgHaTXqU+YrMoqlGMFSqZCMpNaYSQOla9 iaJhnB13podzZ9U0t7aSfLmPelMFFJmO8/gbZdm7YYarQox6nytplFdYlNqiApTNfN6V r5eShy4v6SmdrM7vLKkOLMvSaJapOltxxPtXrTyIBQRLG0E8NVQB8hKyJcXvHnbJfhC2 uahA==
In-reply-to: <20131125214611.GI8803@dastard>
References: <1385379154-3802-1-git-send-email-zwu.kernel@xxxxxxxxx> <1385379154-3802-5-git-send-email-zwu.kernel@xxxxxxxxx> <20131125214611.GI8803@dastard>
On Tue, Nov 26, 2013 at 5:46 AM, Dave Chinner <david@xxxxxxxxxxxxx> wrote:
> On Mon, Nov 25, 2013 at 07:32:34PM +0800, Zhi Yong Wu wrote:
>> From: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
>>
>> Enable O_TMPFILE support in linkat().
>>
>> http://oss.sgi.com/archives/xfs/2013-08/msg00341.html
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
>> ---
>>  fs/xfs/xfs_inode.c      |   23 +++++++++++++++++++++--
>>  fs/xfs/xfs_trans_resv.c |   13 +++++++++++++
>>  fs/xfs/xfs_trans_resv.h |    2 ++
>>  3 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
>> index e1832de..7ab029b 100644
>> --- a/fs/xfs/xfs_inode.c
>> +++ b/fs/xfs/xfs_inode.c
>> @@ -62,6 +62,8 @@ kmem_zone_t *xfs_inode_zone;
>>
>>  STATIC int xfs_iflush_int(xfs_inode_t *, xfs_buf_t *);
>>
>> +STATIC int xfs_iunlink_remove(xfs_trans_t *, xfs_inode_t *);
>> +
>>  /*
>>   * helper function to extract extent size hint from inode
>>   */
>> @@ -1119,7 +1121,9 @@ xfs_bumplink(
>>  {
>>       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
>>
>> -     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);
>>       ip->i_d.di_nlink++;
>>       inc_nlink(VFS_I(ip));
>>       if ((ip->i_d.di_version == 1) &&
>> @@ -1473,6 +1477,7 @@ xfs_link(
>>  {
>>       xfs_mount_t             *mp = tdp->i_mount;
>>       xfs_trans_t             *tp;
>> +     struct xfs_trans_res    *tres;
>>       int                     error;
>>       xfs_bmap_free_t         free_list;
>>       xfs_fsblock_t           first_block;
>> @@ -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;
>> +
>> +     error = xfs_trans_reserve(tp, tres, resblks, 0);
>
> Uggh. For the small amount of extra space needed for the unlinked
> list reservation, I would simply add it to the tr_link reservation
> and be done with it. That gets rid of the need for the noise here.
>
>
> As per above, fold this into xfs_calc_link_reservation() by adding a:
>
>
>                 + xfs_calc_iunlink_remove_resv(mp);
This way seems to not work...
In xfs_calc_link_reservation(), How to determine if it is for one
regular file or O_TMPFILE file? since this functions is only passed in
mp?

>
> to the end of it.  Then you can also modify
> xfs_calc_ifree_reservation() to use the same
> xfs_calc_iunlink_remove_resv() function as well.
>
> [ And similarly, looking back on the previous patch
> xfs_calc_iunlink_add_resv can be used in xfs_calc_remove_reservation
> so all the unlinked list manipulations are covered by the same
> reservation calculations. ]
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@xxxxxxxxxxxxx



-- 
Regards,

Zhi Yong Wu

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