On Fri, Oct 18, 2019 at 05:57:55PM +0800, kaixuxia wrote: > Support the renameat2 syscall in fsstress. > > Signed-off-by: kaixuxia <kaixuxia@xxxxxxxxxxx> > --- > Changes in v4: > -Fix long line((> 80 characters) problem. > -Fix the RENAME_WHITEOUT RENAME_EXCHANGE file flist problem. > > ltp/fsstress.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 143 insertions(+), 31 deletions(-) > > diff --git a/ltp/fsstress.c b/ltp/fsstress.c > index 51976f5..f268a5a 100644 > --- a/ltp/fsstress.c > +++ b/ltp/fsstress.c ... > @@ -4269,16 +4348,26 @@ rename_f(int opno, long r) > oldid = fep->id; > fix_parent(oldid, id); > } > + > + if (mode == RENAME_WHITEOUT) > + add_to_flist(FT_DEV, fep->id, fep->parent, 0); > + else if (mode == RENAME_EXCHANGE) { > + del_from_flist(dflp - flist, dfep - dflp->fents); > + add_to_flist(dflp - flist, fep->id, fep->parent, > + dfep->xattr_counter); I think dfep->xattr_counter is overwritten by the del_from_flist() call. Also if the source and the target happen to be on the same file type list, what prevents the del_from_flist() call above from relocating the entry associated with the target, invalidating the fep reference used below? I'm wondering if we need some kind of entry swap helper function here to get this right for the exchange case (i.e. pass two list+slot pairs to swap and let the function make a local copy as appropriate)... Brian > + } > + > del_from_flist(flp - flist, fep - flp->fents); > add_to_flist(flp - flist, id, parid, xattr_counter); > } > if (v) { > - printf("%d/%d: rename %s to %s %d\n", procid, opno, f.path, > + printf("%d/%d: rename(%s) %s to %s %d\n", procid, > + opno, translate_renameat2_flags(mode), f.path, > newf.path, e); > if (e == 0) { > - printf("%d/%d: rename del entry: id=%d,parent=%d\n", > + printf("%d/%d: rename source entry: id=%d,parent=%d\n", > procid, opno, fep->id, fep->parent); > - printf("%d/%d: rename add entry: id=%d,parent=%d\n", > + printf("%d/%d: rename target entry: id=%d,parent=%d\n", > procid, opno, id, parid); > } > } > @@ -4287,6 +4376,29 @@ rename_f(int opno, long r) > } > > void > +rename_f(int opno, long r) > +{ > + do_renameat2(opno, r, 0); > +} > +void > +rnoreplace_f(int opno, long r) > +{ > + do_renameat2(opno, r, RENAME_NOREPLACE); > +} > + > +void > +rexchange_f(int opno, long r) > +{ > + do_renameat2(opno, r, RENAME_EXCHANGE); > +} > + > +void > +rwhiteout_f(int opno, long r) > +{ > + do_renameat2(opno, r, RENAME_WHITEOUT); > +} > + > +void > resvsp_f(int opno, long r) > { > int e; > -- > 1.8.3.1 > > -- > kaixuxia