Re: [PATCH v4 19/27] xfs: Add parent pointers to xfs_cross_rename

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

 



On Tue, 2022-10-25 at 14:32 -0700, Darrick J. Wong wrote:
> On Fri, Oct 21, 2022 at 03:29:28PM -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 | 79 ++++++++++++++++++++++++++++++++++++------
> > ----
> >  1 file changed, 63 insertions(+), 16 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 83cc52c2bcf1..c79d1047d118 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -2746,27 +2746,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)
> > -{
> > -       int             error = 0;
> > -       int             ip1_flags = 0;
> > -       int             ip2_flags = 0;
> > -       int             dp2_flags = 0;
> > +       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_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;
> > +
> > +
> 
> Nit: extra blank line
Ok, will fix

> 
> > +       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;
> > +       }
> >  
> >         /* 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;
> >  
> > @@ -2827,6 +2849,20 @@ xfs_cross_rename(
> >                 }
> >         }
> >  
> > +       if (xfs_has_parent(mp)) {
> > +               error = xfs_parent_defer_replace(tp, dp1,
> 
> Isn't xfs_parent_defer_replace() added in the next patch?
> 
> > +                               old_parent_ptr, old_diroffset,
> > name2, dp2,
> > +                               new_parent_ptr, new_diroffset,
> > ip1);
> 
> The changes to xfs_parent_defer_replace that I mention in the next
> patch
> notwithstanding, this looks good now.
> 
Oh I think youre right.  I think probably I can just swap these two
patches and it should be ok.  Thanks!

Allison

> --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);
> > @@ -2841,10 +2877,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