Re: [PATCH v3 18/26] xfs: Add parent pointers to xfs_cross_rename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2022-09-23 at 14:52 -0700, Darrick J. Wong wrote:
> On Wed, Sep 21, 2022 at 10:44:50PM -0700,
> allison.henderson@xxxxxxxxxx wrote:
> > From: Allison Henderson <allison.henderson@xxxxxxxxxx>
> > 
> > Cross renames are handled separately from standard renames, and
> > need different handling to update the parent attributes correctly.
> > 
> > Signed-off-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
> > ---
> >  fs/xfs/xfs_inode.c | 85 ++++++++++++++++++++++++++++++++++++++----
> > ----
> >  1 file changed, 70 insertions(+), 15 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 1a35dc972d4d..51724af22bf9 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -2682,27 +2682,49 @@ xfs_finish_rename(
> >   */
> >  STATIC int
> >  xfs_cross_rename(
> > -       struct xfs_trans        *tp,
> > -       struct xfs_inode        *dp1,
> > -       struct xfs_name         *name1,
> > -       struct xfs_inode        *ip1,
> > -       struct xfs_inode        *dp2,
> > -       struct xfs_name         *name2,
> > -       struct xfs_inode        *ip2,
> > -       int                     spaceres)
> > +       struct xfs_trans                *tp,
> > +       struct xfs_inode                *dp1,
> > +       struct xfs_name                 *name1,
> > +       struct xfs_inode                *ip1,
> > +       struct xfs_inode                *dp2,
> > +       struct xfs_name                 *name2,
> > +       struct xfs_inode                *ip2,
> > +       int                             spaceres)
> >  {
> > -       int             error = 0;
> > -       int             ip1_flags = 0;
> > -       int             ip2_flags = 0;
> > -       int             dp2_flags = 0;
> > +       struct xfs_mount                *mp = dp1->i_mount;
> > +       int                             error = 0;
> > +       int                             ip1_flags = 0;
> > +       int                             ip2_flags = 0;
> > +       int                             dp2_flags = 0;
> > +       int                             new_diroffset,
> > old_diroffset;
> > +       struct xfs_parent_defer         *old_parent_ptr = NULL;
> > +       struct xfs_parent_defer         *new_parent_ptr = NULL;
> > +       struct xfs_parent_defer         *old_parent_ptr2 = NULL;
> > +       struct xfs_parent_defer         *new_parent_ptr2 = NULL;
> > +
> > +
> > +       if (xfs_has_parent(mp)) {
> > +               error = xfs_parent_init(mp, &old_parent_ptr);
> > +               if (error)
> > +                       goto out_trans_abort;
> > +               error = xfs_parent_init(mp, &new_parent_ptr);
> > +               if (error)
> > +                       goto out_trans_abort;
> > +               error = xfs_parent_init(mp, &old_parent_ptr2);
> > +               if (error)
> > +                       goto out_trans_abort;
> > +               error = xfs_parent_init(mp, &new_parent_ptr2);
> > +               if (error)
> > +                       goto out_trans_abort;
> 
> Four?  I think this means that xfs_calc_rename_reservation needs to
> do:
> 
>         overhead += 4 * (sizeof(struct xfs_attri_log_item) +
>                                 whatever_else);
> 
> Right?

Ok, I will bump up the overhead in xfs_calc_rename_reservation and see
if I can plumb another param through xfs_trans_alloc to add in the
additional name/value sizes

Allison 


> The rest of the patch looks fine, though...
> 
> > +       }
> >  
> >         /* Swap inode number for dirent in first parent */
> > -       error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino,
> > spaceres, NULL);
> > +       error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino,
> > spaceres, &old_diroffset);
> >         if (error)
> >                 goto out_trans_abort;
> >  
> >         /* Swap inode number for dirent in second parent */
> > -       error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino,
> > spaceres, NULL);
> > +       error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino,
> > spaceres, &new_diroffset);
> >         if (error)
> >                 goto out_trans_abort;
> >  
> > @@ -2763,6 +2785,28 @@ xfs_cross_rename(
> >                 }
> >         }
> >  
> > +       if (xfs_has_parent(mp)) {
> > +               error = xfs_parent_defer_replace(tp, dp1,
> > +                                                 old_parent_ptr,
> > +                                                 old_diroffset,
> > +                                                 name2,
> > +                                                 dp2,
> > +                                                 new_parent_ptr,
> > +                                                 new_diroffset,
> > ip1);
> 
> ...if you reflowed this to do two-tab indenting instead of kernel-
> style
> indenting I wouldn't be sad. ;)
> 
> --D
> 
> > +               if (error)
> > +                       goto out_trans_abort;
> > +
> > +               error = xfs_parent_defer_replace(tp, dp2,
> > +                                                 new_parent_ptr2,
> > +                                                 new_diroffset,
> > +                                                 name1,
> > +                                                 dp1,
> > +                                                 old_parent_ptr2,
> > +                                                 old_diroffset,
> > ip2);
> > +               if (error)
> > +                       goto out_trans_abort;
> > +       }
> > +
> >         if (ip1_flags) {
> >                 xfs_trans_ichgtime(tp, ip1, ip1_flags);
> >                 xfs_trans_log_inode(tp, ip1, XFS_ILOG_CORE);
> > @@ -2777,10 +2821,21 @@ xfs_cross_rename(
> >         }
> >         xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD |
> > XFS_ICHGTIME_CHG);
> >         xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE);
> > -       return xfs_finish_rename(tp);
> >  
> > +       error = xfs_finish_rename(tp);
> > +       goto out;
> >  out_trans_abort:
> >         xfs_trans_cancel(tp);
> > +out:
> > +       if (new_parent_ptr)
> > +               xfs_parent_cancel(mp, new_parent_ptr);
> > +       if (old_parent_ptr)
> > +               xfs_parent_cancel(mp, old_parent_ptr);
> > +       if (new_parent_ptr2)
> > +               xfs_parent_cancel(mp, new_parent_ptr2);
> > +       if (old_parent_ptr2)
> > +               xfs_parent_cancel(mp, old_parent_ptr2);
> > +
> >         return error;
> >  }
> >  
> > -- 
> > 2.25.1
> > 





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux