fsstress: add the ability to create/delete subvolumes
[xfstests-dev.git] / ltp / fsstress.c
index ecc1adc367553828db8d78ca2a4f67b8d770d7c8..45325a674649ef6530a9a9d1031b7710e51ba8af 100644 (file)
@@ -10,6 +10,9 @@
 #include <stddef.h>
 #include "global.h"
 
+#ifdef HAVE_BTRFSUTIL_H
+#include <btrfsutil.h>
+#endif
 #ifdef HAVE_ATTR_ATTRIBUTES_H
 #include <attr/attributes.h>
 #endif
@@ -69,6 +72,9 @@ static int renameat2(int dfd1, const char *path1,
 #ifndef RENAME_NOREPLACE
 #define RENAME_NOREPLACE       (1 << 0)        /* Don't overwrite target */
 #endif
+#ifndef RENAME_EXCHANGE
+#define RENAME_EXCHANGE                (1 << 1)        /* Exchange source and dest */
+#endif
 #ifndef RENAME_WHITEOUT
 #define RENAME_WHITEOUT                (1 << 2)        /* Whiteout source */
 #endif
@@ -115,6 +121,7 @@ typedef enum {
        OP_REMOVEFATTR,
        OP_RENAME,
        OP_RNOREPLACE,
+       OP_REXCHANGE,
        OP_RWHITEOUT,
        OP_RESVSP,
        OP_RMDIR,
@@ -123,6 +130,8 @@ typedef enum {
        OP_SETXATTR,
        OP_SPLICE,
        OP_STAT,
+       OP_SUBVOL_CREATE,
+       OP_SUBVOL_DELETE,
        OP_SYMLINK,
        OP_SYNC,
        OP_TRUNCATE,
@@ -145,6 +154,7 @@ typedef struct opdesc {
 
 typedef struct fent {
        int     id;
+       int     ft;
        int     parent;
        int     xattr_counter;
 } fent_t;
@@ -172,20 +182,22 @@ struct print_string {
        int max;
 };
 
-#define        FT_DIR  0
-#define        FT_DIRm (1 << FT_DIR)
-#define        FT_REG  1
-#define        FT_REGm (1 << FT_REG)
-#define        FT_SYM  2
-#define        FT_SYMm (1 << FT_SYM)
-#define        FT_DEV  3
-#define        FT_DEVm (1 << FT_DEV)
-#define        FT_RTF  4
-#define        FT_RTFm (1 << FT_RTF)
-#define        FT_nft  5
-#define        FT_ANYm ((1 << FT_nft) - 1)
+#define        FT_DIR          0
+#define        FT_DIRm         (1 << FT_DIR)
+#define        FT_REG          1
+#define        FT_REGm         (1 << FT_REG)
+#define        FT_SYM          2
+#define        FT_SYMm         (1 << FT_SYM)
+#define        FT_DEV          3
+#define        FT_DEVm         (1 << FT_DEV)
+#define        FT_RTF          4
+#define        FT_RTFm         (1 << FT_RTF)
+#define        FT_SUBVOL       5
+#define        FT_SUBVOLm      (1 << FT_SUBVOL)
+#define        FT_nft          6
+#define        FT_ANYm         ((1 << FT_nft) - 1)
 #define        FT_REGFILE      (FT_REGm | FT_RTFm)
-#define        FT_NOTDIR       (FT_ANYm & ~FT_DIRm)
+#define        FT_NOTDIR       (FT_ANYm & (~FT_DIRm & ~FT_SUBVOLm))
 
 #define        FLIST_SLOT_INCR 16
 #define        NDCACHE 64
@@ -235,6 +247,7 @@ void        readv_f(int, long);
 void   removefattr_f(int, long);
 void   rename_f(int, long);
 void   rnoreplace_f(int, long);
+void   rexchange_f(int, long);
 void   rwhiteout_f(int, long);
 void   resvsp_f(int, long);
 void   rmdir_f(int, long);
@@ -243,6 +256,8 @@ void        setfattr_f(int, long);
 void   setxattr_f(int, long);
 void   splice_f(int, long);
 void   stat_f(int, long);
+void   subvol_create_f(int, long);
+void   subvol_delete_f(int, long);
 void   symlink_f(int, long);
 void   sync_f(int, long);
 void   truncate_f(int, long);
@@ -296,6 +311,7 @@ opdesc_t    ops[] = {
        { OP_REMOVEFATTR, "removefattr", removefattr_f, 1, 1 },
        { OP_RENAME, "rename", rename_f, 2, 1 },
        { OP_RNOREPLACE, "rnoreplace", rnoreplace_f, 2, 1 },
+       { OP_REXCHANGE, "rexchange", rexchange_f, 2, 1 },
        { OP_RWHITEOUT, "rwhiteout", rwhiteout_f, 2, 1 },
        { OP_RESVSP, "resvsp", resvsp_f, 1, 1 },
        { OP_RMDIR, "rmdir", rmdir_f, 1, 1 },
@@ -307,6 +323,8 @@ opdesc_t    ops[] = {
        { OP_SETXATTR, "setxattr", setxattr_f, 1, 1 },
        { OP_SPLICE, "splice", splice_f, 1, 1 },
        { OP_STAT, "stat", stat_f, 1, 0 },
+       { OP_SUBVOL_CREATE, "subvol_create", subvol_create_f, 1, 1},
+       { OP_SUBVOL_DELETE, "subvol_delete", subvol_delete_f, 1, 1},
        { OP_SYMLINK, "symlink", symlink_f, 2, 1 },
        { OP_SYNC, "sync", sync_f, 1, 1 },
        { OP_TRUNCATE, "truncate", truncate_f, 2, 1 },
@@ -322,6 +340,7 @@ flist_t     flist[FT_nft] = {
        { 0, 0, 'l', NULL },
        { 0, 0, 'c', NULL },
        { 0, 0, 'r', NULL },
+       { 0, 0, 's', NULL },
 };
 
 int            dcache[NDCACHE];
@@ -366,12 +385,13 @@ int       creat_path(pathname_t *, mode_t);
 void   dcache_enter(int, int);
 void   dcache_init(void);
 fent_t *dcache_lookup(int);
-void   dcache_purge(int);
+void   dcache_purge(int, int);
 void   del_from_flist(int, int);
 int    dirid_to_name(char *, int);
 void   doproc(void);
-int    fent_to_name(pathname_t *, flist_t *, fent_t *);
-void   fix_parent(int, int);
+int    fent_to_name(pathname_t *, fent_t *);
+bool   fents_ancestor_check(fent_t *, fent_t *);
+void   fix_parent(int, int, bool);
 void   free_pathname(pathname_t *);
 int    generate_fname(fent_t *, int, pathname_t *, int *, int *);
 int    generate_xattr_name(int, char *, int);
@@ -400,6 +420,7 @@ int unlink_path(pathname_t *);
 void   usage(void);
 void   write_freq(void);
 void   zero_freq(void);
+void   non_btrfs_freq(const char *);
 
 void sg_handler(int signum)
 {
@@ -553,6 +574,7 @@ int main(int argc, char **argv)
             exit(1);
         }
 
+       non_btrfs_freq(dirname);
        (void)mkdir(dirname, 0777);
        if (logname && logname[0] != '/') {
                if (!getcwd(rpath, sizeof(rpath))){
@@ -788,6 +810,7 @@ add_to_flist(int ft, int id, int parent, int xattr_counter)
        }
        fep = &ftp->fents[ftp->nfiles++];
        fep->id = id;
+       fep->ft = ft;
        fep->parent = parent;
        fep->xattr_counter = xattr_counter;
 }
@@ -955,18 +978,22 @@ dcache_lookup(int dirid)
        int     i;
 
        i = dcache[dirid % NDCACHE];
-       if (i >= 0 && (fep = &flist[FT_DIR].fents[i])->id == dirid)
+       if (i >= 0 && i < flist[FT_DIR].nfiles &&
+           (fep = &flist[FT_DIR].fents[i])->id == dirid)
+               return fep;
+       if (i >= 0 && i < flist[FT_SUBVOL].nfiles &&
+           (fep = &flist[FT_SUBVOL].fents[i])->id == dirid)
                return fep;
        return NULL;
 }
 
 void
-dcache_purge(int dirid)
+dcache_purge(int dirid, int ft)
 {
        int     *dcp;
-
        dcp = &dcache[dirid % NDCACHE];
-       if (*dcp >= 0 && flist[FT_DIR].fents[*dcp].id == dirid)
+       if (*dcp >= 0 && *dcp < flist[ft].nfiles &&
+           flist[ft].fents[*dcp].id == dirid)
                *dcp = -1;
 }
 
@@ -982,32 +1009,58 @@ del_from_flist(int ft, int slot)
        flist_t *ftp;
 
        ftp = &flist[ft];
-       if (ft == FT_DIR)
-               dcache_purge(ftp->fents[slot].id);
+       if (ft == FT_DIR || ft == FT_SUBVOL)
+               dcache_purge(ftp->fents[slot].id, ft);
        if (slot != ftp->nfiles - 1) {
-               if (ft == FT_DIR)
-                       dcache_purge(ftp->fents[ftp->nfiles - 1].id);
+               if (ft == FT_DIR || ft == FT_SUBVOL)
+                       dcache_purge(ftp->fents[ftp->nfiles - 1].id, ft);
                ftp->fents[slot] = ftp->fents[--ftp->nfiles];
        } else
                ftp->nfiles--;
 }
 
+void
+delete_subvol_children(int parid)
+{
+       flist_t *flp;
+       int     i;
+again:
+       for (i = 0, flp = flist; i < FT_nft; i++, flp++) {
+               int c;
+               for (c = 0; c < flp->nfiles; c++) {
+                       if (flp->fents[c].parent == parid) {
+                               int id = flp->fents[c].id;
+                               del_from_flist(i, c);
+                               if (i == FT_DIR || i == FT_SUBVOL)
+                                       delete_subvol_children(id);
+                               goto again;
+                       }
+               }
+       }
+}
+
 fent_t *
 dirid_to_fent(int dirid)
 {
        fent_t  *efep;
        fent_t  *fep;
        flist_t *flp;
+       int     ft = FT_DIR;
 
        if ((fep = dcache_lookup(dirid)))
                return fep;
-       flp = &flist[FT_DIR];
+again:
+       flp = &flist[ft];
        for (fep = flp->fents, efep = &fep[flp->nfiles]; fep < efep; fep++) {
                if (fep->id == dirid) {
                        dcache_enter(dirid, fep - flp->fents);
                        return fep;
                }
        }
+       if (ft == FT_DIR) {
+               ft = FT_SUBVOL;
+               goto again;
+       }
        return NULL;
 }
 
@@ -1084,8 +1137,9 @@ errout:
  * Return 0 on error, 1 on success;
  */
 int
-fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep)
+fent_to_name(pathname_t *name, fent_t *fep)
 {
+       flist_t *flp = &flist[fep->ft];
        char    buf[NAME_MAX + 1];
        int     i;
        fent_t  *pfep;
@@ -1105,7 +1159,7 @@ fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep)
 #endif
                if (pfep == NULL)
                        return 0;
-               e = fent_to_name(name, &flist[FT_DIR], pfep);
+               e = fent_to_name(name, pfep);
                if (!e)
                        return 0;
                append_pathname(name, "/");
@@ -1117,8 +1171,22 @@ fent_to_name(pathname_t *name, flist_t *flp, fent_t *fep)
        return 1;
 }
 
+bool
+fents_ancestor_check(fent_t *fep, fent_t *dfep)
+{
+       fent_t  *tmpfep;
+
+       for (tmpfep = fep; tmpfep->parent != -1;
+            tmpfep = dirid_to_fent(tmpfep->parent)) {
+               if (tmpfep->parent == dfep->id)
+                       return true;
+       }
+
+       return false;
+}
+
 void
-fix_parent(int oldid, int newid)
+fix_parent(int oldid, int newid, bool swap)
 {
        fent_t  *fep;
        flist_t *flp;
@@ -1129,6 +1197,8 @@ fix_parent(int oldid, int newid)
                for (j = 0, fep = flp->fents; j < flp->nfiles; j++, fep++) {
                        if (fep->parent == oldid)
                                fep->parent = newid;
+                       else if (swap && fep->parent == newid)
+                               fep->parent = oldid;
                }
        }
 }
@@ -1165,7 +1235,7 @@ generate_fname(fent_t *fep, int ft, pathname_t *name, int *idp, int *v)
 
        /* prepend fep parent dir-name to it */
        if (fep) {
-               e = fent_to_name(name, &flist[FT_DIR], fep);
+               e = fent_to_name(name, fep);
                if (!e)
                        return 0;
                append_pathname(name, "/");
@@ -1247,7 +1317,7 @@ get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
 
                                /* fill-in what we were asked for */
                                if (name) {
-                                       e = fent_to_name(name, flp, fep);
+                                       e = fent_to_name(name, fep);
 #ifdef DEBUG
                                        if (!e) {
                                                fprintf(stderr, "%d: failed to get path for entry:"
@@ -1829,6 +1899,35 @@ zero_freq(void)
                p->freq = 0;
 }
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+opty_t btrfs_ops[] = {
+       OP_SUBVOL_CREATE,
+       OP_SUBVOL_DELETE,
+};
+
+void
+non_btrfs_freq(const char *path)
+{
+       opdesc_t                *p;
+#ifdef HAVE_BTRFSUTIL_H
+       enum btrfs_util_error   e;
+
+       e = btrfs_util_is_subvolume(path);
+       if (e != BTRFS_UTIL_ERROR_NOT_BTRFS)
+               return;
+#endif
+       for (p = ops; p < ops_end; p++) {
+               int i;
+               for (i = 0; i < ARRAY_SIZE(btrfs_ops); i++) {
+                       if (p->op == btrfs_ops[i]) {
+                               p->freq = 0;
+                               break;
+                       }
+               }
+       }
+}
+
 void inode_info(char *str, size_t sz, struct stat64 *s, int verbose)
 {
        if (verbose)
@@ -3080,7 +3179,7 @@ creat_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
+                       (void)fent_to_name(&f, fep);
                        printf("%d/%d: creat - no filename from %s\n",
                                procid, opno, f.path);
                }
@@ -3744,7 +3843,7 @@ link_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&l, &flist[FT_DIR], fep);
+                       (void)fent_to_name(&l, fep);
                        printf("%d/%d: link - no filename from %s\n",
                                procid, opno, l.path);
                }
@@ -3835,7 +3934,7 @@ mkdir_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
+                       (void)fent_to_name(&f, fep);
                        printf("%d/%d: mkdir - no filename from %s\n",
                                procid, opno, f.path);
                }
@@ -3873,7 +3972,7 @@ mknod_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
+                       (void)fent_to_name(&f, fep);
                        printf("%d/%d: mknod - no filename from %s\n",
                                procid, opno, f.path);
                }
@@ -4256,6 +4355,7 @@ out:
 
 struct print_flags renameat2_flags [] = {
        { RENAME_NOREPLACE, "NOREPLACE"},
+       { RENAME_EXCHANGE, "EXCHANGE"},
        { RENAME_WHITEOUT, "WHITEOUT"},
        { -1, NULL}
 };
@@ -4291,41 +4391,87 @@ do_renameat2(int opno, long r, int mode)
                return;
        }
 
-       /* get an existing directory for the destination parent directory name */
-       if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v))
-               parid = -1;
-       else
-               parid = dfep->id;
-       v |= v1;
+       /*
+        * Both pathnames must exist for the RENAME_EXCHANGE, and in
+        * order to maintain filelist/filename integrity, we should
+        * restrict exchange operation to files of the same type.
+        */
+       if (mode == RENAME_EXCHANGE) {
+               which = 1 << (flp - flist);
+               init_pathname(&newf);
+               if (!get_fname(which, random(), &newf, NULL, &dfep, &v)) {
+                       if (v)
+                               printf("%d/%d: rename - no target filename\n",
+                                       procid, opno);
+                       free_pathname(&newf);
+                       free_pathname(&f);
+                       return;
+               }
+               if (which == FT_DIRm && (fents_ancestor_check(fep, dfep) ||
+                   fents_ancestor_check(dfep, fep))) {
+                       if (v)
+                               printf("%d/%d: rename(REXCHANGE) %s and %s "
+                                       "have ancestor-descendant relationship\n",
+                                       procid, opno, f.path, newf.path);
+                       free_pathname(&newf);
+                       free_pathname(&f);
+                       return;
+               }
+               v |= v1;
+               id = dfep->id;
+               parid = dfep->parent;
+       } else {
+               /*
+                * Get an existing directory for the destination parent
+                * directory name.
+                */
+               if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v))
+                       parid = -1;
+               else
+                       parid = dfep->id;
+               v |= v1;
 
-       /* generate a new path using an existing parent directory in name */
-       init_pathname(&newf);
-       e = generate_fname(dfep, flp - flist, &newf, &id, &v1);
-       v |= v1;
-       if (!e) {
-               if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], dfep);
-                       printf("%d/%d: rename - no filename from %s\n",
-                               procid, opno, f.path);
+               /*
+                * Generate a new path using an existing parent directory
+                * in name.
+                */
+               init_pathname(&newf);
+               e = generate_fname(dfep, flp - flist, &newf, &id, &v1);
+               v |= v1;
+               if (!e) {
+                       if (v) {
+                               (void)fent_to_name(&f, dfep);
+                               printf("%d/%d: rename - no filename from %s\n",
+                                       procid, opno, f.path);
+                       }
+                       free_pathname(&newf);
+                       free_pathname(&f);
+                       return;
                }
-               free_pathname(&newf);
-               free_pathname(&f);
-               return;
        }
        e = rename_path(&f, &newf, mode) < 0 ? errno : 0;
        check_cwd();
        if (e == 0) {
                int xattr_counter = fep->xattr_counter;
+               bool swap = (mode == RENAME_EXCHANGE) ? true : false;
+               int ft = flp - flist;
 
                oldid = fep->id;
                oldparid = fep->parent;
 
-               if (flp - flist == FT_DIR)
-                       fix_parent(oldid, id);
+               /*
+                * Swap the parent ids for RENAME_EXCHANGE, and replace the
+                * old parent id for the others.
+                */
+               if (ft == FT_DIR || ft == FT_SUBVOL)
+                       fix_parent(oldid, id, swap);
 
                if (mode == RENAME_WHITEOUT) {
                        fep->xattr_counter = 0;
                        add_to_flist(flp - flist, id, parid, xattr_counter);
+               } else if (mode == RENAME_EXCHANGE) {
+                       fep->xattr_counter = dfep->xattr_counter;
+                       dfep->xattr_counter = xattr_counter;
                } else {
                        del_from_flist(flp - flist, fep - flp->fents);
                        add_to_flist(flp - flist, id, parid, xattr_counter);
@@ -4358,6 +4504,12 @@ 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)
 {
@@ -4424,6 +4576,8 @@ rmdir_f(int opno, long r)
        int             e;
        pathname_t      f;
        fent_t          *fep;
+       int             oldid;
+       int             oldparid;
        int             v;
 
        init_pathname(&f);
@@ -4435,13 +4589,16 @@ rmdir_f(int opno, long r)
        }
        e = rmdir_path(&f) < 0 ? errno : 0;
        check_cwd();
-       if (e == 0)
+       if (e == 0) {
+               oldid = fep->id;
+               oldparid = fep->parent;
                del_from_flist(FT_DIR, fep - flist[FT_DIR].fents);
+       }
        if (v) {
                printf("%d/%d: rmdir %s %d\n", procid, opno, f.path, e);
                if (e == 0)
                        printf("%d/%d: rmdir del entry: id=%d,parent=%d\n",
-                               procid, opno, fep->id, fep->parent);
+                               procid, opno, oldid, oldparid);
        }
        free_pathname(&f);
 }
@@ -4567,6 +4724,86 @@ stat_f(int opno, long r)
        free_pathname(&f);
 }
 
+void
+subvol_create_f(int opno, long r)
+{
+#ifdef HAVE_BTRFSUTIL_H
+       enum btrfs_util_error   e;
+       pathname_t              f;
+       fent_t                  *fep;
+       int                     id;
+       int                     parid;
+       int                     v;
+       int                     v1;
+       int                     err;
+
+       init_pathname(&f);
+       if (!get_fname(FT_DIRm | FT_SUBVOLm, r, NULL, NULL, &fep, &v))
+               parid = -1;
+       else
+               parid = fep->id;
+       err = generate_fname(fep, FT_SUBVOL, &f, &id, &v1);
+       v |= v1;
+       if (!err) {
+               if (v) {
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%d: subvol_create - no filename from %s\n",
+                              procid, opno, f.path);
+               }
+               free_pathname(&f);
+               return;
+       }
+       e = btrfs_util_create_subvolume(f.path, 0, NULL, NULL);
+       if (e == BTRFS_UTIL_OK)
+               add_to_flist(FT_SUBVOL, id, parid, 0);
+       if (v) {
+               printf("%d/%d: subvol_create %s %d(%s)\n", procid, opno,
+                      f.path, e, btrfs_util_strerror(e));
+               printf("%d/%d: subvol_create add id=%d,parent=%d\n", procid,
+                      opno, id, parid);
+       }
+       free_pathname(&f);
+#endif
+}
+
+void
+subvol_delete_f(int opno, long r)
+{
+#ifdef HAVE_BTRFSUTIL_H
+       enum btrfs_util_error   e;
+       pathname_t              f;
+       fent_t                  *fep;
+       int                     v;
+       int                     oldid;
+       int                     oldparid;
+
+       init_pathname(&f);
+       if (!get_fname(FT_SUBVOLm, r, &f, NULL, &fep, &v)) {
+               if (v)
+                       printf("%d:%d: subvol_delete - no subvolume\n", procid,
+                              opno);
+               free_pathname(&f);
+               return;
+       }
+       e = btrfs_util_delete_subvolume(f.path, 0);
+       check_cwd();
+       if (e == BTRFS_UTIL_OK) {
+               oldid = fep->id;
+               oldparid = fep->parent;
+               delete_subvol_children(oldid);
+               del_from_flist(FT_SUBVOL, fep - flist[FT_SUBVOL].fents);
+       }
+       if (v) {
+               printf("%d/%d: subvol_delete %s %d(%s)\n", procid, opno, f.path,
+                      e, btrfs_util_strerror(e));
+               if (e == BTRFS_UTIL_OK)
+                       printf("%d/%d: subvol_delete del entry: id=%d,parent=%d\n",
+                              procid, opno, oldid, oldparid);
+       }
+       free_pathname(&f);
+#endif
+}
+
 void
 symlink_f(int opno, long r)
 {
@@ -4590,7 +4827,7 @@ symlink_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
+                       (void)fent_to_name(&f, fep);
                        printf("%d/%d: symlink - no filename from %s\n",
                                procid, opno, f.path);
                }
@@ -4671,6 +4908,8 @@ unlink_f(int opno, long r)
        pathname_t      f;
        fent_t          *fep;
        flist_t         *flp;
+       int             oldid;
+       int             oldparid;
        int             v;
 
        init_pathname(&f);
@@ -4682,13 +4921,16 @@ unlink_f(int opno, long r)
        }
        e = unlink_path(&f) < 0 ? errno : 0;
        check_cwd();
-       if (e == 0)
+       if (e == 0) {
+               oldid = fep->id;
+               oldparid = fep->parent;
                del_from_flist(flp - flist, fep - flp->fents);
+       }
        if (v) {
                printf("%d/%d: unlink %s %d\n", procid, opno, f.path, e);
                if (e == 0)
                        printf("%d/%d: unlink del entry: id=%d,parent=%d\n",
-                               procid, opno, fep->id, fep->parent);
+                               procid, opno, oldid, oldparid);
        }
        free_pathname(&f);
 }