fsstress: consistently index the ops array by OP_ type
[xfstests-dev.git] / ltp / fsstress.c
index 012557199aafa2d083ec8681985486b9703c22e9..5f3126e6747114bc2581d2d8776a06a3f7313c71 100644 (file)
@@ -8,24 +8,30 @@
 #include <setjmp.h>
 #include <sys/uio.h>
 #include <stddef.h>
+#include <stdbool.h>
+#include <string.h>
 #include "global.h"
 
-#ifdef HAVE_ATTR_ATTRIBUTES_H
-#include <attr/attributes.h>
+#ifdef HAVE_BTRFSUTIL_H
+#include <btrfsutil.h>
 #endif
 #ifdef HAVE_LINUX_FIEMAP_H
 #include <linux/fiemap.h>
 #endif
-#ifndef HAVE_ATTR_LIST
-#define attr_list(path, buf, size, flags, cursor) (errno = -ENOSYS, -1)
-#endif
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
 #ifdef AIO
 #include <libaio.h>
+#define AIO_ENTRIES    1
 io_context_t   io_ctx;
 #endif
+#ifdef URING
+#include <liburing.h>
+#define URING_ENTRIES  1
+struct io_uring        ring;
+bool have_io_uring;                    /* to indicate runtime availability */
+#endif
 #include <sys/syscall.h>
 #include <sys/xattr.h>
 
@@ -125,22 +131,28 @@ typedef enum {
        OP_SETATTR,
        OP_SETFATTR,
        OP_SETXATTR,
+       OP_SNAPSHOT,
        OP_SPLICE,
        OP_STAT,
+       OP_SUBVOL_CREATE,
+       OP_SUBVOL_DELETE,
        OP_SYMLINK,
        OP_SYNC,
        OP_TRUNCATE,
        OP_UNLINK,
        OP_UNRESVSP,
+       OP_URING_READ,
+       OP_URING_WRITE,
        OP_WRITE,
        OP_WRITEV,
        OP_LAST
 } opty_t;
 
-typedef void (*opfnc_t)(int, long);
+typedef long long opnum_t;
+
+typedef void (*opfnc_t)(opnum_t, long);
 
 typedef struct opdesc {
-       opty_t  op;
        char    *name;
        opfnc_t func;
        int     freq;
@@ -149,6 +161,7 @@ typedef struct opdesc {
 
 typedef struct fent {
        int     id;
+       int     ft;
        int     parent;
        int     xattr_counter;
 } fent_t;
@@ -176,20 +189,23 @@ 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        FT_ANYDIR       (FT_DIRm | FT_SUBVOLm)
 
 #define        FLIST_SLOT_INCR 16
 #define        NDCACHE 64
@@ -199,127 +215,137 @@ struct print_string {
 
 #define XATTR_NAME_BUF_SIZE 18
 
-void   afsync_f(int, long);
-void   allocsp_f(int, long);
-void   aread_f(int, long);
-void   attr_remove_f(int, long);
-void   attr_set_f(int, long);
-void   awrite_f(int, long);
-void   bulkstat_f(int, long);
-void   bulkstat1_f(int, long);
-void   chown_f(int, long);
-void   clonerange_f(int, long);
-void   copyrange_f(int, long);
-void   creat_f(int, long);
-void   deduperange_f(int, long);
-void   dread_f(int, long);
-void   dwrite_f(int, long);
-void   fallocate_f(int, long);
-void   fdatasync_f(int, long);
-void   fiemap_f(int, long);
-void   freesp_f(int, long);
-void   fsync_f(int, long);
+void   afsync_f(opnum_t, long);
+void   allocsp_f(opnum_t, long);
+void   aread_f(opnum_t, long);
+void   attr_remove_f(opnum_t, long);
+void   attr_set_f(opnum_t, long);
+void   awrite_f(opnum_t, long);
+void   bulkstat_f(opnum_t, long);
+void   bulkstat1_f(opnum_t, long);
+void   chown_f(opnum_t, long);
+void   clonerange_f(opnum_t, long);
+void   copyrange_f(opnum_t, long);
+void   creat_f(opnum_t, long);
+void   deduperange_f(opnum_t, long);
+void   dread_f(opnum_t, long);
+void   dwrite_f(opnum_t, long);
+void   fallocate_f(opnum_t, long);
+void   fdatasync_f(opnum_t, long);
+void   fiemap_f(opnum_t, long);
+void   freesp_f(opnum_t, long);
+void   fsync_f(opnum_t, long);
 char   *gen_random_string(int);
-void   getattr_f(int, long);
-void   getdents_f(int, long);
-void   getfattr_f(int, long);
-void   link_f(int, long);
-void   listfattr_f(int, long);
-void   mkdir_f(int, long);
-void   mknod_f(int, long);
-void   mread_f(int, long);
-void   mwrite_f(int, long);
-void   punch_f(int, long);
-void   zero_f(int, long);
-void   collapse_f(int, long);
-void   insert_f(int, long);
-void   read_f(int, long);
-void   readlink_f(int, long);
-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);
-void   setattr_f(int, long);
-void   setfattr_f(int, long);
-void   setxattr_f(int, long);
-void   splice_f(int, long);
-void   stat_f(int, long);
-void   symlink_f(int, long);
-void   sync_f(int, long);
-void   truncate_f(int, long);
-void   unlink_f(int, long);
-void   unresvsp_f(int, long);
-void   write_f(int, long);
-void   writev_f(int, long);
+void   getattr_f(opnum_t, long);
+void   getdents_f(opnum_t, long);
+void   getfattr_f(opnum_t, long);
+void   link_f(opnum_t, long);
+void   listfattr_f(opnum_t, long);
+void   mkdir_f(opnum_t, long);
+void   mknod_f(opnum_t, long);
+void   mread_f(opnum_t, long);
+void   mwrite_f(opnum_t, long);
+void   punch_f(opnum_t, long);
+void   zero_f(opnum_t, long);
+void   collapse_f(opnum_t, long);
+void   insert_f(opnum_t, long);
+void   read_f(opnum_t, long);
+void   readlink_f(opnum_t, long);
+void   readv_f(opnum_t, long);
+void   removefattr_f(opnum_t, long);
+void   rename_f(opnum_t, long);
+void   rnoreplace_f(opnum_t, long);
+void   rexchange_f(opnum_t, long);
+void   rwhiteout_f(opnum_t, long);
+void   resvsp_f(opnum_t, long);
+void   rmdir_f(opnum_t, long);
+void   setattr_f(opnum_t, long);
+void   setfattr_f(opnum_t, long);
+void   setxattr_f(opnum_t, long);
+void   snapshot_f(opnum_t, long);
+void   splice_f(opnum_t, long);
+void   stat_f(opnum_t, long);
+void   subvol_create_f(opnum_t, long);
+void   subvol_delete_f(opnum_t, long);
+void   symlink_f(opnum_t, long);
+void   sync_f(opnum_t, long);
+void   truncate_f(opnum_t, long);
+void   unlink_f(opnum_t, long);
+void   unresvsp_f(opnum_t, long);
+void   uring_read_f(opnum_t, long);
+void   uring_write_f(opnum_t, long);
+void   write_f(opnum_t, long);
+void   writev_f(opnum_t, long);
 char   *xattr_flag_to_string(int);
 
-opdesc_t       ops[] = {
-     /* { OP_ENUM, "name", function, freq, iswrite }, */
-       { OP_AFSYNC, "afsync", afsync_f, 0, 1 },
-       { OP_ALLOCSP, "allocsp", allocsp_f, 1, 1 },
-       { OP_AREAD, "aread", aread_f, 1, 0 },
-       { OP_ATTR_REMOVE, "attr_remove", attr_remove_f, /* 1 */ 0, 1 },
-       { OP_ATTR_SET, "attr_set", attr_set_f, /* 2 */ 0, 1 },
-       { OP_AWRITE, "awrite", awrite_f, 1, 1 },
-       { OP_BULKSTAT, "bulkstat", bulkstat_f, 1, 0 },
-       { OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0 },
-       { OP_CHOWN, "chown", chown_f, 3, 1 },
-       { OP_CLONERANGE, "clonerange", clonerange_f, 4, 1 },
-       { OP_COPYRANGE, "copyrange", copyrange_f, 4, 1 },
-       { OP_CREAT, "creat", creat_f, 4, 1 },
-       { OP_DEDUPERANGE, "deduperange", deduperange_f, 4, 1},
-       { OP_DREAD, "dread", dread_f, 4, 0 },
-       { OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
-       { OP_FALLOCATE, "fallocate", fallocate_f, 1, 1 },
-       { OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
-       { OP_FIEMAP, "fiemap", fiemap_f, 1, 1 },
-       { OP_FREESP, "freesp", freesp_f, 1, 1 },
-       { OP_FSYNC, "fsync", fsync_f, 1, 1 },
-       { OP_GETATTR, "getattr", getattr_f, 1, 0 },
-       { OP_GETDENTS, "getdents", getdents_f, 1, 0 },
+struct opdesc  ops[OP_LAST]    = {
+     /* [OP_ENUM]         = {"name",          function,        freq, iswrite }, */
+       [OP_AFSYNC]        = {"afsync",        afsync_f,        0, 1 },
+       [OP_ALLOCSP]       = {"allocsp",       allocsp_f,       1, 1 },
+       [OP_AREAD]         = {"aread",         aread_f,         1, 0 },
+       [OP_ATTR_REMOVE]   = {"attr_remove",   attr_remove_f,   0, 1 },
+       [OP_ATTR_SET]      = {"attr_set",      attr_set_f,      0, 1 },
+       [OP_AWRITE]        = {"awrite",        awrite_f,        1, 1 },
+       [OP_BULKSTAT]      = {"bulkstat",      bulkstat_f,      1, 0 },
+       [OP_BULKSTAT1]     = {"bulkstat1",     bulkstat1_f,     1, 0 },
+       [OP_CHOWN]         = {"chown",         chown_f,         3, 1 },
+       [OP_CLONERANGE]    = {"clonerange",    clonerange_f,    4, 1 },
+       [OP_COPYRANGE]     = {"copyrange",     copyrange_f,     4, 1 },
+       [OP_CREAT]         = {"creat",         creat_f,         4, 1 },
+       [OP_DEDUPERANGE]   = {"deduperange",   deduperange_f,   4, 1 },
+       [OP_DREAD]         = {"dread",         dread_f,         4, 0 },
+       [OP_DWRITE]        = {"dwrite",        dwrite_f,        4, 1 },
+       [OP_FALLOCATE]     = {"fallocate",     fallocate_f,     1, 1 },
+       [OP_FDATASYNC]     = {"fdatasync",     fdatasync_f,     1, 1 },
+       [OP_FIEMAP]        = {"fiemap",        fiemap_f,        1, 1 },
+       [OP_FREESP]        = {"freesp",        freesp_f,        1, 1 },
+       [OP_FSYNC]         = {"fsync",         fsync_f,         1, 1 },
+       [OP_GETATTR]       = {"getattr",       getattr_f,       1, 0 },
+       [OP_GETDENTS]      = {"getdents",      getdents_f,      1, 0 },
        /* get extended attribute */
-       { OP_GETFATTR, "getfattr", getfattr_f, 1, 0 },
-       { OP_LINK, "link", link_f, 1, 1 },
+       [OP_GETFATTR]      = {"getfattr",      getfattr_f,      1, 0 },
+       [OP_LINK]          = {"link",          link_f,          1, 1 },
        /* list extent attributes */
-       { OP_LISTFATTR, "listfattr", listfattr_f, 1, 0 },
-       { OP_MKDIR, "mkdir", mkdir_f, 2, 1 },
-       { OP_MKNOD, "mknod", mknod_f, 2, 1 },
-       { OP_MREAD, "mread", mread_f, 2, 0 },
-       { OP_MWRITE, "mwrite", mwrite_f, 2, 1 },
-       { OP_PUNCH, "punch", punch_f, 1, 1 },
-       { OP_ZERO, "zero", zero_f, 1, 1 },
-       { OP_COLLAPSE, "collapse", collapse_f, 1, 1 },
-       { OP_INSERT, "insert", insert_f, 1, 1 },
-       { OP_READ, "read", read_f, 1, 0 },
-       { OP_READLINK, "readlink", readlink_f, 1, 0 },
-       { OP_READV, "readv", readv_f, 1, 0 },
+       [OP_LISTFATTR]     = {"listfattr",     listfattr_f,     1, 0 },
+       [OP_MKDIR]         = {"mkdir",         mkdir_f,         2, 1 },
+       [OP_MKNOD]         = {"mknod",         mknod_f,         2, 1 },
+       [OP_MREAD]         = {"mread",         mread_f,         2, 0 },
+       [OP_MWRITE]        = {"mwrite",        mwrite_f,        2, 1 },
+       [OP_PUNCH]         = {"punch",         punch_f,         1, 1 },
+       [OP_ZERO]          = {"zero",          zero_f,          1, 1 },
+       [OP_COLLAPSE]      = {"collapse",      collapse_f,      1, 1 },
+       [OP_INSERT]        = {"insert",        insert_f,        1, 1 },
+       [OP_READ]          = {"read",          read_f,          1, 0 },
+       [OP_READLINK]      = {"readlink",      readlink_f,      1, 0 },
+       [OP_READV]         = {"readv",         readv_f,         1, 0 },
        /* remove (delete) extended attribute */
-       { 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 },
+       [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 },
        /* set attribute flag (FS_IOC_SETFLAGS ioctl) */
-       { OP_SETATTR, "setattr", setattr_f, 0, 1 },
+       [OP_SETATTR]       = {"setattr",       setattr_f,       0, 1 },
        /* set extended attribute */
-       { OP_SETFATTR, "setfattr", setfattr_f, 2, 1 },
+       [OP_SETFATTR]      = {"setfattr",      setfattr_f,      2, 1 },
        /* set project id (XFS_IOC_FSSETXATTR ioctl) */
-       { OP_SETXATTR, "setxattr", setxattr_f, 1, 1 },
-       { OP_SPLICE, "splice", splice_f, 1, 1 },
-       { OP_STAT, "stat", stat_f, 1, 0 },
-       { OP_SYMLINK, "symlink", symlink_f, 2, 1 },
-       { OP_SYNC, "sync", sync_f, 1, 1 },
-       { OP_TRUNCATE, "truncate", truncate_f, 2, 1 },
-       { OP_UNLINK, "unlink", unlink_f, 1, 1 },
-       { OP_UNRESVSP, "unresvsp", unresvsp_f, 1, 1 },
-       { OP_WRITE, "write", write_f, 4, 1 },
-       { OP_WRITEV, "writev", writev_f, 4, 1 },
+       [OP_SETXATTR]      = {"setxattr",      setxattr_f,      1, 1 },
+       [OP_SNAPSHOT]      = {"snapshot",      snapshot_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 },
+       [OP_UNLINK]        = {"unlink",        unlink_f,        1, 1 },
+       [OP_UNRESVSP]      = {"unresvsp",      unresvsp_f,      1, 1 },
+       [OP_URING_READ]    = {"uring_read",    uring_read_f,    1, 0 },
+       [OP_URING_WRITE]   = {"uring_write",   uring_write_f,   1, 1 },
+       [OP_WRITE]         = {"write",         write_f,         4, 1 },
+       [OP_WRITEV]        = {"writev",        writev_f,        4, 1 },
 }, *ops_end;
 
 flist_t        flist[FT_nft] = {
@@ -328,6 +354,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];
@@ -345,7 +372,7 @@ int         namerand;
 int            nameseq;
 int            nops;
 int            nproc = 1;
-int            operations = 1;
+opnum_t                operations = 1;
 unsigned int   idmodulo = XFS_IDMODULO_MAX;
 unsigned int   attr_mask = ~0;
 int            procid;
@@ -363,20 +390,20 @@ struct print_string       flag_str = {0};
 
 void   add_to_flist(int, int, int, int);
 void   append_pathname(pathname_t *, char *);
-int    attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *);
-int    attr_remove_path(pathname_t *, const char *, int);
-int    attr_set_path(pathname_t *, const char *, const char *, const int, int);
+int    attr_list_path(pathname_t *, char *, const int);
+int    attr_remove_path(pathname_t *, const char *);
+int    attr_set_path(pathname_t *, const char *, const char *, const int);
 void   check_cwd(void);
 void   cleanup_flist(void);
 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 *);
+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 *);
@@ -407,6 +434,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)
 {
@@ -499,7 +527,12 @@ int main(int argc, char **argv)
                        loops = atoi(optarg);
                        break;
                case 'n':
-                       operations = atoi(optarg);
+                       errno = 0;
+                       operations = strtoll(optarg, NULL, 0);
+                       if (errno) {
+                               perror(optarg);
+                               exit(1);
+                       }
                        break;
                case 'o':
                        logname = optarg;
@@ -560,6 +593,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))){
@@ -668,10 +702,22 @@ int main(int argc, char **argv)
                        }
                        procid = i;
 #ifdef AIO
-                       if (io_setup(128, &io_ctx) != 0) {
-                               fprintf(stderr, "io_setup failed");
+                       if (io_setup(AIO_ENTRIES, &io_ctx) != 0) {
+                               fprintf(stderr, "io_setup failed\n");
                                exit(1);
                        }
+#endif
+#ifdef URING
+                       have_io_uring = true;
+                       /* If ENOSYS, just ignore uring, other errors are fatal. */
+                       if (io_uring_queue_init(URING_ENTRIES, &ring, 0)) {
+                               if (errno == ENOSYS) {
+                                       have_io_uring = false;
+                               } else {
+                                       fprintf(stderr, "io_uring_queue_init failed\n");
+                                       exit(1);
+                               }
+                       }
 #endif
                        for (i = 0; !loops || (i < loops); i++)
                                doproc();
@@ -681,7 +727,10 @@ int main(int argc, char **argv)
                                return 1;
                        }
 #endif
-
+#ifdef URING
+                       if (have_io_uring)
+                               io_uring_queue_exit(&ring);
+#endif
                        cleanup_flist();
                        free(freq_table);
                        return 0;
@@ -795,6 +844,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;
 }
@@ -819,28 +869,36 @@ append_pathname(pathname_t *name, char *str)
        name->len += len;
 }
 
+int
+attr_list_count(char *buffer, int buffersize)
+{
+       char *p = buffer;
+       char *end = buffer + buffersize;
+       int count = 0;
+
+       while (p < end && *p != 0) {
+               count++;
+               p += strlen(p) + 1;
+       }
+
+       return count;
+}
+
 int
 attr_list_path(pathname_t *name,
               char *buffer,
-              const int buffersize,
-              int flags,
-              attrlist_cursor_t *cursor)
+              const int buffersize)
 {
        char            buf[NAME_MAX + 1];
        pathname_t      newname;
        int             rval;
 
-       if (flags != ATTR_DONTFOLLOW) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       rval = attr_list(name->path, buffer, buffersize, flags, cursor);
+       rval = llistxattr(name->path, buffer, buffersize);
        if (rval >= 0 || errno != ENAMETOOLONG)
                return rval;
        separate_pathname(name, buf, &newname);
        if (chdir(buf) == 0) {
-               rval = attr_list_path(&newname, buffer, buffersize, flags, cursor);
+               rval = attr_list_path(&newname, buffer, buffersize);
                assert(chdir("..") == 0);
        }
        free_pathname(&newname);
@@ -848,18 +906,18 @@ attr_list_path(pathname_t *name,
 }
 
 int
-attr_remove_path(pathname_t *name, const char *attrname, int flags)
+attr_remove_path(pathname_t *name, const char *attrname)
 {
        char            buf[NAME_MAX + 1];
        pathname_t      newname;
        int             rval;
 
-       rval = attr_remove(name->path, attrname, flags);
+       rval = lremovexattr(name->path, attrname);
        if (rval >= 0 || errno != ENAMETOOLONG)
                return rval;
        separate_pathname(name, buf, &newname);
        if (chdir(buf) == 0) {
-               rval = attr_remove_path(&newname, attrname, flags);
+               rval = attr_remove_path(&newname, attrname);
                assert(chdir("..") == 0);
        }
        free_pathname(&newname);
@@ -868,19 +926,19 @@ attr_remove_path(pathname_t *name, const char *attrname, int flags)
 
 int
 attr_set_path(pathname_t *name, const char *attrname, const char *attrvalue,
-             const int valuelength, int flags)
+             const int valuelength)
 {
        char            buf[NAME_MAX + 1];
        pathname_t      newname;
        int             rval;
 
-       rval = attr_set(name->path, attrname, attrvalue, valuelength, flags);
+       rval = lsetxattr(name->path, attrname, attrvalue, valuelength, 0);
        if (rval >= 0 || errno != ENAMETOOLONG)
                return rval;
        separate_pathname(name, buf, &newname);
        if (chdir(buf) == 0) {
-               rval = attr_set_path(&newname, attrname, attrvalue, valuelength,
-                       flags);
+               rval = attr_set_path(&newname, attrname, attrvalue,
+                                    valuelength);
                assert(chdir("..") == 0);
        }
        free_pathname(&newname);
@@ -892,9 +950,22 @@ check_cwd(void)
 {
 #ifdef DEBUG
        struct stat64   statbuf;
+       int ret;
+
+       ret = stat64(".", &statbuf);
+       if (ret != 0) {
+               fprintf(stderr, "fsstress: check_cwd stat64() returned %d with errno: %d (%s)\n",
+                       ret, errno, strerror(errno));
+               goto out;
+       }
 
-       if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
+       if (statbuf.st_ino == top_ino)
                return;
+
+       fprintf(stderr, "fsstress: check_cwd statbuf.st_ino (%llu) != top_ino (%llu)\n",
+               (unsigned long long) statbuf.st_ino,
+               (unsigned long long) top_ino);
+out:
        assert(chdir(homedir) == 0);
        fprintf(stderr, "fsstress: check_cwd failure\n");
        abort();
@@ -962,18 +1033,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;
 }
 
@@ -989,32 +1064,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;
 }
 
@@ -1024,10 +1125,10 @@ doproc(void)
        struct stat64   statbuf;
        char            buf[10];
        char            cmd[64];
-       int             opno;
+       opnum_t         opno;
        int             rval;
        opdesc_t        *p;
-       int             dividend;
+       long long       dividend;
 
        dividend = (operations + execute_freq) / (execute_freq + 1);
        sprintf(buf, "p%x", procid);
@@ -1049,7 +1150,7 @@ doproc(void)
        for (opno = 0; opno < operations; opno++) {
                if (execute_cmd && opno && opno % dividend == 0) {
                        if (verbose)
-                               printf("%d: execute command %s\n", opno,
+                               printf("%lld: execute command %s\n", opno,
                                        execute_cmd);
                        rval = system(execute_cmd);
                        if (rval)
@@ -1091,8 +1192,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;
@@ -1112,7 +1214,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, "/");
@@ -1188,7 +1290,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, "/");
@@ -1270,7 +1372,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:"
@@ -1417,7 +1519,7 @@ make_freq_table(void)
        freq_table_size = f;
        for (p = ops, i = 0; p < ops_end; p++) {
                for (f = 0; f < p->freq; f++, i++)
-                       freq_table[i] = p->op;
+                       freq_table[i] = p - ops;
        }
 }
 
@@ -1710,7 +1812,7 @@ show_ops(int flag, char *lead_str)
                /* Command line style */
                if (lead_str != NULL)
                        printf("%s", lead_str);
-               printf ("-z -s %ld -m %d -n %d -p %d \\\n", seed, idmodulo,
+               printf ("-z -s %ld -m %d -n %lld -p %d \\\n", seed, idmodulo,
                        operations, nproc);
                for (p = ops; p < ops_end; p++)
                        if (p->freq > 0)
@@ -1852,6 +1954,29 @@ zero_freq(void)
                p->freq = 0;
 }
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+opty_t btrfs_ops[] = {
+       OP_SNAPSHOT,
+       OP_SUBVOL_CREATE,
+       OP_SUBVOL_DELETE,
+};
+
+void
+non_btrfs_freq(const char *path)
+{
+       int                     i;
+#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 (i = 0; i < ARRAY_SIZE(btrfs_ops); i++)
+               ops[btrfs_ops[i]].freq = 0;
+}
+
 void inode_info(char *str, size_t sz, struct stat64 *s, int verbose)
 {
        if (verbose)
@@ -1862,7 +1987,7 @@ void inode_info(char *str, size_t sz, struct stat64 *s, int verbose)
 }
 
 void
-afsync_f(int opno, long r)
+afsync_f(opnum_t opno, long r)
 {
 #ifdef AIO
        int             e;
@@ -1876,7 +2001,7 @@ afsync_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: afsync - no filename\n", procid, opno);
+                       printf("%d/%lld: afsync - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -1885,7 +2010,7 @@ afsync_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: afsync - open %s failed %d\n",
+                       printf("%d/%lld: afsync - open %s failed %d\n",
                               procid, opno, f.path, e);
                free_pathname(&f);
                return;
@@ -1894,7 +2019,7 @@ afsync_f(int opno, long r)
        io_prep_fsync(&iocb, fd);
        if ((e = io_submit(io_ctx, 1, iocbs)) != 1) {
                if (v)
-                       printf("%d/%d: afsync - io_submit %s %d\n",
+                       printf("%d/%lld: afsync - io_submit %s %d\n",
                               procid, opno, f.path, e);
                free_pathname(&f);
                close(fd);
@@ -1902,7 +2027,7 @@ afsync_f(int opno, long r)
        }
        if ((e = io_getevents(io_ctx, 1, 1, &event, NULL)) != 1) {
                if (v)
-                       printf("%d/%d: afsync - io_getevents failed %d\n",
+                       printf("%d/%lld: afsync - io_getevents failed %d\n",
                               procid, opno, e);
                free_pathname(&f);
                close(fd);
@@ -1911,14 +2036,14 @@ afsync_f(int opno, long r)
 
        e = event.res2;
        if (v)
-               printf("%d/%d: afsync %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: afsync %s %d\n", procid, opno, f.path, e);
        free_pathname(&f);
        close(fd);
 #endif
 }
 
 void
-allocsp_f(int opno, long r)
+allocsp_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -1933,7 +2058,7 @@ allocsp_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: allocsp - no filename\n", procid, opno);
+                       printf("%d/%lld: allocsp - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -1942,14 +2067,14 @@ allocsp_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: allocsp - open %s failed %d\n",
+                       printf("%d/%lld: allocsp - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: allocsp - fstat64 %s failed %d\n",
+                       printf("%d/%lld: allocsp - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -1964,7 +2089,7 @@ allocsp_f(int opno, long r)
        fl.l_len = 0;
        e = xfsctl(f.path, fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
        if (v) {
-               printf("%d/%d: xfsctl(XFS_IOC_ALLOCSP64) %s%s %lld 0 %d\n",
+               printf("%d/%lld: xfsctl(XFS_IOC_ALLOCSP64) %s%s %lld 0 %d\n",
                       procid, opno, f.path, st, (long long)off, e);
        }
        free_pathname(&f);
@@ -1973,14 +2098,14 @@ allocsp_f(int opno, long r)
 
 #ifdef AIO
 void
-do_aio_rw(int opno, long r, int flags)
+do_aio_rw(opnum_t opno, long r, int flags)
 {
        int64_t         align;
-       char            *buf;
+       char            *buf = NULL;
        struct dioattr  diob;
        int             e;
        pathname_t      f;
-       int             fd;
+       int             fd = -1;
        size_t          len;
        int64_t         lr;
        off64_t         off;
@@ -1996,45 +2121,39 @@ do_aio_rw(int opno, long r, int flags)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: do_aio_rw - no filename\n", procid, opno);
-               free_pathname(&f);
-               return;
+                       printf("%d/%lld: do_aio_rw - no filename\n", procid, opno);
+               goto aio_out;
        }
        fd = open_path(&f, flags|O_DIRECT);
        e = fd < 0 ? errno : 0;
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: do_aio_rw - open %s failed %d\n",
+                       printf("%d/%lld: do_aio_rw - open %s failed %d\n",
                               procid, opno, f.path, e);
-               free_pathname(&f);
-               return;
+               goto aio_out;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: do_aio_rw - fstat64 %s failed %d\n",
+                       printf("%d/%lld: do_aio_rw - fstat64 %s failed %d\n",
                               procid, opno, f.path, errno);
-               free_pathname(&f);
-               close(fd);
-               return;
+               goto aio_out;
        }
        inode_info(st, sizeof(st), &stb, v);
        if (!iswrite && stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: do_aio_rw - %s%s zero size\n", procid, opno,
+                       printf("%d/%lld: do_aio_rw - %s%s zero size\n", procid, opno,
                               f.path, st);
-               free_pathname(&f);
-               close(fd);
-               return;
+               goto aio_out;
        }
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf(
-                       "%d/%d: do_aio_rw - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
+                       "%d/%lld: do_aio_rw - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
                        " fallback to stat()\n",
                                procid, opno, f.path, st, errno);
                diob.d_mem = diob.d_miniosz = stb.st_blksize;
-               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+               diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
        }
        dio_env = getenv("XFS_DIO_MIN");
        if (dio_env)
@@ -2048,6 +2167,12 @@ do_aio_rw(int opno, long r, int flags)
        else if (len > diob.d_maxiosz)
                len = diob.d_maxiosz;
        buf = memalign(diob.d_mem, len);
+       if (!buf) {
+               if (v)
+                       printf("%d/%lld: do_aio_rw - memalign failed\n",
+                              procid, opno);
+               goto aio_out;
+       }
 
        if (iswrite) {
                off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
@@ -2062,34 +2187,138 @@ do_aio_rw(int opno, long r, int flags)
        }
        if ((e = io_submit(io_ctx, 1, iocbs)) != 1) {
                if (v)
-                       printf("%d/%d: %s - io_submit failed %d\n",
+                       printf("%d/%lld: %s - io_submit failed %d\n",
                               procid, opno, iswrite ? "awrite" : "aread", e);
-               free_pathname(&f);
-               close(fd);
-               return;
+               goto aio_out;
        }
        if ((e = io_getevents(io_ctx, 1, 1, &event, NULL)) != 1) {
                if (v)
-                       printf("%d/%d: %s - io_getevents failed %d\n",
+                       printf("%d/%lld: %s - io_getevents failed %d\n",
                               procid, opno, iswrite ? "awrite" : "aread", e);
-               free_pathname(&f);
-               close(fd);
-               return;
+               goto aio_out;
        }
 
        e = event.res != len ? event.res2 : 0;
-       free(buf);
        if (v)
-               printf("%d/%d: %s %s%s [%lld,%d] %d\n",
+               printf("%d/%lld: %s %s%s [%lld,%d] %d\n",
                       procid, opno, iswrite ? "awrite" : "aread",
                       f.path, st, (long long)off, (int)len, e);
+ aio_out:
+       if (buf)
+               free(buf);
+       if (fd != -1)
+               close(fd);
+       free_pathname(&f);
+}
+#endif
+
+#ifdef URING
+void
+do_uring_rw(opnum_t opno, long r, int flags)
+{
+       char            *buf = NULL;
+       int             e;
+       pathname_t      f;
+       int             fd = -1;
+       size_t          len;
+       int64_t         lr;
+       off64_t         off;
+       struct stat64   stb;
+       int             v;
+       char            st[1024];
+       struct io_uring_sqe     *sqe;
+       struct io_uring_cqe     *cqe;
+       struct iovec    iovec;
+       int             iswrite = (flags & (O_WRONLY | O_RDWR)) ? 1 : 0;
+
+       if (!have_io_uring)
+               return;
+
+       init_pathname(&f);
+       if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - no filename\n", procid, opno);
+               goto uring_out;
+       }
+       fd = open_path(&f, flags);
+       e = fd < 0 ? errno : 0;
+       check_cwd();
+       if (fd < 0) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - open %s failed %d\n",
+                              procid, opno, f.path, e);
+               goto uring_out;
+       }
+       if (fstat64(fd, &stb) < 0) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - fstat64 %s failed %d\n",
+                              procid, opno, f.path, errno);
+               goto uring_out;
+       }
+       inode_info(st, sizeof(st), &stb, v);
+       if (!iswrite && stb.st_size == 0) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - %s%s zero size\n", procid, opno,
+                              f.path, st);
+               goto uring_out;
+       }
+       sqe = io_uring_get_sqe(&ring);
+       if (!sqe) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - io_uring_get_sqe failed\n",
+                              procid, opno);
+               goto uring_out;
+       }
+       lr = ((int64_t)random() << 32) + random();
+       len = (random() % FILELEN_MAX) + 1;
+       buf = malloc(len);
+       if (!buf) {
+               if (v)
+                       printf("%d/%lld: do_uring_rw - malloc failed\n",
+                              procid, opno);
+               goto uring_out;
+       }
+       iovec.iov_base = buf;
+       iovec.iov_len = len;
+       if (iswrite) {
+               off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
+               off %= maxfsize;
+               memset(buf, nameseq & 0xff, len);
+               io_uring_prep_writev(sqe, fd, &iovec, 1, off);
+       } else {
+               off = (off64_t)(lr % stb.st_size);
+               io_uring_prep_readv(sqe, fd, &iovec, 1, off);
+       }
+
+       if ((e = io_uring_submit_and_wait(&ring, 1)) != 1) {
+               if (v)
+                       printf("%d/%lld: %s - io_uring_submit failed %d\n", procid, opno,
+                              iswrite ? "uring_write" : "uring_read", e);
+               goto uring_out;
+       }
+       if ((e = io_uring_wait_cqe(&ring, &cqe)) < 0) {
+               if (v)
+                       printf("%d/%lld: %s - io_uring_wait_cqe failed %d\n", procid, opno,
+                              iswrite ? "uring_write" : "uring_read", e);
+               goto uring_out;
+       }
+       if (v)
+               printf("%d/%lld: %s %s%s [%lld, %d(res=%d)] %d\n",
+                      procid, opno, iswrite ? "uring_write" : "uring_read",
+                      f.path, st, (long long)off, (int)len, cqe->res, e);
+       io_uring_cqe_seen(&ring, cqe);
+
+ uring_out:
+       if (buf)
+               free(buf);
+       if (fd != -1)
+               close(fd);
        free_pathname(&f);
-       close(fd);
 }
 #endif
 
 void
-aread_f(int opno, long r)
+aread_f(opnum_t opno, long r)
 {
 #ifdef AIO
        do_aio_rw(opno, r, O_RDONLY);
@@ -2097,78 +2326,67 @@ aread_f(int opno, long r)
 }
 
 void
-attr_remove_f(int opno, long r)
+attr_remove_f(opnum_t opno, long r)
 {
-       attrlist_ent_t          *aep;
-       attrlist_t              *alist;
-       char                    *aname;
-       char                    buf[4096];
-       attrlist_cursor_t       cursor;
+       char                    *bufname;
+       char                    *bufend;
+       char                    *aname = NULL;
+       char                    buf[XATTR_LIST_MAX];
        int                     e;
        int                     ent;
        pathname_t              f;
-       int                     total;
+       int                     total = 0;
        int                     v;
        int                     which;
 
        init_pathname(&f);
        if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
                append_pathname(&f, ".");
-       total = 0;
-       bzero(&cursor, sizeof(cursor));
-       do {
-               bzero(buf, sizeof(buf));
-               e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor);
-               check_cwd();
-               if (e)
-                       break;
-               alist = (attrlist_t *)buf;
-               total += alist->al_count;
-       } while (alist->al_more);
+       e = attr_list_path(&f, buf, sizeof(buf));
+       check_cwd();
+       if (e > 0)
+               total = attr_list_count(buf, e);
        if (total == 0) {
                if (v)
-                       printf("%d/%d: attr_remove - no attrs for %s\n",
+                       printf("%d/%lld: attr_remove - no attrs for %s\n",
                                procid, opno, f.path);
                free_pathname(&f);
                return;
        }
+
        which = (int)(random() % total);
-       bzero(&cursor, sizeof(cursor));
+       bufname = buf;
+       bufend = buf + e;
        ent = 0;
-       aname = NULL;
-       do {
-               bzero(buf, sizeof(buf));
-               e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor);
-               check_cwd();
-               if (e)
-                       break;
-               alist = (attrlist_t *)buf;
-               if (which < ent + alist->al_count) {
-                       aep = (attrlist_ent_t *)
-                               &buf[alist->al_offset[which - ent]];
-                       aname = aep->a_name;
+       while (bufname < bufend) {
+               if (which < ent) {
+                       aname = bufname;
                        break;
                }
-               ent += alist->al_count;
-       } while (alist->al_more);
+               ent++;
+               bufname += strlen(bufname) + 1;
+       }
        if (aname == NULL) {
                if (v)
                        printf(
-                       "%d/%d: attr_remove - name %d not found at %s\n",
+                       "%d/%lld: attr_remove - name %d not found at %s\n",
                                procid, opno, which, f.path);
                free_pathname(&f);
                return;
        }
-       e = attr_remove_path(&f, aname, ATTR_DONTFOLLOW) < 0 ? errno : 0;
+       if (attr_remove_path(&f, aname) < 0)
+               e = errno;
+       else
+               e = 0;
        check_cwd();
        if (v)
-               printf("%d/%d: attr_remove %s %s %d\n",
+               printf("%d/%lld: attr_remove %s %s %d\n",
                        procid, opno, f.path, aname, e);
        free_pathname(&f);
 }
 
 void
-attr_set_f(int opno, long r)
+attr_set_f(opnum_t opno, long r)
 {
        char            aname[10];
        char            *aval;
@@ -2189,18 +2407,20 @@ attr_set_f(int opno, long r)
                len = 1;
        aval = malloc(len);
        memset(aval, nameseq & 0xff, len);
-       e = attr_set_path(&f, aname, aval, len, ATTR_DONTFOLLOW) < 0 ?
-               errno : 0;
+       if (attr_set_path(&f, aname, aval, len) < 0)
+               e = errno;
+       else
+               e = 0;
        check_cwd();
        free(aval);
        if (v)
-               printf("%d/%d: attr_set %s %s %d\n", procid, opno, f.path,
+               printf("%d/%lld: attr_set %s %s %d\n", procid, opno, f.path,
                        aname, e);
        free_pathname(&f);
 }
 
 void
-awrite_f(int opno, long r)
+awrite_f(opnum_t opno, long r)
 {
 #ifdef AIO
        do_aio_rw(opno, r, O_WRONLY);
@@ -2208,7 +2428,7 @@ awrite_f(int opno, long r)
 }
 
 void
-bulkstat_f(int opno, long r)
+bulkstat_f(opnum_t opno, long r)
 {
        int             count;
        int             fd;
@@ -2233,13 +2453,13 @@ bulkstat_f(int opno, long r)
                total += count;
        free(t);
        if (verbose)
-               printf("%d/%d: bulkstat nent %d total %lld\n",
+               printf("%d/%lld: bulkstat nent %d total %lld\n",
                        procid, opno, nent, (long long)total);
        close(fd);
 }
 
 void
-bulkstat1_f(int opno, long r)
+bulkstat1_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -2287,14 +2507,14 @@ bulkstat1_f(int opno, long r)
         bsr.ocount=NULL;
        e = xfsctl(".", fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: bulkstat1 %s ino %lld %d\n", 
+               printf("%d/%lld: bulkstat1 %s ino %lld %d\n",
                       procid, opno, good?"real":"random",
                       verifiable_log ? -1LL : (long long)ino, e);
        close(fd);
 }
 
 void
-chown_f(int opno, long r)
+chown_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -2314,14 +2534,14 @@ chown_f(int opno, long r)
        e = lchown_path(&f, u, g) < 0 ? errno : 0;
        check_cwd();
        if (v)
-               printf("%d/%d: chown %s %d/%d %d\n", procid, opno, f.path, (int)u, (int)g, e);
+               printf("%d/%lld: chown %s %d/%d %d\n", procid, opno, f.path, (int)u, (int)g, e);
        free_pathname(&f);
 }
 
 /* reflink some arbitrary range of f1 to f2. */
 void
 clonerange_f(
-       int                     opno,
+       opnum_t                 opno,
        long                    r)
 {
 #ifdef FICLONERANGE
@@ -2348,7 +2568,7 @@ clonerange_f(
        init_pathname(&fpath1);
        if (!get_fname(FT_REGm, r, &fpath1, NULL, NULL, &v1)) {
                if (v1)
-                       printf("%d/%d: clonerange read - no filename\n",
+                       printf("%d/%lld: clonerange read - no filename\n",
                                procid, opno);
                goto out_fpath1;
        }
@@ -2356,7 +2576,7 @@ clonerange_f(
        init_pathname(&fpath2);
        if (!get_fname(FT_REGm, random(), &fpath2, NULL, NULL, &v2)) {
                if (v2)
-                       printf("%d/%d: clonerange write - no filename\n",
+                       printf("%d/%lld: clonerange write - no filename\n",
                                procid, opno);
                goto out_fpath2;
        }
@@ -2367,7 +2587,7 @@ clonerange_f(
        check_cwd();
        if (fd1 < 0) {
                if (v1)
-                       printf("%d/%d: clonerange read - open %s failed %d\n",
+                       printf("%d/%lld: clonerange read - open %s failed %d\n",
                                procid, opno, fpath1.path, e);
                goto out_fpath2;
        }
@@ -2377,7 +2597,7 @@ clonerange_f(
        check_cwd();
        if (fd2 < 0) {
                if (v2)
-                       printf("%d/%d: clonerange write - open %s failed %d\n",
+                       printf("%d/%lld: clonerange write - open %s failed %d\n",
                                procid, opno, fpath2.path, e);
                goto out_fd1;
        }
@@ -2385,7 +2605,7 @@ clonerange_f(
        /* Get file stats */
        if (fstat64(fd1, &stat1) < 0) {
                if (v1)
-                       printf("%d/%d: clonerange read - fstat64 %s failed %d\n",
+                       printf("%d/%lld: clonerange read - fstat64 %s failed %d\n",
                                procid, opno, fpath1.path, errno);
                goto out_fd2;
        }
@@ -2393,7 +2613,7 @@ clonerange_f(
 
        if (fstat64(fd2, &stat2) < 0) {
                if (v2)
-                       printf("%d/%d: clonerange write - fstat64 %s failed %d\n",
+                       printf("%d/%lld: clonerange write - fstat64 %s failed %d\n",
                                procid, opno, fpath2.path, errno);
                goto out_fd2;
        }
@@ -2401,7 +2621,7 @@ clonerange_f(
 
        /* Calculate offsets */
        len = (random() % FILELEN_MAX) + 1;
-       len &= ~(stat1.st_blksize - 1);
+       len = rounddown_64(len, stat1.st_blksize);
        if (len == 0)
                len = stat1.st_blksize;
        if (len > stat1.st_size)
@@ -2413,7 +2633,7 @@ clonerange_f(
        else
                off1 = (off64_t)(lr % MIN(stat1.st_size - len, MAXFSIZE));
        off1 %= maxfsize;
-       off1 &= ~(stat1.st_blksize - 1);
+       off1 = rounddown_64(off1, stat1.st_blksize);
 
        /*
         * If srcfile == destfile, randomly generate destination ranges
@@ -2424,7 +2644,7 @@ clonerange_f(
                lr = ((int64_t)random() << 32) + random();
                off2 = (off64_t)(lr % max_off2);
                off2 %= maxfsize;
-               off2 &= ~(stat2.st_blksize - 1);
+               off2 = rounddown_64(off2, stat2.st_blksize);
        } while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len);
 
        /* Clone data blocks */
@@ -2436,7 +2656,7 @@ clonerange_f(
        ret = ioctl(fd2, FICLONERANGE, &fcr);
        e = ret < 0 ? errno : 0;
        if (v1 || v2) {
-               printf("%d/%d: clonerange %s%s [%lld,%lld] -> %s%s [%lld,%lld]",
+               printf("%d/%lld: clonerange %s%s [%lld,%lld] -> %s%s [%lld,%lld]",
                        procid, opno,
                        fpath1.path, inoinfo1, (long long)off1, (long long)len,
                        fpath2.path, inoinfo2, (long long)off2, (long long)len);
@@ -2460,7 +2680,7 @@ out_fpath1:
 /* copy some arbitrary range of f1 to f2. */
 void
 copyrange_f(
-       int                     opno,
+       opnum_t                 opno,
        long                    r)
 {
 #ifdef HAVE_COPY_FILE_RANGE
@@ -2490,7 +2710,7 @@ copyrange_f(
        init_pathname(&fpath1);
        if (!get_fname(FT_REGm, r, &fpath1, NULL, NULL, &v1)) {
                if (v1)
-                       printf("%d/%d: copyrange read - no filename\n",
+                       printf("%d/%lld: copyrange read - no filename\n",
                                procid, opno);
                goto out_fpath1;
        }
@@ -2498,7 +2718,7 @@ copyrange_f(
        init_pathname(&fpath2);
        if (!get_fname(FT_REGm, random(), &fpath2, NULL, NULL, &v2)) {
                if (v2)
-                       printf("%d/%d: copyrange write - no filename\n",
+                       printf("%d/%lld: copyrange write - no filename\n",
                                procid, opno);
                goto out_fpath2;
        }
@@ -2509,7 +2729,7 @@ copyrange_f(
        check_cwd();
        if (fd1 < 0) {
                if (v1)
-                       printf("%d/%d: copyrange read - open %s failed %d\n",
+                       printf("%d/%lld: copyrange read - open %s failed %d\n",
                                procid, opno, fpath1.path, e);
                goto out_fpath2;
        }
@@ -2519,7 +2739,7 @@ copyrange_f(
        check_cwd();
        if (fd2 < 0) {
                if (v2)
-                       printf("%d/%d: copyrange write - open %s failed %d\n",
+                       printf("%d/%lld: copyrange write - open %s failed %d\n",
                                procid, opno, fpath2.path, e);
                goto out_fd1;
        }
@@ -2527,7 +2747,7 @@ copyrange_f(
        /* Get file stats */
        if (fstat64(fd1, &stat1) < 0) {
                if (v1)
-                       printf("%d/%d: copyrange read - fstat64 %s failed %d\n",
+                       printf("%d/%lld: copyrange read - fstat64 %s failed %d\n",
                                procid, opno, fpath1.path, errno);
                goto out_fd2;
        }
@@ -2535,7 +2755,7 @@ copyrange_f(
 
        if (fstat64(fd2, &stat2) < 0) {
                if (v2)
-                       printf("%d/%d: copyrange write - fstat64 %s failed %d\n",
+                       printf("%d/%lld: copyrange write - fstat64 %s failed %d\n",
                                procid, opno, fpath2.path, errno);
                goto out_fd2;
        }
@@ -2587,7 +2807,7 @@ copyrange_f(
        }
        e = ret < 0 ? errno : 0;
        if (v1 || v2) {
-               printf("%d/%d: copyrange %s%s [%lld,%lld] -> %s%s [%lld,%lld]",
+               printf("%d/%lld: copyrange %s%s [%lld,%lld] -> %s%s [%lld,%lld]",
                        procid, opno,
                        fpath1.path, inoinfo1,
                        (long long)offset1, (long long)length,
@@ -2616,7 +2836,7 @@ out_fpath1:
 /* dedupe some arbitrary range of f1 to f2...fn. */
 void
 deduperange_f(
-       int                     opno,
+       opnum_t                 opno,
        long                    r)
 {
 #ifdef FIDEDUPERANGE
@@ -2647,7 +2867,7 @@ deduperange_f(
        fdr = malloc(nr * sizeof(struct file_dedupe_range_info) +
                     sizeof(struct file_dedupe_range));
        if (!fdr) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                return;
        }
@@ -2656,41 +2876,41 @@ deduperange_f(
 
        fpath = calloc(nr, sizeof(struct pathname));
        if (!fpath) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_fdr;
        }
 
        stat = calloc(nr, sizeof(struct stat64));
        if (!stat) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_paths;
        }
 
        info = calloc(nr, INFO_SZ);
        if (!info) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_stats;
        }
 
        off = calloc(nr, sizeof(off64_t));
        if (!off) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_info;
        }
 
        v = calloc(nr, sizeof(int));
        if (!v) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_offsets;
        }
        fd = calloc(nr, sizeof(int));
        if (!fd) {
-               printf("%d/%d: line %d error %d\n",
+               printf("%d/%lld: line %d error %d\n",
                        procid, opno, __LINE__, errno);
                goto out_v;
        }
@@ -2702,7 +2922,7 @@ deduperange_f(
 
        if (!get_fname(FT_REGm, r, &fpath[0], NULL, NULL, &v[0])) {
                if (v[0])
-                       printf("%d/%d: deduperange read - no filename\n",
+                       printf("%d/%lld: deduperange read - no filename\n",
                                procid, opno);
                goto out_pathnames;
        }
@@ -2710,7 +2930,7 @@ deduperange_f(
        for (i = 1; i < nr; i++) {
                if (!get_fname(FT_REGm, random(), &fpath[i], NULL, NULL, &v[i])) {
                        if (v[i])
-                               printf("%d/%d: deduperange write - no filename\n",
+                               printf("%d/%lld: deduperange write - no filename\n",
                                        procid, opno);
                        goto out_pathnames;
                }
@@ -2722,7 +2942,7 @@ deduperange_f(
        check_cwd();
        if (fd[0] < 0) {
                if (v[0])
-                       printf("%d/%d: deduperange read - open %s failed %d\n",
+                       printf("%d/%lld: deduperange read - open %s failed %d\n",
                                procid, opno, fpath[0].path, e);
                goto out_pathnames;
        }
@@ -2733,7 +2953,7 @@ deduperange_f(
                check_cwd();
                if (fd[i] < 0) {
                        if (v[i])
-                               printf("%d/%d: deduperange write - open %s failed %d\n",
+                               printf("%d/%lld: deduperange write - open %s failed %d\n",
                                        procid, opno, fpath[i].path, e);
                        goto out_fds;
                }
@@ -2742,7 +2962,7 @@ deduperange_f(
        /* Get file stats */
        if (fstat64(fd[0], &stat[0]) < 0) {
                if (v[0])
-                       printf("%d/%d: deduperange read - fstat64 %s failed %d\n",
+                       printf("%d/%lld: deduperange read - fstat64 %s failed %d\n",
                                procid, opno, fpath[0].path, errno);
                goto out_fds;
        }
@@ -2752,7 +2972,7 @@ deduperange_f(
        for (i = 1; i < nr; i++) {
                if (fstat64(fd[i], &stat[i]) < 0) {
                        if (v[i])
-                               printf("%d/%d: deduperange write - fstat64 %s failed %d\n",
+                               printf("%d/%lld: deduperange write - fstat64 %s failed %d\n",
                                        procid, opno, fpath[i].path, errno);
                        goto out_fds;
                }
@@ -2761,7 +2981,7 @@ deduperange_f(
 
        /* Never try to dedupe more than half of the src file. */
        len = (random() % FILELEN_MAX) + 1;
-       len &= ~(stat[0].st_blksize - 1);
+       len = rounddown_64(len, stat[0].st_blksize);
        if (len == 0)
                len = stat[0].st_blksize / 2;
        if (len > stat[0].st_size / 2)
@@ -2774,7 +2994,7 @@ deduperange_f(
        else
                off[0] = (off64_t)(lr % MIN(stat[0].st_size - len, MAXFSIZE));
        off[0] %= maxfsize;
-       off[0] &= ~(stat[0].st_blksize - 1);
+       off[0] = rounddown_64(off[0], stat[0].st_blksize);
 
        /*
         * If srcfile == destfile[i], randomly generate destination ranges
@@ -2790,7 +3010,7 @@ deduperange_f(
                        else
                                off[i] = (off64_t)(lr % MIN(stat[i].st_size - len, MAXFSIZE));
                        off[i] %= maxfsize;
-                       off[i] &= ~(stat[i].st_blksize - 1);
+                       off[i] = rounddown_64(off[i], stat[i].st_blksize);
                } while (stat[0].st_ino == stat[i].st_ino &&
                         llabs(off[i] - off[0]) < len &&
                         tries++ < 10);
@@ -2808,7 +3028,7 @@ deduperange_f(
        ret = ioctl(fd[0], FIDEDUPERANGE, fdr);
        e = ret < 0 ? errno : 0;
        if (v[0]) {
-               printf("%d/%d: deduperange from %s%s [%lld,%lld]",
+               printf("%d/%lld: deduperange from %s%s [%lld,%lld]",
                        procid, opno,
                        fpath[0].path, &info[0], (long long)off[0],
                        (long long)len);
@@ -2822,7 +3042,7 @@ deduperange_f(
        for (i = 1; i < nr; i++) {
                e = fdr->info[i - 1].status < 0 ? fdr->info[i - 1].status : 0;
                if (v[i]) {
-                       printf("%d/%d: ...to %s%s [%lld,%lld]",
+                       printf("%d/%lld: ...to %s%s [%lld,%lld]",
                                procid, opno,
                                fpath[i].path, &info[i * INFO_SZ],
                                (long long)off[i], (long long)len);
@@ -2862,7 +3082,7 @@ out_fdr:
 }
 
 void
-setxattr_f(int opno, long r)
+setxattr_f(opnum_t opno, long r)
 {
 #ifdef XFS_XFLAG_EXTSIZE
        struct fsxattr  fsx;
@@ -2891,14 +3111,14 @@ setxattr_f(int opno, long r)
                e = xfsctl(f.path, fd, XFS_IOC_FSSETXATTR, &fsx);
        }
        if (v)
-               printf("%d/%d: setxattr %s %u %d\n", procid, opno, f.path, p, e);
+               printf("%d/%lld: setxattr %s %u %d\n", procid, opno, f.path, p, e);
        free_pathname(&f);
        close(fd);
 #endif
 }
 
 void
-splice_f(int opno, long r)
+splice_f(opnum_t opno, long r)
 {
        struct pathname         fpath1;
        struct pathname         fpath2;
@@ -2925,7 +3145,7 @@ splice_f(int opno, long r)
        init_pathname(&fpath1);
        if (!get_fname(FT_REGm, r, &fpath1, NULL, NULL, &v1)) {
                if (v1)
-                       printf("%d/%d: splice read - no filename\n",
+                       printf("%d/%lld: splice read - no filename\n",
                                procid, opno);
                goto out_fpath1;
        }
@@ -2933,7 +3153,7 @@ splice_f(int opno, long r)
        init_pathname(&fpath2);
        if (!get_fname(FT_REGm, random(), &fpath2, NULL, NULL, &v2)) {
                if (v2)
-                       printf("%d/%d: splice write - no filename\n",
+                       printf("%d/%lld: splice write - no filename\n",
                                procid, opno);
                goto out_fpath2;
        }
@@ -2944,7 +3164,7 @@ splice_f(int opno, long r)
        check_cwd();
        if (fd1 < 0) {
                if (v1)
-                       printf("%d/%d: splice read - open %s failed %d\n",
+                       printf("%d/%lld: splice read - open %s failed %d\n",
                                procid, opno, fpath1.path, e);
                goto out_fpath2;
        }
@@ -2954,7 +3174,7 @@ splice_f(int opno, long r)
        check_cwd();
        if (fd2 < 0) {
                if (v2)
-                       printf("%d/%d: splice write - open %s failed %d\n",
+                       printf("%d/%lld: splice write - open %s failed %d\n",
                                procid, opno, fpath2.path, e);
                goto out_fd1;
        }
@@ -2962,7 +3182,7 @@ splice_f(int opno, long r)
        /* Get file stats */
        if (fstat64(fd1, &stat1) < 0) {
                if (v1)
-                       printf("%d/%d: splice read - fstat64 %s failed %d\n",
+                       printf("%d/%lld: splice read - fstat64 %s failed %d\n",
                                procid, opno, fpath1.path, errno);
                goto out_fd2;
        }
@@ -2970,7 +3190,7 @@ splice_f(int opno, long r)
 
        if (fstat64(fd2, &stat2) < 0) {
                if (v2)
-                       printf("%d/%d: splice write - fstat64 %s failed %d\n",
+                       printf("%d/%lld: splice write - fstat64 %s failed %d\n",
                                procid, opno, fpath2.path, errno);
                goto out_fd2;
        }
@@ -3009,7 +3229,7 @@ splice_f(int opno, long r)
        /* Pipe initialize */
        if (pipe(filedes) < 0) {
                if (v1 || v2) {
-                       printf("%d/%d: splice - pipe failed %d\n",
+                       printf("%d/%lld: splice - pipe failed %d\n",
                                procid, opno, errno);
                        goto out_fd2;
                }
@@ -3045,7 +3265,7 @@ splice_f(int opno, long r)
        else
                e = 0;
        if (v1 || v2) {
-               printf("%d/%d: splice %s%s [%lld,%lld] -> %s%s [%lld,%lld] %d",
+               printf("%d/%lld: splice %s%s [%lld,%lld] -> %s%s [%lld,%lld] %d",
                        procid, opno,
                        fpath1.path, inoinfo1, (long long)offset1, (long long)length,
                        fpath2.path, inoinfo2, (long long)offset2, (long long)length, e);
@@ -3069,7 +3289,7 @@ out_fpath1:
 }
 
 void
-creat_f(int opno, long r)
+creat_f(opnum_t opno, long r)
 {
        struct fsxattr  a;
        int             e;
@@ -3084,7 +3304,7 @@ creat_f(int opno, long r)
        int             v;
        int             v1;
 
-       if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v1))
+       if (!get_fname(FT_ANYDIR, r, NULL, NULL, &fep, &v1))
                parid = -1;
        else
                parid = fep->id;
@@ -3103,8 +3323,8 @@ creat_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
-                       printf("%d/%d: creat - no filename from %s\n",
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%lld: creat - no filename from %s\n",
                                procid, opno, f.path);
                }
                free_pathname(&f);
@@ -3134,15 +3354,15 @@ creat_f(int opno, long r)
                close(fd);
        }
        if (v) {
-               printf("%d/%d: creat %s x:%d %d %d\n", procid, opno, f.path,
+               printf("%d/%lld: creat %s x:%d %d %d\n", procid, opno, f.path,
                        extsize ? a.fsx_extsize : 0, e, e1);
-               printf("%d/%d: creat add id=%d,parent=%d\n", procid, opno, id, parid);
+               printf("%d/%lld: creat add id=%d,parent=%d\n", procid, opno, id, parid);
        }
        free_pathname(&f);
 }
 
 void
-dread_f(int opno, long r)
+dread_f(opnum_t opno, long r)
 {
        int64_t         align;
        char            *buf;
@@ -3161,7 +3381,7 @@ dread_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: dread - no filename\n", procid, opno);
+                       printf("%d/%lld: dread - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3170,14 +3390,14 @@ dread_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: dread - open %s failed %d\n",
+                       printf("%d/%lld: dread - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: dread - fstat64 %s failed %d\n",
+                       printf("%d/%lld: dread - fstat64 %s failed %d\n",
                               procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3186,7 +3406,7 @@ dread_f(int opno, long r)
        inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: dread - %s%s zero size\n", procid, opno,
+                       printf("%d/%lld: dread - %s%s zero size\n", procid, opno,
                               f.path, st);
                free_pathname(&f);
                close(fd);
@@ -3195,11 +3415,11 @@ dread_f(int opno, long r)
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf(
-                       "%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
+                       "%d/%lld: dread - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
                        " fallback to stat()\n",
                                procid, opno, f.path, st, errno);
                diob.d_mem = diob.d_miniosz = stb.st_blksize;
-               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+               diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
        }
 
        dio_env = getenv("XFS_DIO_MIN");
@@ -3221,14 +3441,14 @@ dread_f(int opno, long r)
        e = read(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: dread %s%s [%lld,%d] %d\n",
+               printf("%d/%lld: dread %s%s [%lld,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-dwrite_f(int opno, long r)
+dwrite_f(opnum_t opno, long r)
 {
        int64_t         align;
        char            *buf;
@@ -3247,7 +3467,7 @@ dwrite_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: dwrite - no filename\n", procid, opno);
+                       printf("%d/%lld: dwrite - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3256,14 +3476,14 @@ dwrite_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: dwrite - open %s failed %d\n",
+                       printf("%d/%lld: dwrite - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: dwrite - fstat64 %s failed %d\n",
+                       printf("%d/%lld: dwrite - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3272,11 +3492,11 @@ dwrite_f(int opno, long r)
        inode_info(st, sizeof(st), &stb, v);
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
-                       printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
+                       printf("%d/%lld: dwrite - xfsctl(XFS_IOC_DIOINFO)"
                                " %s%s return %d, fallback to stat()\n",
                               procid, opno, f.path, st, errno);
                diob.d_mem = diob.d_miniosz = stb.st_blksize;
-               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
+               diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz);
        }
 
        dio_env = getenv("XFS_DIO_MIN");
@@ -3301,7 +3521,7 @@ dwrite_f(int opno, long r)
        e = write(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: dwrite %s%s [%lld,%d] %d\n",
+               printf("%d/%lld: dwrite %s%s [%lld,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
@@ -3324,7 +3544,7 @@ struct print_flags falloc_flags [] = {
 #endif
 
 void
-do_fallocate(int opno, long r, int mode)
+do_fallocate(opnum_t opno, long r, int mode)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        int             e;
@@ -3340,14 +3560,14 @@ do_fallocate(int opno, long r, int mode)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: do_fallocate - no filename\n", procid, opno);
+                       printf("%d/%lld: do_fallocate - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
        fd = open_path(&f, O_RDWR);
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: do_fallocate - open %s failed %d\n",
+                       printf("%d/%lld: do_fallocate - open %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                return;
@@ -3355,7 +3575,7 @@ do_fallocate(int opno, long r, int mode)
        check_cwd();
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: do_fallocate - fstat64 %s failed %d\n",
+                       printf("%d/%lld: do_fallocate - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3372,13 +3592,13 @@ do_fallocate(int opno, long r, int mode)
         */
        if ((mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)) &&
                (opno % 2)) {
-               off = ((off + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
-               len = ((len + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
+               off = roundup_64(off, stb.st_blksize);
+               len = roundup_64(len, stb.st_blksize);
        }
        mode |= FALLOC_FL_KEEP_SIZE & random();
        e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: fallocate(%s) %s %st %lld %lld %d\n",
+               printf("%d/%lld: fallocate(%s) %s %st %lld %lld %d\n",
                       procid, opno, translate_falloc_flags(mode),
                       f.path, st, (long long)off, (long long)len, e);
        free_pathname(&f);
@@ -3387,7 +3607,7 @@ do_fallocate(int opno, long r, int mode)
 }
 
 void
-fallocate_f(int opno, long r)
+fallocate_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        do_fallocate(opno, r, 0);
@@ -3395,7 +3615,7 @@ fallocate_f(int opno, long r)
 }
 
 void
-fdatasync_f(int opno, long r)
+fdatasync_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3405,7 +3625,7 @@ fdatasync_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: fdatasync - no filename\n",
+                       printf("%d/%lld: fdatasync - no filename\n",
                                procid, opno);
                free_pathname(&f);
                return;
@@ -3415,14 +3635,14 @@ fdatasync_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: fdatasync - open %s failed %d\n",
+                       printf("%d/%lld: fdatasync - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        e = fdatasync(fd) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: fdatasync %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: fdatasync %s %d\n", procid, opno, f.path, e);
        free_pathname(&f);
        close(fd);
 }
@@ -3439,7 +3659,7 @@ struct print_flags fiemap_flags[] = {
 #endif
 
 void
-fiemap_f(int opno, long r)
+fiemap_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FIEMAP_H
        int             e;
@@ -3456,7 +3676,7 @@ fiemap_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: fiemap - no filename\n", procid, opno);
+                       printf("%d/%lld: fiemap - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3465,14 +3685,14 @@ fiemap_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: fiemap - open %s failed %d\n",
+                       printf("%d/%lld: fiemap - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: fiemap - fstat64 %s failed %d\n",
+                       printf("%d/%lld: fiemap - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3484,7 +3704,7 @@ fiemap_f(int opno, long r)
                        (blocks_to_map * sizeof(struct fiemap_extent)));
        if (!fiemap) {
                if (v)
-                       printf("%d/%d: malloc failed \n", procid, opno);
+                       printf("%d/%lld: malloc failed \n", procid, opno);
                free_pathname(&f);
                close(fd);
                return;
@@ -3500,7 +3720,7 @@ fiemap_f(int opno, long r)
 
        e = ioctl(fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
        if (v)
-               printf("%d/%d: ioctl(FIEMAP) %s%s %lld %lld (%s) %d\n",
+               printf("%d/%lld: ioctl(FIEMAP) %s%s %lld %lld (%s) %d\n",
                       procid, opno, f.path, st, (long long)fiemap->fm_start,
                       (long long) fiemap->fm_length,
                       translate_fiemap_flags(fiemap->fm_flags), e);
@@ -3511,7 +3731,7 @@ fiemap_f(int opno, long r)
 }
 
 void
-freesp_f(int opno, long r)
+freesp_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3526,7 +3746,7 @@ freesp_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: freesp - no filename\n", procid, opno);
+                       printf("%d/%lld: freesp - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3535,14 +3755,14 @@ freesp_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: freesp - open %s failed %d\n",
+                       printf("%d/%lld: freesp - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: freesp - fstat64 %s failed %d\n",
+                       printf("%d/%lld: freesp - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3557,14 +3777,14 @@ freesp_f(int opno, long r)
        fl.l_len = 0;
        e = xfsctl(f.path, fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_FREESP64) %s%s %lld 0 %d\n",
+               printf("%d/%lld: xfsctl(XFS_IOC_FREESP64) %s%s %lld 0 %d\n",
                       procid, opno, f.path, st, (long long)off, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-fsync_f(int opno, long r)
+fsync_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3574,7 +3794,7 @@ fsync_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: fsync - no filename\n", procid, opno);
+                       printf("%d/%lld: fsync - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3583,14 +3803,14 @@ fsync_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: fsync - open %s failed %d\n",
+                       printf("%d/%lld: fsync - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        e = fsync(fd) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: fsync %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: fsync %s %d\n", procid, opno, f.path, e);
        free_pathname(&f);
        close(fd);
 }
@@ -3618,7 +3838,7 @@ gen_random_string(int len)
 }
 
 void
-getattr_f(int opno, long r)
+getattr_f(opnum_t opno, long r)
 {
        int             fd;
        int             e;
@@ -3635,26 +3855,26 @@ getattr_f(int opno, long r)
 
        e = ioctl(fd, FS_IOC_GETFLAGS, &fl);
        if (v)
-               printf("%d/%d: getattr %s %u %d\n", procid, opno, f.path, fl, e);
+               printf("%d/%lld: getattr %s %u %d\n", procid, opno, f.path, fl, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-getdents_f(int opno, long r)
+getdents_f(opnum_t opno, long r)
 {
        DIR             *dir;
        pathname_t      f;
        int             v;
 
        init_pathname(&f);
-       if (!get_fname(FT_DIRm, r, &f, NULL, NULL, &v))
+       if (!get_fname(FT_ANYDIR, r, &f, NULL, NULL, &v))
                append_pathname(&f, ".");
        dir = opendir_path(&f);
        check_cwd();
        if (dir == NULL) {
                if (v)
-                       printf("%d/%d: getdents - can't open %s\n",
+                       printf("%d/%lld: getdents - can't open %s\n",
                                procid, opno, f.path);
                free_pathname(&f);
                return;
@@ -3662,13 +3882,13 @@ getdents_f(int opno, long r)
        while (readdir64(dir) != NULL)
                continue;
        if (v)
-               printf("%d/%d: getdents %s 0\n", procid, opno, f.path);
+               printf("%d/%lld: getdents %s 0\n", procid, opno, f.path);
        free_pathname(&f);
        closedir(dir);
 }
 
 void
-getfattr_f(int opno, long r)
+getfattr_f(opnum_t opno, long r)
 {
        fent_t          *fep;
        int             e;
@@ -3680,9 +3900,9 @@ getfattr_f(int opno, long r)
        int             xattr_num;
 
        init_pathname(&f);
-       if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, &fep, &v)) {
+       if (!get_fname(FT_REGFILE | FT_ANYDIR, r, &f, NULL, &fep, &v)) {
                if (v)
-                       printf("%d/%d: getfattr - no filename\n", procid, opno);
+                       printf("%d/%lld: getfattr - no filename\n", procid, opno);
                goto out;
        }
        check_cwd();
@@ -3699,7 +3919,7 @@ getfattr_f(int opno, long r)
 
        e = generate_xattr_name(xattr_num, name, sizeof(name));
        if (e < 0) {
-               printf("%d/%d: getfattr - file %s failed to generate xattr name: %d\n",
+               printf("%d/%lld: getfattr - file %s failed to generate xattr name: %d\n",
                       procid, opno, f.path, e);
                goto out;
        }
@@ -3707,7 +3927,7 @@ getfattr_f(int opno, long r)
        value_len = getxattr(f.path, name, NULL, 0);
        if (value_len < 0) {
                if (v)
-                       printf("%d/%d: getfattr file %s name %s failed %d\n",
+                       printf("%d/%lld: getfattr file %s name %s failed %d\n",
                               procid, opno, f.path, name, errno);
                goto out;
        }
@@ -3721,7 +3941,7 @@ getfattr_f(int opno, long r)
        value = malloc(value_len);
        if (!value) {
                if (v)
-                       printf("%d/%d: getfattr file %s failed to allocate buffer with %d bytes\n",
+                       printf("%d/%lld: getfattr file %s failed to allocate buffer with %d bytes\n",
                               procid, opno, f.path, value_len);
                goto out;
        }
@@ -3729,7 +3949,7 @@ getfattr_f(int opno, long r)
        e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
 out_log:
        if (v)
-               printf("%d/%d: getfattr file %s name %s value length %d %d\n",
+               printf("%d/%lld: getfattr file %s name %s value length %d %d\n",
                       procid, opno, f.path, name, value_len, e);
 out:
        free(value);
@@ -3737,7 +3957,7 @@ out:
 }
 
 void
-link_f(int opno, long r)
+link_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3753,7 +3973,7 @@ link_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep_src, &v1)) {
                if (v1)
-                       printf("%d/%d: link - no file\n", procid, opno);
+                       printf("%d/%lld: link - no file\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3767,8 +3987,8 @@ link_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&l, &flist[FT_DIR], fep);
-                       printf("%d/%d: link - no filename from %s\n",
+                       (void)fent_to_name(&l, fep);
+                       printf("%d/%lld: link - no filename from %s\n",
                                procid, opno, l.path);
                }
                free_pathname(&l);
@@ -3780,16 +4000,16 @@ link_f(int opno, long r)
        if (e == 0)
                add_to_flist(flp - flist, id, parid, fep_src->xattr_counter);
        if (v) {
-               printf("%d/%d: link %s %s %d\n", procid, opno, f.path, l.path,
+               printf("%d/%lld: link %s %s %d\n", procid, opno, f.path, l.path,
                        e);
-               printf("%d/%d: link add id=%d,parent=%d\n", procid, opno, id, parid);
+               printf("%d/%lld: link add id=%d,parent=%d\n", procid, opno, id, parid);
        }
        free_pathname(&l);
        free_pathname(&f);
 }
 
 void
-listfattr_f(int opno, long r)
+listfattr_f(opnum_t opno, long r)
 {
        fent_t          *fep;
        int             e;
@@ -3799,9 +4019,9 @@ listfattr_f(int opno, long r)
        int             buffer_len;
 
        init_pathname(&f);
-       if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, &fep, &v)) {
+       if (!get_fname(FT_REGFILE | FT_ANYDIR, r, &f, NULL, &fep, &v)) {
                if (v)
-                       printf("%d/%d: listfattr - no filename\n", procid, opno);
+                       printf("%d/%lld: listfattr - no filename\n", procid, opno);
                goto out;
        }
        check_cwd();
@@ -3809,14 +4029,14 @@ listfattr_f(int opno, long r)
        e = listxattr(f.path, NULL, 0);
        if (e < 0) {
                if (v)
-                       printf("%d/%d: listfattr %s failed %d\n",
+                       printf("%d/%lld: listfattr %s failed %d\n",
                               procid, opno, f.path, errno);
                goto out;
        }
        buffer_len = e;
        if (buffer_len == 0) {
                if (v)
-                       printf("%d/%d: listfattr %s - has no extended attributes\n",
+                       printf("%d/%lld: listfattr %s - has no extended attributes\n",
                               procid, opno, f.path);
                goto out;
        }
@@ -3824,14 +4044,14 @@ listfattr_f(int opno, long r)
        buffer = malloc(buffer_len);
        if (!buffer) {
                if (v)
-                       printf("%d/%d: listfattr %s failed to allocate buffer with %d bytes\n",
+                       printf("%d/%lld: listfattr %s failed to allocate buffer with %d bytes\n",
                               procid, opno, f.path, buffer_len);
                goto out;
        }
 
        e = listxattr(f.path, buffer, buffer_len) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: listfattr %s buffer length %d %d\n",
+               printf("%d/%lld: listfattr %s buffer length %d %d\n",
                       procid, opno, f.path, buffer_len, e);
 out:
        free(buffer);
@@ -3839,7 +4059,7 @@ out:
 }
 
 void
-mkdir_f(int opno, long r)
+mkdir_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3849,7 +4069,7 @@ mkdir_f(int opno, long r)
        int             v;
        int             v1;
 
-       if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
+       if (!get_fname(FT_ANYDIR, r, NULL, NULL, &fep, &v))
                parid = -1;
        else
                parid = fep->id;
@@ -3858,8 +4078,8 @@ mkdir_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
-                       printf("%d/%d: mkdir - no filename from %s\n",
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%lld: mkdir - no filename from %s\n",
                                procid, opno, f.path);
                }
                free_pathname(&f);
@@ -3870,14 +4090,14 @@ mkdir_f(int opno, long r)
        if (e == 0)
                add_to_flist(FT_DIR, id, parid, 0);
        if (v) {
-               printf("%d/%d: mkdir %s %d\n", procid, opno, f.path, e);
-               printf("%d/%d: mkdir add id=%d,parent=%d\n", procid, opno, id, parid);
+               printf("%d/%lld: mkdir %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: mkdir add id=%d,parent=%d\n", procid, opno, id, parid);
        }
        free_pathname(&f);
 }
 
 void
-mknod_f(int opno, long r)
+mknod_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -3887,7 +4107,7 @@ mknod_f(int opno, long r)
        int             v;
        int             v1;
 
-       if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
+       if (!get_fname(FT_ANYDIR, r, NULL, NULL, &fep, &v))
                parid = -1;
        else
                parid = fep->id;
@@ -3896,8 +4116,8 @@ mknod_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
-                       printf("%d/%d: mknod - no filename from %s\n",
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%lld: mknod - no filename from %s\n",
                                procid, opno, f.path);
                }
                free_pathname(&f);
@@ -3908,8 +4128,8 @@ mknod_f(int opno, long r)
        if (e == 0)
                add_to_flist(FT_DEV, id, parid, 0);
        if (v) {
-               printf("%d/%d: mknod %s %d\n", procid, opno, f.path, e);
-               printf("%d/%d: mknod add id=%d,parent=%d\n", procid, opno, id, parid);
+               printf("%d/%lld: mknod %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: mknod add id=%d,parent=%d\n", procid, opno, id, parid);
        }
        free_pathname(&f);
 }
@@ -3926,7 +4146,7 @@ struct print_flags mmap_flags[] = {
 #endif
 
 void
-do_mmap(int opno, long r, int prot)
+do_mmap(opnum_t opno, long r, int prot)
 {
 #ifdef HAVE_SYS_MMAN_H
        char            *addr;
@@ -3945,7 +4165,7 @@ do_mmap(int opno, long r, int prot)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: do_mmap - no filename\n", procid, opno);
+                       printf("%d/%lld: do_mmap - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -3954,14 +4174,14 @@ do_mmap(int opno, long r, int prot)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: do_mmap - open %s failed %d\n",
+                       printf("%d/%lld: do_mmap - open %s failed %d\n",
                               procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: do_mmap - fstat64 %s failed %d\n",
+                       printf("%d/%lld: do_mmap - fstat64 %s failed %d\n",
                               procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -3970,7 +4190,7 @@ do_mmap(int opno, long r, int prot)
        inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: do_mmap - %s%s zero size\n", procid, opno,
+                       printf("%d/%lld: do_mmap - %s%s zero size\n", procid, opno,
                               f.path, st);
                free_pathname(&f);
                close(fd);
@@ -3979,7 +4199,7 @@ do_mmap(int opno, long r, int prot)
 
        lr = ((int64_t)random() << 32) + random();
        off = (off64_t)(lr % stb.st_size);
-       off &= (off64_t)(~(sysconf(_SC_PAGE_SIZE) - 1));
+       off = rounddown_64(off, sysconf(_SC_PAGE_SIZE));
        len = (size_t)(random() % MIN(stb.st_size - off, FILELEN_MAX)) + 1;
 
        flags = (random() % 2) ? MAP_SHARED : MAP_PRIVATE;
@@ -3987,7 +4207,7 @@ do_mmap(int opno, long r, int prot)
        e = (addr == MAP_FAILED) ? errno : 0;
        if (e) {
                if (v)
-                       printf("%d/%d: do_mmap - mmap failed %s%s [%lld,%d,%s] %d\n",
+                       printf("%d/%lld: do_mmap - mmap failed %s%s [%lld,%d,%s] %d\n",
                               procid, opno, f.path, st, (long long)off,
                               (int)len, translate_mmap_flags(flags), e);
                free_pathname(&f);
@@ -4012,7 +4232,7 @@ do_mmap(int opno, long r, int prot)
        sigbus_jmp = NULL;
 
        if (v)
-               printf("%d/%d: %s %s%s [%lld,%d,%s] %s\n",
+               printf("%d/%lld: %s %s%s [%lld,%d,%s] %s\n",
                       procid, opno, (prot & PROT_WRITE) ? "mwrite" : "mread",
                       f.path, st, (long long)off, (int)len,
                       translate_mmap_flags(flags),
@@ -4024,7 +4244,7 @@ do_mmap(int opno, long r, int prot)
 }
 
 void
-mread_f(int opno, long r)
+mread_f(opnum_t opno, long r)
 {
 #ifdef HAVE_SYS_MMAN_H
        do_mmap(opno, r, PROT_READ);
@@ -4032,7 +4252,7 @@ mread_f(int opno, long r)
 }
 
 void
-mwrite_f(int opno, long r)
+mwrite_f(opnum_t opno, long r)
 {
 #ifdef HAVE_SYS_MMAN_H
        do_mmap(opno, r, PROT_WRITE);
@@ -4040,7 +4260,7 @@ mwrite_f(int opno, long r)
 }
 
 void
-punch_f(int opno, long r)
+punch_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        do_fallocate(opno, r, FALLOC_FL_PUNCH_HOLE);
@@ -4048,7 +4268,7 @@ punch_f(int opno, long r)
 }
 
 void
-zero_f(int opno, long r)
+zero_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        do_fallocate(opno, r, FALLOC_FL_ZERO_RANGE);
@@ -4056,7 +4276,7 @@ zero_f(int opno, long r)
 }
 
 void
-collapse_f(int opno, long r)
+collapse_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        do_fallocate(opno, r, FALLOC_FL_COLLAPSE_RANGE);
@@ -4064,7 +4284,7 @@ collapse_f(int opno, long r)
 }
 
 void
-insert_f(int opno, long r)
+insert_f(opnum_t opno, long r)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        do_fallocate(opno, r, FALLOC_FL_INSERT_RANGE);
@@ -4072,7 +4292,7 @@ insert_f(int opno, long r)
 }
 
 void
-read_f(int opno, long r)
+read_f(opnum_t opno, long r)
 {
        char            *buf;
        int             e;
@@ -4088,7 +4308,7 @@ read_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: read - no filename\n", procid, opno);
+                       printf("%d/%lld: read - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4097,14 +4317,14 @@ read_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: read - open %s failed %d\n",
+                       printf("%d/%lld: read - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: read - fstat64 %s failed %d\n",
+                       printf("%d/%lld: read - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4113,7 +4333,7 @@ read_f(int opno, long r)
        inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: read - %s%s zero size\n", procid, opno,
+                       printf("%d/%lld: read - %s%s zero size\n", procid, opno,
                               f.path, st);
                free_pathname(&f);
                close(fd);
@@ -4127,14 +4347,14 @@ read_f(int opno, long r)
        e = read(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: read %s%s [%lld,%d] %d\n",
+               printf("%d/%lld: read %s%s [%lld,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-readlink_f(int opno, long r)
+readlink_f(opnum_t opno, long r)
 {
        char            buf[PATH_MAX];
        int             e;
@@ -4144,19 +4364,19 @@ readlink_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_SYMm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: readlink - no filename\n", procid, opno);
+                       printf("%d/%lld: readlink - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
        e = readlink_path(&f, buf, PATH_MAX) < 0 ? errno : 0;
        check_cwd();
        if (v)
-               printf("%d/%d: readlink %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: readlink %s %d\n", procid, opno, f.path, e);
        free_pathname(&f);
 }
 
 void
-readv_f(int opno, long r)
+readv_f(opnum_t opno, long r)
 {
        char            *buf;
        int             e;
@@ -4177,7 +4397,7 @@ readv_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: readv - no filename\n", procid, opno);
+                       printf("%d/%lld: readv - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4186,14 +4406,14 @@ readv_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: readv - open %s failed %d\n",
+                       printf("%d/%lld: readv - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: readv - fstat64 %s failed %d\n",
+                       printf("%d/%lld: readv - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4202,7 +4422,7 @@ readv_f(int opno, long r)
        inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: readv - %s%s zero size\n", procid, opno,
+                       printf("%d/%lld: readv - %s%s zero size\n", procid, opno,
                               f.path, st);
                free_pathname(&f);
                close(fd);
@@ -4227,7 +4447,7 @@ readv_f(int opno, long r)
        e = readv(fd, iov, iovcnt) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: readv %s%s [%lld,%d,%d] %d\n",
+               printf("%d/%lld: readv %s%s [%lld,%d,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)iovl,
                       iovcnt, e);
        free_pathname(&f);
@@ -4235,7 +4455,7 @@ readv_f(int opno, long r)
 }
 
 void
-removefattr_f(int opno, long r)
+removefattr_f(opnum_t opno, long r)
 {
        fent_t          *fep;
        int             e;
@@ -4245,9 +4465,9 @@ removefattr_f(int opno, long r)
        int             xattr_num;
 
        init_pathname(&f);
-       if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, &fep, &v)) {
+       if (!get_fname(FT_REGFILE | FT_ANYDIR, r, &f, NULL, &fep, &v)) {
                if (v)
-                       printf("%d/%d: removefattr - no filename\n", procid, opno);
+                       printf("%d/%lld: removefattr - no filename\n", procid, opno);
                goto out;
        }
        check_cwd();
@@ -4264,14 +4484,14 @@ removefattr_f(int opno, long r)
 
        e = generate_xattr_name(xattr_num, name, sizeof(name));
        if (e < 0) {
-               printf("%d/%d: removefattr - file %s failed to generate xattr name: %d\n",
+               printf("%d/%lld: removefattr - file %s failed to generate xattr name: %d\n",
                       procid, opno, f.path, e);
                goto out;
        }
 
        e = removexattr(f.path, name) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: removefattr file %s name %s %d\n",
+               printf("%d/%lld: removefattr file %s name %s %d\n",
                       procid, opno, f.path, name, e);
 out:
        free_pathname(&f);
@@ -4288,7 +4508,7 @@ struct print_flags renameat2_flags [] = {
        ({translate_flags(mode, "|", renameat2_flags);})
 
 void
-do_renameat2(int opno, long r, int mode)
+do_renameat2(opnum_t opno, long r, int mode)
 {
        fent_t          *dfep;
        int             e;
@@ -4297,9 +4517,9 @@ do_renameat2(int opno, long r, int mode)
        flist_t         *flp;
        int             id;
        pathname_t      newf;
-       int             oldid;
+       int             oldid = 0;
        int             parid;
-       int             oldparid;
+       int             oldparid = 0;
        int             which;
        int             v;
        int             v1;
@@ -4309,7 +4529,7 @@ do_renameat2(int opno, long r, int mode)
        which = (mode == RENAME_WHITEOUT) ? FT_DEVm : FT_ANYm;
        if (!get_fname(which, r, &f, &flp, &fep, &v1)) {
                if (v1)
-                       printf("%d/%d: rename - no source filename\n",
+                       printf("%d/%lld: rename - no source filename\n",
                                procid, opno);
                free_pathname(&f);
                return;
@@ -4325,7 +4545,7 @@ do_renameat2(int opno, long r, int mode)
                init_pathname(&newf);
                if (!get_fname(which, random(), &newf, NULL, &dfep, &v)) {
                        if (v)
-                               printf("%d/%d: rename - no target filename\n",
+                               printf("%d/%lld: rename - no target filename\n",
                                        procid, opno);
                        free_pathname(&newf);
                        free_pathname(&f);
@@ -4334,7 +4554,7 @@ do_renameat2(int opno, long r, int mode)
                if (which == FT_DIRm && (fents_ancestor_check(fep, dfep) ||
                    fents_ancestor_check(dfep, fep))) {
                        if (v)
-                               printf("%d/%d: rename(REXCHANGE) %s and %s "
+                               printf("%d/%lld: rename(REXCHANGE) %s and %s "
                                        "have ancestor-descendant relationship\n",
                                        procid, opno, f.path, newf.path);
                        free_pathname(&newf);
@@ -4364,8 +4584,8 @@ do_renameat2(int opno, long r, int mode)
                v |= v1;
                if (!e) {
                        if (v) {
-                               (void)fent_to_name(&f, &flist[FT_DIR], dfep);
-                               printf("%d/%d: rename - no filename from %s\n",
+                               (void)fent_to_name(&f, dfep);
+                               printf("%d/%lld: rename - no filename from %s\n",
                                        procid, opno, f.path);
                        }
                        free_pathname(&newf);
@@ -4378,6 +4598,7 @@ do_renameat2(int opno, long r, int mode)
        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;
@@ -4386,7 +4607,7 @@ do_renameat2(int opno, long r, int mode)
                 * Swap the parent ids for RENAME_EXCHANGE, and replace the
                 * old parent id for the others.
                 */
-               if (flp - flist == FT_DIR)
+               if (ft == FT_DIR || ft == FT_SUBVOL)
                        fix_parent(oldid, id, swap);
 
                if (mode == RENAME_WHITEOUT) {
@@ -4401,13 +4622,13 @@ do_renameat2(int opno, long r, int mode)
                }
        }
        if (v) {
-               printf("%d/%d: rename(%s) %s to %s %d\n", procid,
+               printf("%d/%lld: 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 source entry: id=%d,parent=%d\n",
+                       printf("%d/%lld: rename source entry: id=%d,parent=%d\n",
                                procid, opno, oldid, oldparid);
-                       printf("%d/%d: rename target entry: id=%d,parent=%d\n",
+                       printf("%d/%lld: rename target entry: id=%d,parent=%d\n",
                                procid, opno, id, parid);
                }
        }
@@ -4416,31 +4637,31 @@ do_renameat2(int opno, long r, int mode)
 }
 
 void
-rename_f(int opno, long r)
+rename_f(opnum_t opno, long r)
 {
        do_renameat2(opno, r, 0);
 }
 
 void
-rnoreplace_f(int opno, long r)
+rnoreplace_f(opnum_t opno, long r)
 {
        do_renameat2(opno, r, RENAME_NOREPLACE);
 }
 
 void
-rexchange_f(int opno, long r)
+rexchange_f(opnum_t opno, long r)
 {
        do_renameat2(opno, r, RENAME_EXCHANGE);
 }
 
 void
-rwhiteout_f(int opno, long r)
+rwhiteout_f(opnum_t opno, long r)
 {
        do_renameat2(opno, r, RENAME_WHITEOUT);
 }
 
 void
-resvsp_f(int opno, long r)
+resvsp_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4455,7 +4676,7 @@ resvsp_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: resvsp - no filename\n", procid, opno);
+                       printf("%d/%lld: resvsp - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4464,14 +4685,14 @@ resvsp_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: resvsp - open %s failed %d\n",
+                       printf("%d/%lld: resvsp - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: resvsp - fstat64 %s failed %d\n",
+                       printf("%d/%lld: resvsp - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4486,7 +4707,7 @@ resvsp_f(int opno, long r)
        fl.l_len = (off64_t)(random() % (1024 * 1024));
        e = xfsctl(f.path, fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_RESVSP64) %s%s %lld %lld %d\n",
+               printf("%d/%lld: xfsctl(XFS_IOC_RESVSP64) %s%s %lld %lld %d\n",
                       procid, opno, f.path, st,
                        (long long)off, (long long)fl.l_len, e);
        free_pathname(&f);
@@ -4494,35 +4715,40 @@ resvsp_f(int opno, long r)
 }
 
 void
-rmdir_f(int opno, long r)
+rmdir_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
        fent_t          *fep;
+       int             oldid;
+       int             oldparid;
        int             v;
 
        init_pathname(&f);
        if (!get_fname(FT_DIRm, r, &f, NULL, &fep, &v)) {
                if (v)
-                       printf("%d/%d: rmdir - no directory\n", procid, opno);
+                       printf("%d/%lld: rmdir - no directory\n", procid, opno);
                free_pathname(&f);
                return;
        }
        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);
+               printf("%d/%lld: 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);
+                       printf("%d/%lld: rmdir del entry: id=%d,parent=%d\n",
+                               procid, opno, oldid, oldparid);
        }
        free_pathname(&f);
 }
 
 void
-setattr_f(int opno, long r)
+setattr_f(opnum_t opno, long r)
 {
        int             fd;
        int             e;
@@ -4540,13 +4766,13 @@ setattr_f(int opno, long r)
        fl = attr_mask & (uint)random();
        e = ioctl(fd, FS_IOC_SETFLAGS, &fl);
        if (v)
-               printf("%d/%d: setattr %s %x %d\n", procid, opno, f.path, fl, e);
+               printf("%d/%lld: setattr %s %x %d\n", procid, opno, f.path, fl, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-setfattr_f(int opno, long r)
+setfattr_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4559,9 +4785,9 @@ setfattr_f(int opno, long r)
        int             xattr_num;
 
        init_pathname(&f);
-       if (!get_fname(FT_REGFILE | FT_DIRm, r, &f, NULL, &fep, &v)) {
+       if (!get_fname(FT_REGFILE | FT_ANYDIR, r, &f, NULL, &fep, &v)) {
                if (v)
-                       printf("%d/%d: setfattr - no filename\n", procid, opno);
+                       printf("%d/%lld: setfattr - no filename\n", procid, opno);
                goto out;
        }
        check_cwd();
@@ -4597,13 +4823,13 @@ setfattr_f(int opno, long r)
        value = gen_random_string(value_len);
        if (!value && value_len > 0) {
                if (v)
-                       printf("%d/%d: setfattr - file %s failed to allocate value with %d bytes\n",
+                       printf("%d/%lld: setfattr - file %s failed to allocate value with %d bytes\n",
                               procid, opno, f.path, value_len);
                goto out;
        }
        e = generate_xattr_name(xattr_num, name, sizeof(name));
        if (e < 0) {
-               printf("%d/%d: setfattr - file %s failed to generate xattr name: %d\n",
+               printf("%d/%lld: setfattr - file %s failed to generate xattr name: %d\n",
                       procid, opno, f.path, e);
                goto out;
        }
@@ -4612,7 +4838,7 @@ setfattr_f(int opno, long r)
        if (e == 0)
                fep->xattr_counter++;
        if (v)
-               printf("%d/%d: setfattr file %s name %s flag %s value length %d: %d\n",
+               printf("%d/%lld: setfattr file %s name %s flag %s value length %d: %d\n",
                       procid, opno, f.path, name, xattr_flag_to_string(flag),
                       value_len, e);
 out:
@@ -4621,7 +4847,56 @@ out:
 }
 
 void
-stat_f(int opno, long r)
+snapshot_f(opnum_t opno, long r)
+{
+#ifdef HAVE_BTRFSUTIL_H
+       enum btrfs_util_error   e;
+       pathname_t              f;
+       pathname_t              newf;
+       fent_t                  *fep;
+       int                     id;
+       int                     parid;
+       int                     v;
+       int                     v1;
+       int                     err;
+
+       init_pathname(&f);
+       if (!get_fname(FT_SUBVOLm, r, &f, NULL, &fep, &v)) {
+               if (v)
+                       printf("%d/%lld: snapshot - no subvolume\n", procid,
+                              opno);
+               free_pathname(&f);
+               return;
+       }
+       init_pathname(&newf);
+       parid = fep->id;
+       err = generate_fname(fep, FT_SUBVOL, &newf, &id, &v1);
+       v |= v1;
+       if (!err) {
+               if (v) {
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%lld: snapshot - no filename from %s\n",
+                              procid, opno, f.path);
+               }
+               free_pathname(&f);
+               return;
+       }
+       e = btrfs_util_create_snapshot(f.path, newf.path, 0, NULL, NULL);
+       if (e == BTRFS_UTIL_OK)
+               add_to_flist(FT_SUBVOL, id, parid, 0);
+       if (v) {
+               printf("%d/%lld: snapshot %s->%s %d(%s)\n", procid, opno,
+                      f.path, newf.path, e, btrfs_util_strerror(e));
+               printf("%d/%lld: snapshot add id=%d,parent=%d\n", procid, opno,
+                      id, parid);
+       }
+       free_pathname(&newf);
+       free_pathname(&f);
+#endif
+}
+
+void
+stat_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4631,19 +4906,99 @@ stat_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: stat - no entries\n", procid, opno);
+                       printf("%d/%lld: stat - no entries\n", procid, opno);
                free_pathname(&f);
                return;
        }
        e = lstat64_path(&f, &stb) < 0 ? errno : 0;
        check_cwd();
        if (v)
-               printf("%d/%d: stat %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: stat %s %d\n", procid, opno, f.path, e);
        free_pathname(&f);
 }
 
 void
-symlink_f(int opno, long r)
+subvol_create_f(opnum_t 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_ANYDIR, 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/%lld: 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/%lld: subvol_create %s %d(%s)\n", procid, opno,
+                      f.path, e, btrfs_util_strerror(e));
+               printf("%d/%lld: subvol_create add id=%d,parent=%d\n", procid,
+                      opno, id, parid);
+       }
+       free_pathname(&f);
+#endif
+}
+
+void
+subvol_delete_f(opnum_t 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:%lld: 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/%lld: subvol_delete %s %d(%s)\n", procid, opno, f.path,
+                      e, btrfs_util_strerror(e));
+               if (e == BTRFS_UTIL_OK)
+                       printf("%d/%lld: subvol_delete del entry: id=%d,parent=%d\n",
+                              procid, opno, oldid, oldparid);
+       }
+       free_pathname(&f);
+#endif
+}
+
+void
+symlink_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4656,7 +5011,7 @@ symlink_f(int opno, long r)
        int             v1;
        char            *val;
 
-       if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
+       if (!get_fname(FT_ANYDIR, r, NULL, NULL, &fep, &v))
                parid = -1;
        else
                parid = fep->id;
@@ -4665,8 +5020,8 @@ symlink_f(int opno, long r)
        v |= v1;
        if (!e) {
                if (v) {
-                       (void)fent_to_name(&f, &flist[FT_DIR], fep);
-                       printf("%d/%d: symlink - no filename from %s\n",
+                       (void)fent_to_name(&f, fep);
+                       printf("%d/%lld: symlink - no filename from %s\n",
                                procid, opno, f.path);
                }
                free_pathname(&f);
@@ -4685,23 +5040,23 @@ symlink_f(int opno, long r)
                add_to_flist(FT_SYM, id, parid, 0);
        free(val);
        if (v) {
-               printf("%d/%d: symlink %s %d\n", procid, opno, f.path, e);
-               printf("%d/%d: symlink add id=%d,parent=%d\n", procid, opno, id, parid);
+               printf("%d/%lld: symlink %s %d\n", procid, opno, f.path, e);
+               printf("%d/%lld: symlink add id=%d,parent=%d\n", procid, opno, id, parid);
        }
        free_pathname(&f);
 }
 
 /* ARGSUSED */
 void
-sync_f(int opno, long r)
+sync_f(opnum_t opno, long r)
 {
        sync();
        if (verbose)
-               printf("%d/%d: sync\n", procid, opno);
+               printf("%d/%lld: sync\n", procid, opno);
 }
 
 void
-truncate_f(int opno, long r)
+truncate_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4714,7 +5069,7 @@ truncate_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: truncate - no filename\n", procid, opno);
+                       printf("%d/%lld: truncate - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4722,7 +5077,7 @@ truncate_f(int opno, long r)
        check_cwd();
        if (e > 0) {
                if (v)
-                       printf("%d/%d: truncate - stat64 %s failed %d\n",
+                       printf("%d/%lld: truncate - stat64 %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
@@ -4734,42 +5089,47 @@ truncate_f(int opno, long r)
        e = truncate64_path(&f, off) < 0 ? errno : 0;
        check_cwd();
        if (v)
-               printf("%d/%d: truncate %s%s %lld %d\n", procid, opno, f.path,
+               printf("%d/%lld: truncate %s%s %lld %d\n", procid, opno, f.path,
                       st, (long long)off, e);
        free_pathname(&f);
 }
 
 void
-unlink_f(int opno, long r)
+unlink_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
        fent_t          *fep;
        flist_t         *flp;
+       int             oldid;
+       int             oldparid;
        int             v;
 
        init_pathname(&f);
        if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep, &v)) {
                if (v)
-                       printf("%d/%d: unlink - no file\n", procid, opno);
+                       printf("%d/%lld: unlink - no file\n", procid, opno);
                free_pathname(&f);
                return;
        }
        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);
+               printf("%d/%lld: 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);
+                       printf("%d/%lld: unlink del entry: id=%d,parent=%d\n",
+                               procid, opno, oldid, oldparid);
        }
        free_pathname(&f);
 }
 
 void
-unresvsp_f(int opno, long r)
+unresvsp_f(opnum_t opno, long r)
 {
        int             e;
        pathname_t      f;
@@ -4784,7 +5144,7 @@ unresvsp_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: unresvsp - no filename\n", procid, opno);
+                       printf("%d/%lld: unresvsp - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4793,14 +5153,14 @@ unresvsp_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: unresvsp - open %s failed %d\n",
+                       printf("%d/%lld: unresvsp - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: unresvsp - fstat64 %s failed %d\n",
+                       printf("%d/%lld: unresvsp - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4815,7 +5175,7 @@ unresvsp_f(int opno, long r)
        fl.l_len = (off64_t)(random() % (1 << 20));
        e = xfsctl(f.path, fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_UNRESVSP64) %s%s %lld %lld %d\n",
+               printf("%d/%lld: xfsctl(XFS_IOC_UNRESVSP64) %s%s %lld %lld %d\n",
                       procid, opno, f.path, st,
                        (long long)off, (long long)fl.l_len, e);
        free_pathname(&f);
@@ -4823,7 +5183,23 @@ unresvsp_f(int opno, long r)
 }
 
 void
-write_f(int opno, long r)
+uring_read_f(opnum_t opno, long r)
+{
+#ifdef URING
+       do_uring_rw(opno, r, O_RDONLY);
+#endif
+}
+
+void
+uring_write_f(opnum_t opno, long r)
+{
+#ifdef URING
+       do_uring_rw(opno, r, O_WRONLY);
+#endif
+}
+
+void
+write_f(opnum_t opno, long r)
 {
        char            *buf;
        int             e;
@@ -4839,7 +5215,7 @@ write_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: write - no filename\n", procid, opno);
+                       printf("%d/%lld: write - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4848,14 +5224,14 @@ write_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: write - open %s failed %d\n",
+                       printf("%d/%lld: write - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: write - fstat64 %s failed %d\n",
+                       printf("%d/%lld: write - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4872,14 +5248,14 @@ write_f(int opno, long r)
        e = write(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: write %s%s [%lld,%d] %d\n",
+               printf("%d/%lld: write %s%s [%lld,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
 
 void
-writev_f(int opno, long r)
+writev_f(opnum_t opno, long r)
 {
        char            *buf;
        int             e;
@@ -4900,7 +5276,7 @@ writev_f(int opno, long r)
        init_pathname(&f);
        if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
                if (v)
-                       printf("%d/%d: writev - no filename\n", procid, opno);
+                       printf("%d/%lld: writev - no filename\n", procid, opno);
                free_pathname(&f);
                return;
        }
@@ -4909,14 +5285,14 @@ writev_f(int opno, long r)
        check_cwd();
        if (fd < 0) {
                if (v)
-                       printf("%d/%d: writev - open %s failed %d\n",
+                       printf("%d/%lld: writev - open %s failed %d\n",
                                procid, opno, f.path, e);
                free_pathname(&f);
                return;
        }
        if (fstat64(fd, &stb) < 0) {
                if (v)
-                       printf("%d/%d: writev - fstat64 %s failed %d\n",
+                       printf("%d/%lld: writev - fstat64 %s failed %d\n",
                                procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
@@ -4945,7 +5321,7 @@ writev_f(int opno, long r)
        free(buf);
        free(iov);
        if (v)
-               printf("%d/%d: writev %s%s [%lld,%d,%d] %d\n",
+               printf("%d/%lld: writev %s%s [%lld,%d,%d] %d\n",
                       procid, opno, f.path, st, (long long)off, (int)iovl,
                       iovcnt, e);
        free_pathname(&f);