hammer2 - Remote xop implementation part 1
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 29 Jul 2018 02:03:29 +0000 (19:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 13 Aug 2018 00:17:01 +0000 (17:17 -0700)
* Normalize naming conventions for XOP functions.

* Change the XOP callback API to remove the hammer2_thread argument.
  Pass the clindex and scratch buffer in directly.

* Change the XOP API to pass in a function descriptor instead of a
  function pointer, create prototypes for DMSG send/receive XOPs which
  will be used for XOP components which are DMSG based and not
  local-storage based.

* Adjust comments.

sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_admin.c
sys/vfs/hammer2/hammer2_flush.c
sys/vfs/hammer2/hammer2_inode.c
sys/vfs/hammer2/hammer2_iocom.c
sys/vfs/hammer2/hammer2_ioctl.c
sys/vfs/hammer2/hammer2_strategy.c
sys/vfs/hammer2/hammer2_synchro.c
sys/vfs/hammer2/hammer2_vfsops.c
sys/vfs/hammer2/hammer2_vnops.c
sys/vfs/hammer2/hammer2_xops.c

index 91905f4..db8dedc 100644 (file)
@@ -857,8 +857,17 @@ typedef struct hammer2_dedup hammer2_dedup_t;
  *
  * This structure also sequences operations on up to three inodes.
  */
-typedef void (*hammer2_xop_func_t)(hammer2_thread_t *thr,
-                                  union hammer2_xop *xop);
+typedef void (*hammer2_xop_func_t)(union hammer2_xop *xop, void *scratch,
+                                  int clindex);
+
+struct hammer2_xop_desc {
+       hammer2_xop_func_t      storage_func;   /* local storage function */
+       hammer2_xop_func_t      dmsg_dispatch;  /* dmsg dispatch function */
+       hammer2_xop_func_t      dmsg_process;   /* dmsg processing function */
+       const char              *id;
+};
+
+typedef struct hammer2_xop_desc hammer2_xop_desc_t;
 
 struct hammer2_xop_fifo {
        TAILQ_ENTRY(hammer2_xop_head) entry;
@@ -876,7 +885,7 @@ typedef struct hammer2_xop_fifo hammer2_xop_fifo_t;
 #define HAMMER2_XOP_FIFO_STALL 0x0002
 
 struct hammer2_xop_head {
-       hammer2_xop_func_t      func;
+       hammer2_xop_desc_t      *desc;
        hammer2_tid_t           mtid;
        struct hammer2_inode    *ip1;
        struct hammer2_inode    *ip2;
@@ -1664,8 +1673,8 @@ void hammer2_xop_setip3(hammer2_xop_head_t *xop, hammer2_inode_t *ip3);
 void hammer2_xop_reinit(hammer2_xop_head_t *xop);
 void hammer2_xop_helper_create(hammer2_pfs_t *pmp);
 void hammer2_xop_helper_cleanup(hammer2_pfs_t *pmp);
-void hammer2_xop_start(hammer2_xop_head_t *xop, hammer2_xop_func_t func);
-void hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_func_t func,
+void hammer2_xop_start(hammer2_xop_head_t *xop, hammer2_xop_desc_t *desc);
+void hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_desc_t *desc,
                                int notidx);
 int hammer2_xop_collect(hammer2_xop_head_t *xop, int flags);
 void hammer2_xop_retire(hammer2_xop_head_t *xop, uint64_t mask);
@@ -1682,22 +1691,89 @@ void hammer2_primary_sync_thread(void *arg);
  * XOP backends in hammer2_xops.c, primarily for VNOPS.  Other XOP backends
  * may be integrated into other source files.
  */
-void hammer2_xop_ipcluster(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_readdir(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_nresolve(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_unlink(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_scanlhc(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_scanall(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_lookup(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_xop_delete(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_mkdirent(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_create(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_destroy(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_chain_sync(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_unlinkall(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_connect(hammer2_thread_t *thr, hammer2_xop_t *xop);
-void hammer2_inode_xop_flush(hammer2_thread_t *thr, hammer2_xop_t *xop);
+void hammer2_xop_ipcluster(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_readdir(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_nresolve(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_unlink(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_nrename(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_scanlhc(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_scanall(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_lookup(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_delete(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_inode_mkdirent(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_inode_create(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_inode_destroy(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_inode_chain_sync(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_xop_inode_unlinkall(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_xop_inode_connect(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_inode_flush(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_strategy_read(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_xop_strategy_write(hammer2_xop_t *xop, void *scratch, int clindex);
+
+void hammer2_dmsg_ipcluster(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_readdir(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_nresolve(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_unlink(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_nrename(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_scanlhc(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_scanall(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_lookup(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_inode_mkdirent(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_dmsg_inode_create(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_inode_destroy(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_inode_chain_sync(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_dmsg_inode_unlinkall(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_dmsg_inode_connect(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_inode_flush(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_strategy_read(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_dmsg_strategy_write(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+
+void hammer2_rmsg_ipcluster(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_readdir(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_nresolve(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_unlink(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_nrename(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_scanlhc(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_scanall(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_lookup(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_inode_mkdirent(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_rmsg_inode_create(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_inode_destroy(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_inode_chain_sync(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_rmsg_inode_unlinkall(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+void hammer2_rmsg_inode_connect(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_inode_flush(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_strategy_read(hammer2_xop_t *xop, void *scratch, int clindex);
+void hammer2_rmsg_strategy_write(hammer2_xop_t *xop, void *scratch,
+                               int clindex);
+
+extern hammer2_xop_desc_t hammer2_ipcluster_desc;
+extern hammer2_xop_desc_t hammer2_readdir_desc;
+extern hammer2_xop_desc_t hammer2_nresolve_desc;
+extern hammer2_xop_desc_t hammer2_unlink_desc;
+extern hammer2_xop_desc_t hammer2_nrename_desc;
+extern hammer2_xop_desc_t hammer2_scanlhc_desc;
+extern hammer2_xop_desc_t hammer2_scanall_desc;
+extern hammer2_xop_desc_t hammer2_lookup_desc;
+extern hammer2_xop_desc_t hammer2_delete_desc;
+extern hammer2_xop_desc_t hammer2_inode_mkdirent_desc;
+extern hammer2_xop_desc_t hammer2_inode_create_desc;
+extern hammer2_xop_desc_t hammer2_inode_destroy_desc;
+extern hammer2_xop_desc_t hammer2_inode_chain_sync_desc;
+extern hammer2_xop_desc_t hammer2_inode_unlinkall_desc;
+extern hammer2_xop_desc_t hammer2_inode_connect_desc;
+extern hammer2_xop_desc_t hammer2_inode_flush_desc;
+extern hammer2_xop_desc_t hammer2_strategy_read_desc;
+extern hammer2_xop_desc_t hammer2_strategy_write_desc;
 
 /*
  * hammer2_msgops.c
index b4d4e7f..324a546 100644 (file)
  */
 #include "hammer2.h"
 
+#define H2XOPDESCRIPTOR(label)                                 \
+       hammer2_xop_desc_t hammer2_##label##desc = {            \
+               .storage_func = hammer2_xop_##label,            \
+               .id = #label                                    \
+       };                                                      \
+
+H2XOPDESCRIPTOR(ipcluster);
+H2XOPDESCRIPTOR(readdir);
+H2XOPDESCRIPTOR(nresolve);
+H2XOPDESCRIPTOR(unlink);
+H2XOPDESCRIPTOR(nrename);
+H2XOPDESCRIPTOR(scanlhc);
+H2XOPDESCRIPTOR(scanall);
+H2XOPDESCRIPTOR(lookup);
+H2XOPDESCRIPTOR(delete);
+H2XOPDESCRIPTOR(inode_mkdirent);
+H2XOPDESCRIPTOR(inode_create);
+H2XOPDESCRIPTOR(inode_destroy);
+H2XOPDESCRIPTOR(inode_chain_sync);
+H2XOPDESCRIPTOR(inode_unlinkall);
+H2XOPDESCRIPTOR(inode_connect);
+H2XOPDESCRIPTOR(inode_flush);
+H2XOPDESCRIPTOR(strategy_read);
+H2XOPDESCRIPTOR(strategy_write);
+
 /*
  * Set flags and wakeup any waiters.
  *
@@ -310,7 +335,7 @@ hammer2_xop_alloc(hammer2_inode_t *ip, int flags)
        KKASSERT(xop->head.cluster.array[0].chain == NULL);
 
        xop->head.ip1 = ip;
-       xop->head.func = NULL;
+       xop->head.desc = NULL;
        xop->head.flags = flags;
        xop->head.state = 0;
        xop->head.error = 0;
@@ -435,7 +460,7 @@ hammer2_xop_helper_cleanup(hammer2_pfs_t *pmp)
  * XXX optimize single-target case.
  */
 void
-hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_func_t func,
+hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_desc_t *desc,
                         int notidx)
 {
        hammer2_inode_t *ip1;
@@ -477,7 +502,7 @@ hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_func_t func,
                ng = (int)(hammer2_icrc32(&xop->ip1, sizeof(xop->ip1)));
                ng = ng & (HAMMER2_XOPGROUPS_MASK >> 1);
        }
-       xop->func = func;
+       xop->desc = desc;
 
        /*
         * The instant xop is queued another thread can pick it off.  In the
@@ -517,9 +542,9 @@ hammer2_xop_start_except(hammer2_xop_head_t *xop, hammer2_xop_func_t func,
 }
 
 void
-hammer2_xop_start(hammer2_xop_head_t *xop, hammer2_xop_func_t func)
+hammer2_xop_start(hammer2_xop_head_t *xop, hammer2_xop_desc_t *desc)
 {
-       hammer2_xop_start_except(xop, func, -1);
+       hammer2_xop_start_except(xop, desc, -1);
 }
 
 /*
@@ -1034,7 +1059,7 @@ hammer2_primary_xops_thread(void *arg)
        uint64_t mask;
        uint32_t flags;
        uint32_t nflags;
-       hammer2_xop_func_t last_func = NULL;
+       hammer2_xop_desc_t *last_desc = NULL;
 
        pmp = thr->pmp;
        /*xgrp = &pmp->xop_groups[thr->repidx]; not needed */
@@ -1102,12 +1127,14 @@ hammer2_primary_xops_thread(void *arg)
                }
                while ((xop = hammer2_xop_next(thr)) != NULL) {
                        if (hammer2_xop_active(xop)) {
-                               last_func = xop->func;
-                               xop->func(thr, (hammer2_xop_t *)xop);
+                               last_desc = xop->desc;
+                               xop->desc->storage_func((hammer2_xop_t *)xop,
+                                                       thr->scratch,
+                                                       thr->clindex);
                                hammer2_xop_dequeue(thr, xop);
                                hammer2_xop_retire(xop, mask);
                        } else {
-                               last_func = xop->func;
+                               last_desc = xop->desc;
                                hammer2_xop_feed(xop, NULL, thr->clindex,
                                                 ECONNABORTED);
                                hammer2_xop_dequeue(thr, xop);
@@ -1135,7 +1162,7 @@ hammer2_primary_xops_thread(void *arg)
         * Cleanup / termination
         */
        while ((xop = TAILQ_FIRST(&thr->xopq)) != NULL) {
-               kprintf("hammer2_thread: aborting xop %p\n", xop->func);
+               kprintf("hammer2_thread: aborting xop %s\n", xop->desc->id);
                TAILQ_REMOVE(&thr->xopq, xop,
                             collect[thr->clindex].entry);
                hammer2_xop_retire(xop, mask);
index 6c7054d..7fbdc0d 100644 (file)
@@ -363,7 +363,7 @@ hammer2_delayed_flush(hammer2_chain_t *chain)
  * function.
  *
  * This routine can be called from several places but the most important
- * is from VFS_SYNC (frontend) via hammer2_inode_xop_flush (backend).
+ * is from VFS_SYNC (frontend) via hammer2_xop_inode_flush (backend).
  *
  * chain is locked on call and will remain locked on return.  The chain's
  * UPDATE flag indicates that its parent's block table (which is not yet
@@ -1373,7 +1373,7 @@ done:
  * Primarily called from vfs_sync().
  */
 void
-hammer2_inode_xop_flush(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_flush(hammer2_xop_t *arg, void *scratch __unused, int clindex)
 {
        hammer2_xop_flush_t *xop = &arg->xop_flush;
        hammer2_chain_t *chain;
@@ -1393,7 +1393,7 @@ hammer2_inode_xop_flush(hammer2_thread_t *thr, hammer2_xop_t *arg)
        /*
         * Flush core chains
         */
-       chain = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       chain = hammer2_inode_chain(xop->head.ip1, clindex,
                                    HAMMER2_RESOLVE_ALWAYS);
        if (chain) {
                hmp = chain->hmp;
@@ -1426,7 +1426,7 @@ hammer2_inode_xop_flush(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * Flush volume roots.  Avoid replication, we only want to
         * flush each hammer2_dev (hmp) once.
         */
-       for (j = thr->clindex - 1; j >= 0; --j) {
+       for (j = clindex - 1; j >= 0; --j) {
                if ((chain = xop->head.ip1->cluster.array[j].chain) != NULL) {
                        if (chain->hmp == hmp) {
                                chain = NULL;   /* safety */
@@ -1560,5 +1560,5 @@ hammer2_inode_xop_flush(hammer2_thread_t *thr, hammer2_xop_t *arg)
 
        hammer2_trans_done(hmp->spmp, 0);  /* spmp trans */
 skip:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, total_error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, total_error);
 }
index 3e8fe63..be7abc5 100644 (file)
@@ -749,7 +749,7 @@ hammer2_inode_create(hammer2_inode_t *dip, hammer2_inode_t *pip,
                lhcbase = lhc;
                sxop = hammer2_xop_alloc(dip, HAMMER2_XOP_MODIFYING);
                sxop->lhc = lhc;
-               hammer2_xop_start(&sxop->head, hammer2_xop_scanlhc);
+               hammer2_xop_start(&sxop->head, &hammer2_scanlhc_desc);
                while ((error = hammer2_xop_collect(&sxop->head, 0)) == 0) {
                        if (lhc != sxop->head.cluster.focus->bref.key)
                                break;
@@ -852,7 +852,7 @@ hammer2_inode_create(hammer2_inode_t *dip, hammer2_inode_t *pip,
        xop->meta.name_key = lhc;
        KKASSERT(name_len < HAMMER2_INODE_MAXNAME);
 
-       hammer2_xop_start(&xop->head, hammer2_inode_xop_create);
+       hammer2_xop_start(&xop->head, &hammer2_inode_create_desc);
 
        error = hammer2_xop_collect(&xop->head, 0);
 #if INODE_DEBUG
@@ -929,7 +929,7 @@ hammer2_dirent_create(hammer2_inode_t *dip, const char *name, size_t name_len,
                lhcbase = lhc;
                sxop = hammer2_xop_alloc(dip, HAMMER2_XOP_MODIFYING);
                sxop->lhc = lhc;
-               hammer2_xop_start(&sxop->head, hammer2_xop_scanlhc);
+               hammer2_xop_start(&sxop->head, &hammer2_scanlhc_desc);
                while ((error = hammer2_xop_collect(&sxop->head, 0)) == 0) {
                        if (lhc != sxop->head.cluster.focus->bref.key)
                                break;
@@ -962,7 +962,7 @@ hammer2_dirent_create(hammer2_inode_t *dip, const char *name, size_t name_len,
        KKASSERT(name_len < HAMMER2_INODE_MAXNAME);
        hammer2_xop_setname(&xop->head, name, name_len);
 
-       hammer2_xop_start(&xop->head, hammer2_inode_xop_mkdirent);
+       hammer2_xop_start(&xop->head, &hammer2_inode_mkdirent_desc);
 
        error = hammer2_xop_collect(&xop->head, 0);
 
@@ -1182,7 +1182,7 @@ killit:
                hammer2_inode_delayed_sideq(ip);
                atomic_set_int(&ip->flags, HAMMER2_INODE_ISDELETED);
                xop = hammer2_xop_alloc(ip, HAMMER2_XOP_MODIFYING);
-               hammer2_xop_start(&xop->head, hammer2_inode_xop_destroy);
+               hammer2_xop_start(&xop->head, &hammer2_inode_destroy_desc);
                error = hammer2_xop_collect(&xop->head, 0);
                hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
        }
@@ -1253,7 +1253,7 @@ hammer2_inode_chain_sync(hammer2_inode_t *ip)
 
                atomic_clear_int(&ip->flags, HAMMER2_INODE_RESIZED |
                                             HAMMER2_INODE_MODIFIED);
-               hammer2_xop_start(&xop->head, hammer2_inode_xop_chain_sync);
+               hammer2_xop_start(&xop->head, &hammer2_inode_chain_sync_desc);
                error = hammer2_xop_collect(&xop->head, 0);
                hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
                if (error == HAMMER2_ERROR_ENOENT)
@@ -1288,7 +1288,7 @@ hammer2_inode_chain_flush(hammer2_inode_t *ip)
        atomic_clear_int(&ip->flags, HAMMER2_INODE_DIRTYDATA);
        xop = hammer2_xop_alloc(ip, HAMMER2_XOP_MODIFYING |
                                    HAMMER2_XOP_INODE_STOP);
-       hammer2_xop_start(&xop->head, hammer2_inode_xop_flush);
+       hammer2_xop_start(&xop->head, &hammer2_inode_flush_desc);
        error = hammer2_xop_collect(&xop->head, HAMMER2_XOP_COLLECT_WAITALL);
        hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
        if (error == HAMMER2_ERROR_ENOENT)
@@ -1361,7 +1361,7 @@ hammer2_inode_run_sideq(hammer2_pfs_t *pmp, int doall)
                         */
                        xop = hammer2_xop_alloc(ip, HAMMER2_XOP_MODIFYING);
                        hammer2_xop_start(&xop->head,
-                                         hammer2_inode_xop_destroy);
+                                         &hammer2_inode_destroy_desc);
                        error = hammer2_xop_collect(&xop->head, 0);
                        /* XXX error handling */
                        hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
@@ -1400,7 +1400,7 @@ hammer2_inode_run_sideq(hammer2_pfs_t *pmp, int doall)
  * Helper to create a directory entry.
  */
 void
-hammer2_inode_xop_mkdirent(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_mkdirent(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_mkdirent_t *xop = &arg->xop_mkdirent;
        hammer2_chain_t *parent;
@@ -1411,9 +1411,9 @@ hammer2_inode_xop_mkdirent(hammer2_thread_t *thr, hammer2_xop_t *arg)
 
        if (hammer2_debug & 0x0001)
                kprintf("dirent_create lhc %016jx clindex %d\n",
-                       xop->lhc, thr->clindex);
+                       xop->lhc, clindex);
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        if (parent == NULL) {
                error = HAMMER2_ERROR_EIO;
@@ -1465,7 +1465,7 @@ fail:
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
        }
-       hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -1483,7 +1483,7 @@ fail:
  * frontend.
  */
 void
-hammer2_inode_xop_create(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_create(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_create_t *xop = &arg->xop_create;
        hammer2_chain_t *parent;
@@ -1493,9 +1493,9 @@ hammer2_inode_xop_create(hammer2_thread_t *thr, hammer2_xop_t *arg)
 
        if (hammer2_debug & 0x0001)
                kprintf("inode_create lhc %016jx clindex %d\n",
-                       xop->lhc, thr->clindex);
+                       xop->lhc, clindex);
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        if (parent == NULL) {
                error = HAMMER2_ERROR_EIO;
@@ -1535,7 +1535,7 @@ fail:
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
        }
-       hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -1548,7 +1548,7 @@ fail:
  * Generally used by hammer2_run_sideq()
  */
 void
-hammer2_inode_xop_destroy(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_destroy(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_destroy_t *xop = &arg->xop_destroy;
        hammer2_pfs_t *pmp;
@@ -1563,7 +1563,7 @@ hammer2_inode_xop_destroy(hammer2_thread_t *thr, hammer2_xop_t *arg)
        ip = xop->head.ip1;
        pmp = ip->pmp;
 
-       chain = hammer2_inode_chain(ip, thr->clindex, HAMMER2_RESOLVE_ALWAYS);
+       chain = hammer2_inode_chain(ip, clindex, HAMMER2_RESOLVE_ALWAYS);
        if (chain == NULL) {
                parent = NULL;
                error = HAMMER2_ERROR_EIO;
@@ -1582,7 +1582,7 @@ hammer2_inode_xop_destroy(hammer2_thread_t *thr, hammer2_xop_t *arg)
        hammer2_chain_delete(parent, chain, xop->head.mtid, 0);
        error = 0;
 done:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
        if (parent) {
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
@@ -1594,7 +1594,7 @@ done:
 }
 
 void
-hammer2_inode_xop_unlinkall(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_unlinkall(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_unlinkall_t *xop = &arg->xop_unlinkall;
        hammer2_chain_t *parent;
@@ -1605,7 +1605,7 @@ hammer2_inode_xop_unlinkall(hammer2_thread_t *thr, hammer2_xop_t *arg)
        /*
         * We need the precise parent chain to issue the deletion.
         */
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        chain = NULL;
        if (parent == NULL) {
@@ -1618,7 +1618,7 @@ hammer2_inode_xop_unlinkall(hammer2_thread_t *thr, hammer2_xop_t *arg)
        while (chain) {
                hammer2_chain_delete(parent, chain,
                                     xop->head.mtid, HAMMER2_DELETE_PERMANENT);
-               hammer2_xop_feed(&xop->head, chain, thr->clindex, chain->error);
+               hammer2_xop_feed(&xop->head, chain, clindex, chain->error);
                /* depend on function to unlock the shared lock */
                chain = hammer2_chain_next(&parent, chain, &key_next,
                                           key_next, xop->key_end,
@@ -1628,7 +1628,7 @@ hammer2_inode_xop_unlinkall(hammer2_thread_t *thr, hammer2_xop_t *arg)
 done:
        if (error == 0)
                error = HAMMER2_ERROR_ENOENT;
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
        if (parent) {
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
@@ -1640,7 +1640,7 @@ done:
 }
 
 void
-hammer2_inode_xop_connect(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_connect(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_connect_t *xop = &arg->xop_connect;
        hammer2_inode_data_t *wipdata;
@@ -1655,7 +1655,7 @@ hammer2_inode_xop_connect(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * for the create.  The lookup is expected to fail.
         */
        pmp = xop->head.ip1->pmp;
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        if (parent == NULL) {
                chain = NULL;
@@ -1681,7 +1681,7 @@ hammer2_inode_xop_connect(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * NOTE: Frontend must also adjust ip2->meta on success, we can't
         *       do it here.
         */
-       chain = hammer2_inode_chain(xop->head.ip2, thr->clindex,
+       chain = hammer2_inode_chain(xop->head.ip2, clindex,
                                    HAMMER2_RESOLVE_ALWAYS);
        error = hammer2_chain_modify(chain, xop->head.mtid, 0, 0);
        if (error)
@@ -1711,7 +1711,7 @@ hammer2_inode_xop_connect(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * Feed result back.
         */
 fail:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
        if (parent) {
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
@@ -1730,14 +1730,14 @@ fail:
  * manner inside the vfs_sync.
  */
 void
-hammer2_inode_xop_chain_sync(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_inode_chain_sync(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_fsync_t *xop = &arg->xop_fsync;
        hammer2_chain_t *parent;
        hammer2_chain_t *chain;
        int error;
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        chain = NULL;
        if (parent == NULL) {
@@ -1797,7 +1797,7 @@ hammer2_inode_xop_chain_sync(hammer2_thread_t *thr, hammer2_xop_t *arg)
                        hammer2_chain_unlock(parent);
                        hammer2_chain_drop(parent);
                        parent = hammer2_inode_chain(xop->head.ip1,
-                                                    thr->clindex,
+                                                    clindex,
                                                     HAMMER2_RESOLVE_ALWAYS);
                        kprintf("hammer2: TRUNCATE RESET on '%s'\n",
                                parent->data->ipdata.filename);
@@ -1827,6 +1827,6 @@ done:
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
        }
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
 }
 
index c3d9f76..ccb1852 100644 (file)
@@ -189,10 +189,23 @@ hammer2_rcvdmsg(kdmsg_msg_t *msg)
  * This function is called after KDMSG has automatically handled processing
  * of a LNK layer message (typically CONN or SPAN).
  *
- * We tag off the LNK_CONN to trigger our LNK_VOLCONF messages which
- * advertises all available hammer2 super-root volumes.
+ * We trampoline off LNK_CONN (link level connection advertising the presence
+ * of H2 partitions) to generate LNK_HAMMER2_VOLCONF's from the vol->copyinfo[]
+ * array in the volume header, and to generate LNK_SPANs advertising all PFSs
+ * available from that volume.  Currently the VOLCONFs go through the motions
+ * but are otherwise ignored.
  *
- * We collect span state
+ * We collect LNK_SPAN state for hammer2 peers and turn those into 'remote'
+ * PFSs which look similar to local (direct storage) PFSs.  These PFSs are
+ * merged with local PFSs and may be mounted locally or merged with other
+ * elements that might or might not include local cluster components (local
+ * PFSs).  If you wish to ensure that a mandatory PFS rendezvous is present
+ * even without network connectivity you would normally just create a dummy
+ * local PFS configured as PFSTYPE_CACHE (that can be small and ram-backed).
+ *
+ * Remote PFSs are object-based and operate using an (inode,key) DMSG API
+ * instead of hammer2_chain's + direct I/O.  A high level XOP API is employed
+ * to retain integrity across operations such as rename()s.
  */
 static void hammer2_update_spans(hammer2_dev_t *hmp, kdmsg_state_t *state);
 
index 6ad2a5f..7c41bcd 100644 (file)
@@ -758,7 +758,7 @@ hammer2_ioctl_pfs_delete(hammer2_inode_t *ip, void *data)
        hammer2_xop_setname(&xop->head, pfs->name, strlen(pfs->name));
        xop->isdir = 2;
        xop->dopermanent = H2DOPERM_PERMANENT | H2DOPERM_FORCE;
-       hammer2_xop_start(&xop->head, hammer2_xop_unlink);
+       hammer2_xop_start(&xop->head, &hammer2_unlink_desc);
 
        error = hammer2_xop_collect(&xop->head, 0);
 
@@ -1175,7 +1175,7 @@ hammer2_ioctl_destroy(hammer2_inode_t *ip, void *data)
                xop->dopermanent = H2DOPERM_PERMANENT |
                                   H2DOPERM_FORCE |
                                   H2DOPERM_IGNINO;
-               hammer2_xop_start(&xop->head, hammer2_xop_unlink);
+               hammer2_xop_start(&xop->head, &hammer2_unlink_desc);
 
                error = hammer2_xop_collect(&xop->head, 0);
                error = hammer2_error_to_errno(error);
@@ -1200,7 +1200,7 @@ hammer2_ioctl_destroy(hammer2_inode_t *ip, void *data)
 
                xop = hammer2_xop_alloc(pmp->iroot, HAMMER2_XOP_MODIFYING);
                xop->lhc = iocd->inum;
-               hammer2_xop_start(&xop->head, hammer2_xop_delete);
+               hammer2_xop_start(&xop->head, &hammer2_delete_desc);
                error = hammer2_xop_collect(&xop->head, 0);
                error = hammer2_error_to_errno(error);
                hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
index 2b70108..63af632 100644 (file)
@@ -86,10 +86,6 @@ struct objcache *cache_buffer_write;
  *     until running transactions complete separately from the normal
  *     transaction sequencing.  FIXME TODO.
  */
-static void hammer2_strategy_xop_read(hammer2_thread_t *thr,
-                               hammer2_xop_t *arg);
-static void hammer2_strategy_xop_write(hammer2_thread_t *thr,
-                               hammer2_xop_t *arg);
 static int hammer2_strategy_read(struct vop_strategy_args *ap);
 static int hammer2_strategy_write(struct vop_strategy_args *ap);
 static void hammer2_strategy_read_completion(hammer2_chain_t *focus,
@@ -273,7 +269,7 @@ hammer2_strategy_read(struct vop_strategy_args *ap)
        xop->bio = bio;
        xop->lbase = lbase;
        hammer2_mtx_init(&xop->lock, "h2bior");
-       hammer2_xop_start(&xop->head, hammer2_strategy_xop_read);
+       hammer2_xop_start(&xop->head, &hammer2_strategy_read_desc);
        /* asynchronous completion */
 
        return(0);
@@ -284,9 +280,8 @@ hammer2_strategy_read(struct vop_strategy_args *ap)
  * its data.  The frontend is asynchronous, so we are also responsible
  * for racing to terminate the frontend.
  */
-static
 void
-hammer2_strategy_xop_read(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_strategy_read(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_strategy_t *xop = &arg->xop_strategy;
        hammer2_chain_t *parent;
@@ -318,7 +313,7 @@ hammer2_strategy_xop_read(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * (3) !hammer2_double_buffer, and issue a direct read into the
         * logical buffer.
         */
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
        if (parent) {
@@ -333,7 +328,7 @@ hammer2_strategy_xop_read(hammer2_thread_t *thr, hammer2_xop_t *arg)
                error = HAMMER2_ERROR_EIO;
                chain = NULL;
        }
-       error = hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       error = hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -407,7 +402,7 @@ hammer2_strategy_xop_read(hammer2_thread_t *thr, hammer2_xop_t *arg)
                hammer2_mtx_unlock(&xop->lock);
                break;
        default:
-               kprintf("strategy_xop_read: error %08x loff=%016jx\n",
+               kprintf("xop_strategy_read: error %08x loff=%016jx\n",
                        error, bp->b_loffset);
                xop->finished = 1;
                hammer2_mtx_unlock(&xop->lock);
@@ -516,7 +511,6 @@ static void hammer2_write_bp(hammer2_chain_t *chain, char *data,
                                hammer2_tid_t mtid, int *errorp,
                                int check_algo);
 
-static
 int
 hammer2_strategy_write(struct vop_strategy_args *ap)
 {      
@@ -542,7 +536,7 @@ hammer2_strategy_write(struct vop_strategy_args *ap)
        xop->bio = bio;
        xop->lbase = bio->bio_offset;
        hammer2_mtx_init(&xop->lock, "h2biow");
-       hammer2_xop_start(&xop->head, hammer2_strategy_xop_write);
+       hammer2_xop_start(&xop->head, &hammer2_strategy_write_desc);
        /* asynchronous completion */
 
        hammer2_lwinprog_wait(pmp, hammer2_flush_pipe);
@@ -559,9 +553,8 @@ hammer2_strategy_write(struct vop_strategy_args *ap)
  * the frontend).  To accomplish this we copy the data to the per-thr
  * scratch buffer.
  */
-static
 void
-hammer2_strategy_xop_write(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_strategy_write(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_strategy_t *xop = &arg->xop_strategy;
        hammer2_chain_t *parent;
@@ -592,7 +585,7 @@ hammer2_strategy_xop_write(hammer2_thread_t *thr, hammer2_xop_t *arg)
        bp = bio->bio_buf;              /* ephermal */
        ip = xop->head.ip1;             /* retained by ref */
        bio_offset = bio->bio_offset;
-       bio_data = thr->scratch;
+       bio_data = scratch;
 
        /* hammer2_trans_init(parent->hmp->spmp, HAMMER2_TRANS_BUFCACHE); */
 
@@ -609,7 +602,7 @@ hammer2_strategy_xop_write(hammer2_thread_t *thr, hammer2_xop_t *arg)
        /*
         * Actual operation
         */
-       parent = hammer2_inode_chain(ip, thr->clindex, HAMMER2_RESOLVE_ALWAYS);
+       parent = hammer2_inode_chain(ip, clindex, HAMMER2_RESOLVE_ALWAYS);
        hammer2_write_file_core(bio_data, ip, &parent,
                                lbase, IO_ASYNC, pblksize,
                                xop->head.mtid, &error);
@@ -618,7 +611,7 @@ hammer2_strategy_xop_write(hammer2_thread_t *thr, hammer2_xop_t *arg)
                hammer2_chain_drop(parent);
                parent = NULL;  /* safety */
        }
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
 
        /*
         * Try to complete the operation on behalf of the front-end.
@@ -662,7 +655,7 @@ hammer2_strategy_xop_write(hammer2_thread_t *thr, hammer2_xop_t *arg)
                bp->b_error = 0;
                biodone(bio);
        } else {
-               kprintf("strategy_xop_write: error %d loff=%016jx\n",
+               kprintf("xop_strategy_write: error %d loff=%016jx\n",
                        error, bp->b_loffset);
                bp->b_flags |= B_ERROR;
                bp->b_error = EIO;
index f06f73d..c79480c 100644 (file)
@@ -408,7 +408,7 @@ hammer2_sync_slaves(hammer2_thread_t *thr, hammer2_inode_t *ip,
 
                hammer2_inode_lock(ip, HAMMER2_RESOLVE_SHARED);
                xop2 = hammer2_xop_alloc(ip, HAMMER2_XOP_MODIFYING);
-               hammer2_xop_start_except(&xop2->head, hammer2_xop_ipcluster,
+               hammer2_xop_start_except(&xop2->head, &hammer2_ipcluster_desc,
                                         idx);
                hammer2_inode_unlock(ip);
                merror = hammer2_xop_collect(&xop2->head, 0);
@@ -451,7 +451,7 @@ hammer2_sync_slaves(hammer2_thread_t *thr, hammer2_inode_t *ip,
        xop->lookup_flags = HAMMER2_LOOKUP_SHARED |
                            HAMMER2_LOOKUP_NODIRECT |
                            HAMMER2_LOOKUP_ALWAYS;
-       hammer2_xop_start_except(&xop->head, hammer2_xop_scanall, idx);
+       hammer2_xop_start_except(&xop->head, &hammer2_scanall_desc, idx);
        parent = hammer2_inode_chain(ip, idx,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
@@ -669,7 +669,7 @@ hammer2_sync_slaves(hammer2_thread_t *thr, hammer2_inode_t *ip,
 
                hammer2_inode_lock(ip, HAMMER2_RESOLVE_SHARED);
                xop2 = hammer2_xop_alloc(ip, HAMMER2_XOP_MODIFYING);
-               hammer2_xop_start_except(&xop2->head, hammer2_xop_ipcluster,
+               hammer2_xop_start_except(&xop2->head, &hammer2_ipcluster_desc,
                                         idx);
                hammer2_inode_unlock(ip);
                merror = hammer2_xop_collect(&xop2->head, 0);
index 1f9963e..43c35e0 100644 (file)
@@ -1877,7 +1877,7 @@ hammer2_vfs_vget(struct mount *mp, struct vnode *dvp,
         */
        xop = hammer2_xop_alloc(pmp->iroot, 0);
        xop->lhc = inum;
-       hammer2_xop_start(&xop->head, hammer2_xop_lookup);
+       hammer2_xop_start(&xop->head, &hammer2_lookup_desc);
        error = hammer2_xop_collect(&xop->head, 0);
 
        if (error == 0)
@@ -1918,7 +1918,7 @@ hammer2_vfs_root(struct mount *mp, struct vnode **vpp)
                const hammer2_inode_meta_t *meta;
 
                xop = hammer2_xop_alloc(pmp->iroot, HAMMER2_XOP_MODIFYING);
-               hammer2_xop_start(&xop->head, hammer2_xop_ipcluster);
+               hammer2_xop_start(&xop->head, &hammer2_ipcluster_desc);
                error = hammer2_xop_collect(&xop->head, 0);
 
                if (error == 0) {
@@ -2501,7 +2501,7 @@ hammer2_vfs_sync(struct mount *mp, int waitfor)
                                                       HAMMER2_XOP_INODE_STOP |
                                                       HAMMER2_XOP_VOLHDR);
                }
-               hammer2_xop_start(&xop->head, hammer2_inode_xop_flush);
+               hammer2_xop_start(&xop->head, &hammer2_inode_flush_desc);
                error = hammer2_xop_collect(&xop->head,
                                            HAMMER2_XOP_COLLECT_WAITALL);
                hammer2_xop_retire(&xop->head, HAMMER2_XOPMASK_VOP);
index fb4f321..9968ba0 100644 (file)
@@ -619,7 +619,7 @@ hammer2_vop_readdir(struct vop_readdir_args *ap)
         */
        xop = hammer2_xop_alloc(ip, 0);
        xop->lkey = lkey;
-       hammer2_xop_start(&xop->head, hammer2_xop_readdir);
+       hammer2_xop_start(&xop->head, &hammer2_readdir_desc);
 
        for (;;) {
                const hammer2_inode_data_t *ripdata;
@@ -1284,7 +1284,7 @@ hammer2_vop_nresolve(struct vop_nresolve_args *ap)
         * Note: In DragonFly the kernel handles '.' and '..'.
         */
        hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);
-       hammer2_xop_start(&xop->head, hammer2_xop_nresolve);
+       hammer2_xop_start(&xop->head, &hammer2_nresolve_desc);
 
        error = hammer2_xop_collect(&xop->head, 0);
        error = hammer2_error_to_errno(error);
@@ -1876,7 +1876,7 @@ hammer2_vop_nremove(struct vop_nremove_args *ap)
        isopen = cache_isopen(ap->a_nch);
        xop->isdir = 0;
        xop->dopermanent = 0;
-       hammer2_xop_start(&xop->head, hammer2_xop_unlink);
+       hammer2_xop_start(&xop->head, &hammer2_unlink_desc);
 
        /*
         * Collect the real inode and adjust nlinks, destroy the real
@@ -1953,7 +1953,7 @@ hammer2_vop_nrmdir(struct vop_nrmdir_args *ap)
        isopen = cache_isopen(ap->a_nch);
        xop->isdir = 1;
        xop->dopermanent = 0;
-       hammer2_xop_start(&xop->head, hammer2_xop_unlink);
+       hammer2_xop_start(&xop->head, &hammer2_unlink_desc);
 
        /*
         * Collect the real inode and adjust nlinks, destroy the real
@@ -2085,59 +2085,6 @@ hammer2_vop_nrename(struct vop_nrename_args *ap)
                hammer2_inode_lock(ip, 0);
        }
 
-#if 0
-       /*
-        * Delete the target namespace.
-        *
-        * REMOVED - NOW FOLDED INTO XOP_NRENAME OPERATION
-        */
-       {
-               hammer2_xop_unlink_t *xop2;
-               hammer2_inode_t *tip;
-               int isopen;
-
-               /*
-                * The unlink XOP unlinks the path from the directory and
-                * locates and returns the cluster associated with the real
-                * inode.  We have to handle nlinks here on the frontend.
-                */
-               xop2 = hammer2_xop_alloc(tdip, HAMMER2_XOP_MODIFYING);
-               hammer2_xop_setname(&xop2->head, tname, tname_len);
-               isopen = cache_isopen(ap->a_tnch);
-               xop2->isdir = -1;
-               xop2->dopermanent = 0;
-               hammer2_xop_start(&xop2->head, hammer2_xop_unlink);
-
-               /*
-                * Collect the real inode and adjust nlinks, destroy the real
-                * inode if nlinks transitions to 0 and it was the real inode
-                * (else it has already been removed).
-                */
-               tnch_error = hammer2_xop_collect(&xop2->head, 0);
-               tnch_error = hammer2_error_to_errno(tnch_error);
-               /* hammer2_inode_unlock(tdip); */
-
-               if (tnch_error == 0) {
-                       tip = hammer2_inode_get(tdip->pmp, NULL,
-                                               &xop2->head, -1);
-                       hammer2_xop_retire(&xop2->head, HAMMER2_XOPMASK_VOP);
-                       if (tip) {
-                               hammer2_inode_unlink_finisher(tip, isopen);
-                               hammer2_inode_unlock(tip);
-                       }
-               } else {
-                       hammer2_xop_retire(&xop2->head, HAMMER2_XOPMASK_VOP);
-               }
-               /* hammer2_inode_lock(tdip, 0); */
-
-               if (tnch_error && tnch_error != ENOENT) {
-                       error = tnch_error;
-                       goto done2;
-               }
-               update_tdip = 1;
-       }
-#endif
-
        /*
         * Resolve the collision space for (tdip, tname, tname_len)
         *
@@ -2152,7 +2099,7 @@ hammer2_vop_nrename(struct vop_nrename_args *ap)
                lhcbase = tlhc;
                sxop = hammer2_xop_alloc(tdip, HAMMER2_XOP_MODIFYING);
                sxop->lhc = tlhc;
-               hammer2_xop_start(&sxop->head, hammer2_xop_scanlhc);
+               hammer2_xop_start(&sxop->head, &hammer2_scanlhc_desc);
                while ((error = hammer2_xop_collect(&sxop->head, 0)) == 0) {
                        if (tlhc != sxop->head.cluster.focus->bref.key)
                                break;
@@ -2191,7 +2138,7 @@ hammer2_vop_nrename(struct vop_nrename_args *ap)
                hammer2_xop_setip3(&xop4->head, tdip);
                hammer2_xop_setname(&xop4->head, fname, fname_len);
                hammer2_xop_setname2(&xop4->head, tname, tname_len);
-               hammer2_xop_start(&xop4->head, hammer2_xop_nrename);
+               hammer2_xop_start(&xop4->head, &hammer2_nrename_desc);
 
                error = hammer2_xop_collect(&xop4->head, 0);
                error = hammer2_error_to_errno(error);
index 0391b35..93fffb9 100644 (file)
@@ -161,13 +161,13 @@ checkdirempty(hammer2_chain_t *oparent, hammer2_chain_t *ochain, int clindex)
  * to the inode_tid and modify_tid.
  */
 void
-hammer2_xop_ipcluster(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_ipcluster(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_ipcluster_t *xop = &arg->xop_ipcluster;
        hammer2_chain_t *chain;
        int error;
 
-       chain = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       chain = hammer2_inode_chain(xop->head.ip1, clindex,
                                    HAMMER2_RESOLVE_ALWAYS |
                                    HAMMER2_RESOLVE_SHARED);
        if (chain)
@@ -175,7 +175,7 @@ hammer2_xop_ipcluster(hammer2_thread_t *thr, hammer2_xop_t *arg)
        else
                error = HAMMER2_ERROR_EIO;
                
-       hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -186,7 +186,7 @@ hammer2_xop_ipcluster(hammer2_thread_t *thr, hammer2_xop_t *arg)
  * Backend for hammer2_vop_readdir()
  */
 void
-hammer2_xop_readdir(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_readdir(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_readdir_t *xop = &arg->xop_readdir;
        hammer2_chain_t *parent;
@@ -203,7 +203,7 @@ hammer2_xop_readdir(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * The inode's chain is the iterator.  If we cannot acquire it our
         * contribution ends here.
         */
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
        if (parent == NULL) {
@@ -223,7 +223,7 @@ hammer2_xop_readdir(hammer2_thread_t *thr, hammer2_xop_t *arg)
                                             &error, HAMMER2_LOOKUP_SHARED);
        }
        while (chain) {
-               error = hammer2_xop_feed(&xop->head, chain, thr->clindex, 0);
+               error = hammer2_xop_feed(&xop->head, chain, clindex, 0);
                if (error)
                        goto break2;
                chain = hammer2_chain_next(&parent, chain, &key_next,
@@ -238,14 +238,14 @@ break2:
        hammer2_chain_unlock(parent);
        hammer2_chain_drop(parent);
 done:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
 }
 
 /*
  * Backend for hammer2_vop_nresolve()
  */
 void
-hammer2_xop_nresolve(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_nresolve(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_nresolve_t *xop = &arg->xop_nresolve;
        hammer2_chain_t *parent;
@@ -256,7 +256,7 @@ hammer2_xop_nresolve(hammer2_thread_t *thr, hammer2_xop_t *arg)
        hammer2_key_t lhc;
        int error;
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
        if (parent == NULL) {
@@ -296,7 +296,7 @@ hammer2_xop_nresolve(hammer2_thread_t *thr, hammer2_xop_t *arg)
                        lhc = chain->bref.embed.dirent.inum;
                        error = hammer2_chain_inode_find(chain->pmp,
                                                         lhc,
-                                                        thr->clindex,
+                                                        clindex,
                                                         HAMMER2_LOOKUP_SHARED,
                                                         &parent,
                                                         &chain);
@@ -305,7 +305,7 @@ hammer2_xop_nresolve(hammer2_thread_t *thr, hammer2_xop_t *arg)
                error = chain->error;
        }
 done:
-       error = hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       error = hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -330,7 +330,7 @@ done:
  *          is responsible for the final disposition of the actual inode.
  */
 void
-hammer2_xop_unlink(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_unlink(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_unlink_t *xop = &arg->xop_unlink;
        hammer2_chain_t *parent;
@@ -345,7 +345,7 @@ again:
        /*
         * Requires exclusive lock
         */
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        chain = NULL;
        if (parent == NULL) {
@@ -421,7 +421,7 @@ again:
                        error = hammer2_chain_delete(parent, chain,
                                             xop->head.mtid, dopermanent);
                } else if (type == HAMMER2_OBJTYPE_DIRECTORY &&
-                          (error = checkdirempty(parent, chain, thr->clindex)) != 0) {
+                          (error = checkdirempty(parent, chain, clindex)) != 0) {
                        /*
                         * error may be EAGAIN or ENOTEMPTY
                         */
@@ -471,7 +471,7 @@ again:
                lhc = chain->bref.embed.dirent.inum;
 
                error2 = hammer2_chain_inode_find(chain->pmp, lhc,
-                                                 thr->clindex, 0,
+                                                 clindex, 0,
                                                  &parent, &chain);
                if (error2) {
                        kprintf("inode_find: %016jx %p failed\n",
@@ -487,7 +487,7 @@ again:
         * hammer2_inode_unlink_finisher().
         */
 done:
-       hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, chain, clindex, error);
        if (chain) {
                hammer2_chain_unlock(chain);
                hammer2_chain_drop(chain);
@@ -511,7 +511,7 @@ done:
  *      inode's nlinks, if present.
  */
 void
-hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_nrename(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_nrename_t *xop = &arg->xop_nrename;
        hammer2_pfs_t *pmp;
@@ -537,7 +537,7 @@ hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *arg)
                /*
                 * Find ip's direct parent chain.
                 */
-               chain = hammer2_inode_chain(ip, thr->clindex,
+               chain = hammer2_inode_chain(ip, clindex,
                                            HAMMER2_RESOLVE_ALWAYS);
                if (chain == NULL) {
                        error = HAMMER2_ERROR_EIO;
@@ -558,7 +558,7 @@ hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *arg)
                const char *name;
                size_t name_len;
 
-               parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+               parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                             HAMMER2_RESOLVE_ALWAYS);
                if (parent == NULL) {
                        kprintf("xop_nrename: NULL parent\n");
@@ -713,7 +713,7 @@ hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * This will result in some ping-ponging of the directory key
         * iterator but that is ok.
         */
-       parent = hammer2_inode_chain(xop->head.ip3, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip3, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        if (parent == NULL) {
                error = HAMMER2_ERROR_EIO;
@@ -764,7 +764,7 @@ hammer2_xop_nrename(hammer2_thread_t *thr, hammer2_xop_t *arg)
                                             xop->head.mtid, 0, 0);
        }
 done:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
        if (parent) {
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
@@ -781,7 +781,7 @@ done:
  * Used by the inode create code to locate an unused lhc.
  */
 void
-hammer2_xop_scanlhc(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_scanlhc(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_scanlhc_t *xop = &arg->xop_scanlhc;
        hammer2_chain_t *parent;
@@ -789,7 +789,7 @@ hammer2_xop_scanlhc(hammer2_thread_t *thr, hammer2_xop_t *arg)
        hammer2_key_t key_next;
        int error = 0;
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
        if (parent == NULL) {
@@ -810,7 +810,7 @@ hammer2_xop_scanlhc(hammer2_thread_t *thr, hammer2_xop_t *arg)
                                     HAMMER2_LOOKUP_ALWAYS |
                                     HAMMER2_LOOKUP_SHARED);
        while (chain) {
-               error = hammer2_xop_feed(&xop->head, chain, thr->clindex, 0);
+               error = hammer2_xop_feed(&xop->head, chain, clindex, 0);
                if (error) {
                        hammer2_chain_unlock(chain);
                        hammer2_chain_drop(chain);
@@ -825,7 +825,7 @@ hammer2_xop_scanlhc(hammer2_thread_t *thr, hammer2_xop_t *arg)
                                           HAMMER2_LOOKUP_SHARED);
        }
 done:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
        if (parent) {
                hammer2_chain_unlock(parent);
                hammer2_chain_drop(parent);
@@ -836,7 +836,7 @@ done:
  * Generic lookup of a specific key.
  */
 void
-hammer2_xop_lookup(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_lookup(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_scanlhc_t *xop = &arg->xop_scanlhc;
        hammer2_chain_t *parent;
@@ -844,7 +844,7 @@ hammer2_xop_lookup(hammer2_thread_t *thr, hammer2_xop_t *arg)
        hammer2_key_t key_next;
        int error = 0;
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS |
                                     HAMMER2_RESOLVE_SHARED);
        chain = NULL;
@@ -868,7 +868,7 @@ hammer2_xop_lookup(hammer2_thread_t *thr, hammer2_xop_t *arg)
                else
                        error = HAMMER2_ERROR_ENOENT;
        }
-       hammer2_xop_feed(&xop->head, chain, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, chain, clindex, error);
 
 done:
        if (chain) {
@@ -882,7 +882,7 @@ done:
 }
 
 void
-hammer2_xop_delete(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_delete(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_scanlhc_t *xop = &arg->xop_scanlhc;
        hammer2_chain_t *parent;
@@ -890,7 +890,7 @@ hammer2_xop_delete(hammer2_thread_t *thr, hammer2_xop_t *arg)
        hammer2_key_t key_next;
        int error = 0;
 
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     HAMMER2_RESOLVE_ALWAYS);
        chain = NULL;
        if (parent == NULL) {
@@ -916,7 +916,7 @@ hammer2_xop_delete(hammer2_thread_t *thr, hammer2_xop_t *arg)
                error = hammer2_chain_delete(parent, chain, xop->head.mtid,
                                             HAMMER2_DELETE_PERMANENT);
        }
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
 
 done:
        if (chain) {
@@ -938,7 +938,7 @@ done:
  *         retained.
  */
 void
-hammer2_xop_scanall(hammer2_thread_t *thr, hammer2_xop_t *arg)
+hammer2_xop_scanall(hammer2_xop_t *arg, void *scratch, int clindex)
 {
        hammer2_xop_scanall_t *xop = &arg->xop_scanall;
        hammer2_chain_t *parent;
@@ -956,7 +956,7 @@ hammer2_xop_scanall(hammer2_thread_t *thr, hammer2_xop_t *arg)
         * The inode's chain is the iterator.  If we cannot acquire it our
         * contribution ends here.
         */
-       parent = hammer2_inode_chain(xop->head.ip1, thr->clindex,
+       parent = hammer2_inode_chain(xop->head.ip1, clindex,
                                     xop->resolve_flags);
        if (parent == NULL) {
                kprintf("xop_readdir: NULL parent\n");
@@ -971,7 +971,7 @@ hammer2_xop_scanall(hammer2_thread_t *thr, hammer2_xop_t *arg)
                                     xop->key_beg, xop->key_end,
                                     &error, xop->lookup_flags);
        while (chain) {
-               error = hammer2_xop_feed(&xop->head, chain, thr->clindex, 0);
+               error = hammer2_xop_feed(&xop->head, chain, clindex, 0);
                if (error)
                        goto break2;
                chain = hammer2_chain_next(&parent, chain, &key_next,
@@ -986,5 +986,5 @@ break2:
        hammer2_chain_unlock(parent);
        hammer2_chain_drop(parent);
 done:
-       hammer2_xop_feed(&xop->head, NULL, thr->clindex, error);
+       hammer2_xop_feed(&xop->head, NULL, clindex, error);
 }