hammer2 - Messaging layer separation work part 1
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 25 Oct 2012 04:27:50 +0000 (21:27 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 25 Oct 2012 04:27:50 +0000 (21:27 -0700)
This work is to separate the network messaging format and various
lower layers out from hammer2 and into their own 'dmsg*' files.

* Factor low level messaging structures into sys/dmsg.h

* Rename HAMMER2 -> DMSG.

16 files changed:
sbin/hammer2/cmd_debug.c
sbin/hammer2/cmd_service.c
sbin/hammer2/crypto.c
sbin/hammer2/hammer2.h
sbin/hammer2/icrc.c
sbin/hammer2/msg.c
sbin/hammer2/msg_lnk.c
sbin/hammer2/network.h
sbin/hammer2/subs.c
sys/sys/dmsg.h [moved from sys/vfs/hammer2/hammer2_network.h with 75% similarity]
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_disk.h
sys/vfs/hammer2/hammer2_ioctl.h
sys/vfs/hammer2/hammer2_msg.c
sys/vfs/hammer2/hammer2_msgops.c
sys/vfs/hammer2/hammer2_vfsops.c

index 369e913..bc3f16f 100644 (file)
@@ -66,8 +66,7 @@ cmd_shell(const char *hostname)
        fcntl(0, F_SETFL, O_NONBLOCK);
        printf("debug: connected\n");
 
-       msg = hammer2_msg_alloc(iocom.router, 0, HAMMER2_DBG_SHELL,
-                               NULL, NULL);
+       msg = hammer2_msg_alloc(iocom.router, 0, DMSG_DBG_SHELL, NULL, NULL);
        hammer2_msg_write(msg);
        hammer2_iocom_core(&iocom);
        fprintf(stderr, "debug: disconnected\n");
@@ -83,9 +82,9 @@ static
 void
 shell_rcvmsg(hammer2_msg_t *msg)
 {
-       switch(msg->any.head.cmd & HAMMER2_MSGF_TRANSMASK) {
-       case HAMMER2_LNK_ERROR:
-       case HAMMER2_LNK_ERROR | HAMMER2_MSGF_REPLY:
+       switch(msg->any.head.cmd & DMSGF_TRANSMASK) {
+       case DMSG_LNK_ERROR:
+       case DMSG_LNK_ERROR | DMSGF_REPLY:
                /*
                 * One-way non-transactional LNK_ERROR messages typically
                 * indicate a connection failure.  Error code 0 is used by
@@ -98,17 +97,17 @@ shell_rcvmsg(hammer2_msg_t *msg)
                        write(1, "debug> ", 7);
                }
                break;
-       case HAMMER2_LNK_ERROR | HAMMER2_MSGF_DELETE:
+       case DMSG_LNK_ERROR | DMSGF_DELETE:
                /* ignore termination of LNK_CONN */
                break;
-       case HAMMER2_DBG_SHELL:
+       case DMSG_DBG_SHELL:
                /*
                 * We send the commands, not accept them.
                 * (one-way message, not transactional)
                 */
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
-       case HAMMER2_DBG_SHELL | HAMMER2_MSGF_REPLY:
+       case DMSG_DBG_SHELL | DMSGF_REPLY:
                /*
                 * A reply from the remote is data we copy to stdout.
                 * (one-way message, not transactional)
@@ -118,11 +117,11 @@ shell_rcvmsg(hammer2_msg_t *msg)
                        write(1, msg->aux_data, strlen(msg->aux_data));
                }
                break;
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_CREATE:
+       case DMSG_LNK_CONN | DMSGF_CREATE:
                fprintf(stderr, "Debug Shell is ignoring received LNK_CONN\n");
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_DELETE:
+       case DMSG_LNK_CONN | DMSGF_DELETE:
                break;
        default:
                /*
@@ -130,10 +129,10 @@ shell_rcvmsg(hammer2_msg_t *msg)
                 * transactions with an error.
                 */
                fprintf(stderr, "Unknown message: %s\n", hammer2_msg_str(msg));
-               if (msg->any.head.cmd & HAMMER2_MSGF_CREATE)
-                       hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
-               if (msg->any.head.cmd & HAMMER2_MSGF_DELETE)
-                       hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               if (msg->any.head.cmd & DMSGF_CREATE)
+                       hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
+               if (msg->any.head.cmd & DMSGF_DELETE)
+                       hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
        }
 }
@@ -151,7 +150,7 @@ shell_ttymsg(hammer2_iocom_t *iocom)
                if (len && buf[len - 1] == '\n')
                        buf[--len] = 0;
                ++len;
-               msg = hammer2_msg_alloc(iocom->router, len, HAMMER2_DBG_SHELL,
+               msg = hammer2_msg_alloc(iocom->router, len, DMSG_DBG_SHELL,
                                        NULL, NULL);
                bcopy(buf, msg->aux_data, len);
                hammer2_msg_write(msg);
@@ -174,8 +173,8 @@ shell_ttymsg(hammer2_iocom_t *iocom)
 void
 hammer2_msg_dbg(hammer2_msg_t *msg)
 {
-       switch(msg->any.head.cmd & HAMMER2_MSGF_CMDSWMASK) {
-       case HAMMER2_DBG_SHELL:
+       switch(msg->any.head.cmd & DMSGF_CMDSWMASK) {
+       case DMSG_DBG_SHELL:
                /*
                 * This is a command which we must process.
                 * When we are finished we generate a final reply.
@@ -185,7 +184,7 @@ hammer2_msg_dbg(hammer2_msg_t *msg)
                hammer2_shell_parse(msg);
                hammer2_msg_reply(msg, 0);
                break;
-       case HAMMER2_DBG_SHELL | HAMMER2_MSGF_REPLY:
+       case DMSG_DBG_SHELL | DMSGF_REPLY:
                /*
                 * A reply just prints out the string.  No newline is added
                 * (it is expected to be embedded if desired).
@@ -196,7 +195,7 @@ hammer2_msg_dbg(hammer2_msg_t *msg)
                        write(2, msg->aux_data, strlen(msg->aux_data));
                break;
        default:
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
        }
 }
@@ -276,8 +275,7 @@ router_printf(hammer2_router_t *router, const char *ctl, ...)
        va_end(va);
        len = strlen(buf) + 1;
 
-       rmsg = hammer2_msg_alloc(router, len, HAMMER2_DBG_SHELL |
-                                             HAMMER2_MSGF_REPLY,
+       rmsg = hammer2_msg_alloc(router, len, DMSG_DBG_SHELL | DMSGF_REPLY,
                                 NULL, NULL);
        bcopy(buf, rmsg->aux_data, len);
 
index 0fd3ea7..f387b2e 100644 (file)
 
 #include "hammer2.h"
 
-static void *master_accept(void *data);
+static void *service_thread(void *data);
+static void *udev_thread(void *data);
 static void master_auth_signal(hammer2_router_t *router);
 static void master_auth_rxmsg(hammer2_msg_t *msg);
 static void master_link_signal(hammer2_router_t *router);
 static void master_link_rxmsg(hammer2_msg_t *msg);
 static void master_reconnect(const char *mntpt);
+static void udev_check_disks(void);
 
 /*
  * Start-up the master listener daemon for the machine.
@@ -106,7 +108,7 @@ cmd_service(void)
         * In debug mode this call will create the pthread without forking
         * and set NormalExit to 0, instead of fork.
         */
-       hammer2_demon(master_accept, (void *)(intptr_t)lfd);
+       hammer2_demon(service_thread, (void *)(intptr_t)lfd);
        if (NormalExit)
                close(lfd);
        return 0;
@@ -118,7 +120,7 @@ cmd_service(void)
  */
 static
 void *
-master_accept(void *data)
+service_thread(void *data)
 {
        struct sockaddr_in asin;
        socklen_t alen;
@@ -137,6 +139,12 @@ master_accept(void *data)
        setproctitle("hammer2 master listen");
        pthread_detach(pthread_self());
 
+       /*
+        * Start up a thread to handle block device monitoring
+        */
+       thread = NULL;
+       pthread_create(&thread, NULL, udev_thread, NULL);
+
        /*
         * Scan existing hammer2 mounts and reconnect to them using
         * HAMMER2IOC_RECLUSTER.
@@ -160,7 +168,7 @@ master_accept(void *data)
                        break;
                }
                thread = NULL;
-               fprintf(stderr, "master_accept: accept fd %d\n", fd);
+               fprintf(stderr, "service_thread: accept fd %d\n", fd);
                info = malloc(sizeof(*info));
                bzero(info, sizeof(*info));
                info->fd = fd;
@@ -170,6 +178,72 @@ master_accept(void *data)
        return (NULL);
 }
 
+/*
+ * Monitor block devices.  Currently polls every ~10 seconds or so.
+ */
+static
+void *
+udev_thread(void *data __unused)
+{
+       int     fd;
+       int     seq = 0;
+
+       pthread_detach(pthread_self());
+
+       if ((fd = open(UDEV_DEVICE_PATH, O_RDWR)) < 0) {
+               fprintf(stderr, "udev_thread: unable to open \"%s\"\n",
+                       UDEV_DEVICE_PATH);
+               pthread_exit(NULL);
+       }
+       udev_check_disks();
+       while (ioctl(fd, UDEVWAIT, &seq) == 0) {
+               udev_check_disks();
+               sleep(1);
+       }
+       return (NULL);
+}
+
+/*
+ * Retrieve the list of disk attachments and attempt to export
+ * them.
+ */
+static
+void
+udev_check_disks(void)
+{
+       char tmpbuf[1024];
+       char *buf = NULL;
+       int error;
+       size_t n;
+
+       for (;;) {
+               n = 0;
+               error = sysctlbyname("kern.disks", NULL, &n, NULL, 0);
+               if (error < 0 || n == 0)
+                       break;
+               if (n >= sizeof(tmpbuf))
+                       buf = malloc(n + 1);
+               else
+                       buf = tmpbuf;
+               error = sysctlbyname("kern.disks", buf, &n, NULL, 0);
+               if (error == 0) {
+                       buf[n] = 0;
+                       break;
+               }
+               if (buf != tmpbuf) {
+                       free(buf);
+                       buf = NULL;
+               }
+               if (errno != ENOMEM)
+                       break;
+       }
+       if (buf) {
+               fprintf(stderr, "DISKS: %s\n", buf);
+               if (buf != tmpbuf)
+                       free(buf);
+       }
+}
+
 /*
  * Normally the mount program supplies a cluster communications
  * descriptor to the hammer2 vfs on mount, but if you kill the service
@@ -276,8 +350,8 @@ master_auth_signal(hammer2_router_t *router)
         *
         * XXX put additional authentication states here?
         */
-       msg = hammer2_msg_alloc(router, 0, HAMMER2_LNK_CONN |
-                                          HAMMER2_MSGF_CREATE,
+       msg = hammer2_msg_alloc(router, 0, DMSG_LNK_CONN |
+                                          DMSGF_CREATE,
                                master_auth_conn_rx, NULL);
        msg->any.lnk_conn.peer_mask = (uint64_t)-1;
        msg->any.lnk_conn.peer_type = HAMMER2_PEER_CLUSTER;
@@ -294,7 +368,7 @@ static
 void
 master_auth_conn_rx(hammer2_msg_t *msg)
 {
-       if (msg->any.head.cmd & HAMMER2_MSGF_DELETE)
+       if (msg->any.head.cmd & DMSGF_DELETE)
                hammer2_msg_reply(msg, 0);
 }
 
@@ -342,15 +416,15 @@ master_link_rxmsg(hammer2_msg_t *msg)
                assert(state->func != NULL);
                state->func(msg);
        } else {
-               switch(cmd & HAMMER2_MSGF_PROTOS) {
-               case HAMMER2_MSG_PROTO_LNK:
+               switch(cmd & DMSGF_PROTOS) {
+               case DMSG_PROTO_LNK:
                        hammer2_msg_lnk(msg);
                        break;
-               case HAMMER2_MSG_PROTO_DBG:
+               case DMSG_PROTO_DBG:
                        hammer2_msg_dbg(msg);
                        break;
                default:
-                       hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+                       hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                        break;
                }
        }
index fd5ac6f..2de957f 100644 (file)
@@ -522,7 +522,7 @@ urandfail:
         * zero.  To be safe make sure that bit 7 and bit 6 is zero.
         */
        snprintf(handtx.quickmsg, sizeof(handtx.quickmsg), "Testing 1 2 3");
-       handtx.magic = HAMMER2_MSGHDR_MAGIC;
+       handtx.magic = DMSG_HDR_MAGIC;
        handtx.version = 1;
        handtx.flags = 0;
        assert(sizeof(handtx.verf) * 4 == sizeof(handtx.sess));
@@ -619,7 +619,7 @@ keyxchgfail:
                goto done;
        }
 
-       if (handrx.magic == HAMMER2_MSGHDR_MAGIC_REV) {
+       if (handrx.magic == DMSG_HDR_MAGIC_REV) {
                handrx.version = bswap16(handrx.version);
                handrx.flags = bswap32(handrx.flags);
        }
@@ -731,7 +731,7 @@ hammer2_crypto_encrypt(hammer2_iocom_t *iocom __unused, hammer2_ioq_t *ioq,
        for (i = 0; i < n && nmax; ++i) {
                used = 0;
                p_len = iov[i].iov_len;
-               assert((p_len & HAMMER2_MSG_ALIGNMASK) == 0);
+               assert((p_len & DMSG_ALIGNMASK) == 0);
 
                while (p_len >= HAMMER2_CRYPTO_CHUNK_SIZE &&
                    nmax >= HAMMER2_CRYPTO_CHUNK_SIZE +
index ddcbc08..399f53f 100644 (file)
@@ -45,6 +45,9 @@
 #include <sys/wait.h>
 #include <sys/tty.h>
 #include <sys/endian.h>
+#include <sys/sysctl.h>
+#include <sys/udev.h>
+#include <sys/dmsg.h>
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -54,7 +57,6 @@
 #include <vfs/hammer2/hammer2_disk.h>
 #include <vfs/hammer2/hammer2_mount.h>
 #include <vfs/hammer2/hammer2_ioctl.h>
-#include <vfs/hammer2/hammer2_network.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -78,6 +80,9 @@
 
 #define HAMMER2_DEFAULT_DIR    "/etc/hammer2"
 #define HAMMER2_PATH_REMOTE    HAMMER2_DEFAULT_DIR "/remote"
+#ifndef UDEV_DEVICE_PATH
+#define UDEV_DEVICE_PATH       "/dev/udev"
+#endif
 
 struct hammer2_idmap {
        struct hammer2_idmap *next;
@@ -128,7 +133,7 @@ int cmd_rsadec(const char **keys, int nkeys);
 /*
  * Msg support functions
  */
-void hammer2_bswap_head(hammer2_msg_hdr_t *head);
+void hammer2_bswap_head(dmsg_hdr_t *head);
 void hammer2_ioq_init(hammer2_iocom_t *iocom, hammer2_ioq_t *ioq);
 void hammer2_ioq_done(hammer2_iocom_t *iocom, hammer2_ioq_t *ioq);
 void hammer2_iocom_init(hammer2_iocom_t *iocom, int sock_fd, int alt_fd,
index eea4ea6..e98027f 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <sys/types.h>
 #include <sys/uuid.h>
+#include <sys/dmsg.h>
 
 #include <vfs/hammer2/hammer2_disk.h>
 
index f4cb65c..c5fbb9e 100644 (file)
@@ -264,16 +264,15 @@ hammer2_msg_alloc(hammer2_router_t *router, size_t aux_size, uint32_t cmd,
 
        pthread_mutex_lock(&iocom->mtx);
        if (aux_size) {
-               aux_size = (aux_size + HAMMER2_MSG_ALIGNMASK) &
-                          ~HAMMER2_MSG_ALIGNMASK;
+               aux_size = (aux_size + DMSG_ALIGNMASK) &
+                          ~DMSG_ALIGNMASK;
                if ((msg = TAILQ_FIRST(&iocom->freeq_aux)) != NULL)
                        TAILQ_REMOVE(&iocom->freeq_aux, msg, qentry);
        } else {
                if ((msg = TAILQ_FIRST(&iocom->freeq)) != NULL)
                        TAILQ_REMOVE(&iocom->freeq, msg, qentry);
        }
-       if ((cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_REPLY)) ==
-           HAMMER2_MSGF_CREATE) {
+       if ((cmd & (DMSGF_CREATE | DMSGF_REPLY)) == DMSGF_CREATE) {
                /*
                 * Create state when CREATE is set without REPLY.
                 *
@@ -286,9 +285,8 @@ hammer2_msg_alloc(hammer2_router_t *router, size_t aux_size, uint32_t cmd,
                state->flags = HAMMER2_STATE_DYNAMIC;
                state->msgid = (uint64_t)(uintptr_t)state;
                state->router = router;
-               state->txcmd = cmd & ~(HAMMER2_MSGF_CREATE |
-                                      HAMMER2_MSGF_DELETE);
-               state->rxcmd = HAMMER2_MSGF_REPLY;
+               state->txcmd = cmd & ~(DMSGF_CREATE | DMSGF_DELETE);
+               state->rxcmd = DMSGF_REPLY;
                state->func = func;
                state->any.any = data;
                pthread_mutex_lock(&iocom->mtx);
@@ -316,7 +314,7 @@ hammer2_msg_alloc(hammer2_router_t *router, size_t aux_size, uint32_t cmd,
                        msg->aux_size = aux_size;
                }
        }
-       hbytes = (cmd & HAMMER2_MSGF_SIZE) * HAMMER2_MSG_ALIGN;
+       hbytes = (cmd & DMSGF_SIZE) * DMSG_ALIGN;
        if (hbytes)
                bzero(&msg->any.head, hbytes);
        msg->hdr_size = hbytes;
@@ -539,9 +537,9 @@ hammer2_ioq_makeroom(hammer2_ioq_t *ioq, size_t needed)
  * Read the next ready message from the ioq, issuing I/O if needed.
  * Caller should retry on a read-event when NULL is returned.
  *
- * If an error occurs during reception a HAMMER2_LNK_ERROR msg will
+ * If an error occurs during reception a DMSG_LNK_ERROR msg will
  * be returned for each open transaction, then the ioq and iocom
- * will be errored out and a non-transactional HAMMER2_LNK_ERROR
+ * will be errored out and a non-transactional DMSG_LNK_ERROR
  * msg will be returned as the final message.  The caller should not call
  * us again after the final message is returned.
  *
@@ -552,8 +550,8 @@ hammer2_ioq_read(hammer2_iocom_t *iocom)
 {
        hammer2_ioq_t *ioq = &iocom->ioq_rx;
        hammer2_msg_t *msg;
-       hammer2_msg_hdr_t *head;
        hammer2_state_t *state;
+       dmsg_hdr_t *head;
        ssize_t n;
        size_t bytes;
        size_t nmax;
@@ -650,8 +648,8 @@ again:
                 * else.
                 */
                head = (void *)(ioq->buf + ioq->fifo_beg);
-               if (head->magic != HAMMER2_MSGHDR_MAGIC &&
-                   head->magic != HAMMER2_MSGHDR_MAGIC_REV) {
+               if (head->magic != DMSG_HDR_MAGIC &&
+                   head->magic != DMSG_HDR_MAGIC_REV) {
                        ioq->error = HAMMER2_IOQ_ERROR_SYNC;
                        break;
                }
@@ -659,19 +657,19 @@ again:
                /*
                 * Calculate the full header size and aux data size
                 */
-               if (head->magic == HAMMER2_MSGHDR_MAGIC_REV) {
-                       ioq->hbytes = (bswap32(head->cmd) & HAMMER2_MSGF_SIZE) *
-                                     HAMMER2_MSG_ALIGN;
+               if (head->magic == DMSG_HDR_MAGIC_REV) {
+                       ioq->hbytes = (bswap32(head->cmd) & DMSGF_SIZE) *
+                                     DMSG_ALIGN;
                        ioq->abytes = bswap32(head->aux_bytes) *
-                                     HAMMER2_MSG_ALIGN;
+                                     DMSG_ALIGN;
                } else {
-                       ioq->hbytes = (head->cmd & HAMMER2_MSGF_SIZE) *
-                                     HAMMER2_MSG_ALIGN;
-                       ioq->abytes = head->aux_bytes * HAMMER2_MSG_ALIGN;
+                       ioq->hbytes = (head->cmd & DMSGF_SIZE) *
+                                     DMSG_ALIGN;
+                       ioq->abytes = head->aux_bytes * DMSG_ALIGN;
                }
                if (ioq->hbytes < sizeof(msg->any.head) ||
                    ioq->hbytes > sizeof(msg->any) ||
-                   ioq->abytes > HAMMER2_MSGAUX_MAX) {
+                   ioq->abytes > DMSG_AUX_MAX) {
                        ioq->error = HAMMER2_IOQ_ERROR_FIELD;
                        break;
                }
@@ -748,7 +746,7 @@ again:
                /*
                 * Check the CRC.
                 */
-               if (head->magic == HAMMER2_MSGHDR_MAGIC_REV)
+               if (head->magic == DMSG_HDR_MAGIC_REV)
                        xcrc32 = bswap32(head->hdr_crc);
                else
                        xcrc32 = head->hdr_crc;
@@ -763,7 +761,7 @@ again:
                }
                head->hdr_crc = xcrc32;
 
-               if (head->magic == HAMMER2_MSGHDR_MAGIC_REV) {
+               if (head->magic == DMSG_HDR_MAGIC_REV) {
                        hammer2_bswap_head(head);
                }
 
@@ -971,8 +969,8 @@ skip:
                 */
                msg = hammer2_msg_alloc(iocom->router, 0, 0, NULL, NULL);
                bzero(&msg->any.head, sizeof(msg->any.head));
-               msg->any.head.magic = HAMMER2_MSGHDR_MAGIC;
-               msg->any.head.cmd = HAMMER2_LNK_ERROR;
+               msg->any.head.magic = DMSG_HDR_MAGIC;
+               msg->any.head.cmd = DMSG_LNK_ERROR;
                msg->any.head.error = ioq->error;
 
                pthread_mutex_lock(&iocom->mtx);
@@ -982,16 +980,16 @@ skip:
                         * Active remote transactions are still present.
                         * Simulate the other end sending us a DELETE.
                         */
-                       if (state->rxcmd & HAMMER2_MSGF_DELETE) {
+                       if (state->rxcmd & DMSGF_DELETE) {
                                hammer2_msg_free(msg);
                                msg = NULL;
                        } else {
-                               /*state->txcmd |= HAMMER2_MSGF_DELETE;*/
+                               /*state->txcmd |= DMSGF_DELETE;*/
                                msg->state = state;
                                msg->router = state->router;
                                msg->any.head.msgid = state->msgid;
-                               msg->any.head.cmd |= HAMMER2_MSGF_ABORT |
-                                                    HAMMER2_MSGF_DELETE;
+                               msg->any.head.cmd |= DMSGF_ABORT |
+                                                    DMSGF_DELETE;
                        }
                } else if ((state = RB_ROOT(&iocom->router->statewr_tree)) !=
                           NULL) {
@@ -999,19 +997,19 @@ skip:
                         * Active local transactions are still present.
                         * Simulate the other end sending us a DELETE.
                         */
-                       if (state->rxcmd & HAMMER2_MSGF_DELETE) {
+                       if (state->rxcmd & DMSGF_DELETE) {
                                hammer2_msg_free(msg);
                                msg = NULL;
                        } else {
                                msg->state = state;
                                msg->router = state->router;
                                msg->any.head.msgid = state->msgid;
-                               msg->any.head.cmd |= HAMMER2_MSGF_ABORT |
-                                                    HAMMER2_MSGF_DELETE |
-                                                    HAMMER2_MSGF_REPLY;
-                               if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
+                               msg->any.head.cmd |= DMSGF_ABORT |
+                                                    DMSGF_DELETE |
+                                                    DMSGF_REPLY;
+                               if ((state->rxcmd & DMSGF_CREATE) == 0) {
                                        msg->any.head.cmd |=
-                                                    HAMMER2_MSGF_CREATE;
+                                                    DMSGF_CREATE;
                                }
                        }
                } else {
@@ -1117,7 +1115,7 @@ hammer2_iocom_flush1(hammer2_iocom_t *iocom)
                 * the iv[] array is ridiculously randomized and we also
                 * re-seed our PRNG every 32768 messages just to be sure.
                 */
-               msg->any.head.magic = HAMMER2_MSGHDR_MAGIC;
+               msg->any.head.magic = DMSG_HDR_MAGIC;
                msg->any.head.salt = (random() << 8) | (ioq->seq & 255);
                ++ioq->seq;
                if ((ioq->seq & 32767) == 0)
@@ -1127,15 +1125,15 @@ hammer2_iocom_flush1(hammer2_iocom_t *iocom)
                 * Calculate aux_crc if 0, then calculate hdr_crc.
                 */
                if (msg->aux_size && msg->any.head.aux_crc == 0) {
-                       assert((msg->aux_size & HAMMER2_MSG_ALIGNMASK) == 0);
+                       assert((msg->aux_size & DMSG_ALIGNMASK) == 0);
                        xcrc32 = hammer2_icrc32(msg->aux_data, msg->aux_size);
                        msg->any.head.aux_crc = xcrc32;
                }
-               msg->any.head.aux_bytes = msg->aux_size / HAMMER2_MSG_ALIGN;
-               assert((msg->aux_size & HAMMER2_MSG_ALIGNMASK) == 0);
+               msg->any.head.aux_bytes = msg->aux_size / DMSG_ALIGN;
+               assert((msg->aux_size & DMSG_ALIGNMASK) == 0);
 
-               hbytes = (msg->any.head.cmd & HAMMER2_MSGF_SIZE) *
-                        HAMMER2_MSG_ALIGN;
+               hbytes = (msg->any.head.cmd & DMSGF_SIZE) *
+                        DMSG_ALIGN;
                msg->any.head.hdr_crc = 0;
                msg->any.head.hdr_crc = hammer2_icrc32(&msg->any.head, hbytes);
 
@@ -1184,8 +1182,8 @@ hammer2_iocom_flush2(hammer2_iocom_t *iocom)
        aoff = ioq->abytes;
 
        TAILQ_FOREACH(msg, &ioq->msgq, qentry) {
-               hbytes = (msg->any.head.cmd & HAMMER2_MSGF_SIZE) *
-                        HAMMER2_MSG_ALIGN;
+               hbytes = (msg->any.head.cmd & DMSGF_SIZE) *
+                        DMSG_ALIGN;
                abytes = msg->aux_size;
                assert(hoff <= hbytes && aoff <= abytes);
 
@@ -1234,7 +1232,7 @@ hammer2_iocom_flush2(hammer2_iocom_t *iocom)
                 * left (if not completely full).
                 */
                if (ioq->fifo_beg > sizeof(ioq->buf) / 2 &&
-                   sizeof(ioq->buf) - ioq->fifo_end >= HAMMER2_MSG_ALIGN * 2) {
+                   sizeof(ioq->buf) - ioq->fifo_end >= DMSG_ALIGN * 2) {
                        bcopy(ioq->buf + ioq->fifo_beg, ioq->buf,
                              ioq->fifo_end - ioq->fifo_beg);
                        ioq->fifo_cdx -= ioq->fifo_beg;
@@ -1270,8 +1268,8 @@ hammer2_iocom_flush2(hammer2_iocom_t *iocom)
         * represents the portion of the first message previously sent.
         */
        while ((msg = TAILQ_FIRST(&ioq->msgq)) != NULL) {
-               hbytes = (msg->any.head.cmd & HAMMER2_MSGF_SIZE) *
-                        HAMMER2_MSG_ALIGN;
+               hbytes = (msg->any.head.cmd & DMSGF_SIZE) *
+                        DMSG_ALIGN;
                abytes = msg->aux_size;
 
                if ((size_t)nact < hbytes - ioq->hbytes) {
@@ -1374,16 +1372,14 @@ hammer2_msg_write(hammer2_msg_t *msg)
                 * not been serialized (state could have gotten ripped out
                 * from under the message prior to it being transmitted).
                 */
-               if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE |
-                                         HAMMER2_MSGF_REPLY)) ==
-                   HAMMER2_MSGF_CREATE) {
-                       state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+               if ((msg->any.head.cmd & (DMSGF_CREATE | DMSGF_REPLY)) ==
+                   DMSGF_CREATE) {
+                       state->txcmd = msg->any.head.cmd & ~DMSGF_DELETE;
                }
                msg->any.head.msgid = state->msgid;
-               assert(((state->txcmd ^ msg->any.head.cmd) &
-                       HAMMER2_MSGF_REPLY) == 0);
-               if (msg->any.head.cmd & HAMMER2_MSGF_CREATE)
-                       state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+               assert(((state->txcmd ^ msg->any.head.cmd) & DMSGF_REPLY) == 0);
+               if (msg->any.head.cmd & DMSGF_CREATE)
+                       state->txcmd = msg->any.head.cmd & ~DMSGF_DELETE;
        } else {
                msg->any.head.msgid = 0;
                /* XXX set spanid by router */
@@ -1404,9 +1400,9 @@ hammer2_msg_write(hammer2_msg_t *msg)
 /*
  * This is a shortcut to formulate a reply to msg with a simple error code,
  * It can reply to and terminate a transaction, or it can reply to a one-way
- * messages.  A HAMMER2_LNK_ERROR command code is utilized to encode
+ * messages.  A DMSG_LNK_ERROR command code is utilized to encode
  * the error code (which can be 0).  Not all transactions are terminated
- * with HAMMER2_LNK_ERROR status (the low level only cares about the
+ * with DMSG_LNK_ERROR status (the low level only cares about the
  * MSGF_DELETE flag), but most are.
  *
  * Replies to one-way messages are a bit of an oxymoron but the feature
@@ -1426,7 +1422,7 @@ hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
        /*
         * Reply with a simple error code and terminate the transaction.
         */
-       cmd = HAMMER2_LNK_ERROR;
+       cmd = DMSG_LNK_ERROR;
 
        /*
         * Check if our direction has even been initiated yet, set CREATE.
@@ -1438,14 +1434,14 @@ hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
         * doing anything.
         */
        if (state) {
-               if (state->txcmd & HAMMER2_MSGF_DELETE)
+               if (state->txcmd & DMSGF_DELETE)
                        return;
-               if (state->txcmd & HAMMER2_MSGF_REPLY)
-                       cmd |= HAMMER2_MSGF_REPLY;
-               cmd |= HAMMER2_MSGF_DELETE;
+               if (state->txcmd & DMSGF_REPLY)
+                       cmd |= DMSGF_REPLY;
+               cmd |= DMSGF_DELETE;
        } else {
-               if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if ((msg->any.head.cmd & DMSGF_REPLY) == 0)
+                       cmd |= DMSGF_REPLY;
        }
 
        /*
@@ -1455,8 +1451,8 @@ hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
         */
        nmsg = hammer2_msg_alloc(iocom->router, 0, cmd, NULL, NULL);
        if (state) {
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
-                       nmsg->any.head.cmd |= HAMMER2_MSGF_CREATE;
+               if ((state->txcmd & DMSGF_CREATE) == 0)
+                       nmsg->any.head.cmd |= DMSGF_CREATE;
        }
        nmsg->any.head.error = error;
        nmsg->state = state;
@@ -1481,7 +1477,7 @@ hammer2_msg_result(hammer2_msg_t *msg, uint32_t error)
        /*
         * Reply with a simple error code and terminate the transaction.
         */
-       cmd = HAMMER2_LNK_ERROR;
+       cmd = DMSG_LNK_ERROR;
 
        /*
         * Check if our direction has even been initiated yet, set CREATE.
@@ -1493,20 +1489,20 @@ hammer2_msg_result(hammer2_msg_t *msg, uint32_t error)
         * doing anything.
         */
        if (state) {
-               if (state->txcmd & HAMMER2_MSGF_DELETE)
+               if (state->txcmd & DMSGF_DELETE)
                        return;
-               if (state->txcmd & HAMMER2_MSGF_REPLY)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if (state->txcmd & DMSGF_REPLY)
+                       cmd |= DMSGF_REPLY;
                /* continuing transaction, do not set MSGF_DELETE */
        } else {
-               if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if ((msg->any.head.cmd & DMSGF_REPLY) == 0)
+                       cmd |= DMSGF_REPLY;
        }
 
        nmsg = hammer2_msg_alloc(iocom->router, 0, cmd, NULL, NULL);
        if (state) {
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
-                       nmsg->any.head.cmd |= HAMMER2_MSGF_CREATE;
+               if ((state->txcmd & DMSGF_CREATE) == 0)
+                       nmsg->any.head.cmd |= DMSGF_CREATE;
        }
        nmsg->any.head.error = error;
        nmsg->state = state;
@@ -1520,25 +1516,25 @@ void
 hammer2_state_reply(hammer2_state_t *state, uint32_t error)
 {
        hammer2_msg_t *nmsg;
-       uint32_t cmd = HAMMER2_LNK_ERROR | HAMMER2_MSGF_DELETE;
+       uint32_t cmd = DMSG_LNK_ERROR | DMSGF_DELETE;
 
        /*
         * Nothing to do if we already transmitted a delete
         */
-       if (state->txcmd & HAMMER2_MSGF_DELETE)
+       if (state->txcmd & DMSGF_DELETE)
                return;
 
        /*
         * Set REPLY if the other end initiated the command.  Otherwise
         * we are the command direction.
         */
-       if (state->txcmd & HAMMER2_MSGF_REPLY)
-               cmd |= HAMMER2_MSGF_REPLY;
+       if (state->txcmd & DMSGF_REPLY)
+               cmd |= DMSGF_REPLY;
 
        nmsg = hammer2_msg_alloc(state->iocom->router, 0, cmd, NULL, NULL);
        if (state) {
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
-                       nmsg->any.head.cmd |= HAMMER2_MSGF_CREATE;
+               if ((state->txcmd & DMSGF_CREATE) == 0)
+                       nmsg->any.head.cmd |= DMSGF_CREATE;
        }
        nmsg->any.head.error = error;
        nmsg->state = state;
@@ -1634,7 +1630,7 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
         */
        dummy.msgid = msg->any.head.msgid;
        pthread_mutex_lock(&iocom->mtx);
-       if (msg->any.head.cmd & HAMMER2_MSGF_REPLY) {
+       if (msg->any.head.cmd & DMSGF_REPLY) {
                state = RB_FIND(hammer2_state_tree,
                                &iocom->router->statewr_tree, &dummy);
        } else {
@@ -1647,8 +1643,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
        /*
         * Short-cut one-off or mid-stream messages (state may be NULL).
         */
-       if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                 HAMMER2_MSGF_ABORT)) == 0) {
+       if ((msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                 DMSGF_ABORT)) == 0) {
                return(0);
        }
 
@@ -1656,10 +1652,10 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
         * Switch on CREATE, DELETE, REPLY, and also handle ABORT from
         * inside the case statements.
         */
-       switch(msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                   HAMMER2_MSGF_REPLY)) {
-       case HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       switch(msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                   DMSGF_REPLY)) {
+       case DMSGF_CREATE:
+       case DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * New persistant command received.
                 */
@@ -1675,8 +1671,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                state->iocom = iocom;
                state->flags = HAMMER2_STATE_DYNAMIC;
                state->msg = msg;
-               state->txcmd = HAMMER2_MSGF_REPLY;
-               state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+               state->txcmd = DMSGF_REPLY;
+               state->rxcmd = msg->any.head.cmd & ~DMSGF_DELETE;
                state->flags |= HAMMER2_STATE_INSERTED;
                state->msgid = msg->any.head.msgid;
                state->router = msg->router;
@@ -1691,13 +1687,13 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                                state, (uint32_t)state->msgid, iocom);
                }
                break;
-       case HAMMER2_MSGF_DELETE:
+       case DMSGF_DELETE:
                /*
                 * Persistent state is expected but might not exist if an
                 * ABORT+DELETE races the close.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                        } else {
                                fprintf(stderr, "missing-state %s\n",
@@ -1712,8 +1708,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * Handle another ABORT+DELETE case if the msgid has already
                 * been reused.
                 */
-               if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->rxcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                        } else {
                                fprintf(stderr, "reused-state %s\n",
@@ -1730,17 +1726,17 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * Check for mid-stream ABORT command received, otherwise
                 * allow.
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->rxcmd & DMSGF_CREATE) == 0) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                                break;
                        }
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_CREATE:
+       case DMSGF_REPLY | DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * When receiving a reply with CREATE set the original
                 * persistent state message should already exist.
@@ -1753,17 +1749,17 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                        break;
                }
                assert(((state->rxcmd ^ msg->any.head.cmd) &
-                       HAMMER2_MSGF_REPLY) == 0);
-               state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+                       DMSGF_REPLY) == 0);
+               state->rxcmd = msg->any.head.cmd & ~DMSGF_DELETE;
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_DELETE:
                /*
                 * Received REPLY+ABORT+DELETE in case where msgid has
                 * already been fully closed, ignore the message.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                        } else {
                                fprintf(stderr, "no-state(r,d) %s\n",
@@ -1779,8 +1775,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * already been reused for an unrelated message,
                 * ignore the message.
                 */
-               if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->rxcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                        } else {
                                fprintf(stderr, "reused-state(r,d) %s\n",
@@ -1792,13 +1788,13 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY:
+       case DMSGF_REPLY:
                /*
                 * Check for mid-stream ABORT reply received to sent command.
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->rxcmd & DMSGF_CREATE) == 0) {
                                error = HAMMER2_IOQ_ERROR_EALREADY;
                                break;
                        }
@@ -1820,24 +1816,24 @@ hammer2_state_cleanuprx(hammer2_iocom_t *iocom, hammer2_msg_t *msg)
                 * to worry about.
                 */
                hammer2_msg_free(msg);
-       } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       } else if (msg->any.head.cmd & DMSGF_DELETE) {
                /*
                 * Message terminating transaction, destroy the related
                 * state, the original message, and this message (if it
                 * isn't the original message due to a CREATE|DELETE).
                 */
                pthread_mutex_lock(&iocom->mtx);
-               state->rxcmd |= HAMMER2_MSGF_DELETE;
-               if (state->txcmd & HAMMER2_MSGF_DELETE) {
+               state->rxcmd |= DMSGF_DELETE;
+               if (state->txcmd & DMSGF_DELETE) {
                        if (state->msg == msg)
                                state->msg = NULL;
                        assert(state->flags & HAMMER2_STATE_INSERTED);
-                       if (state->rxcmd & HAMMER2_MSGF_REPLY) {
-                               assert(msg->any.head.cmd & HAMMER2_MSGF_REPLY);
+                       if (state->rxcmd & DMSGF_REPLY) {
+                               assert(msg->any.head.cmd & DMSGF_REPLY);
                                RB_REMOVE(hammer2_state_tree,
                                          &iocom->router->statewr_tree, state);
                        } else {
-                               assert((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0);
+                               assert((msg->any.head.cmd & DMSGF_REPLY) == 0);
                                RB_REMOVE(hammer2_state_tree,
                                          &iocom->router->staterd_tree, state);
                        }
@@ -1865,19 +1861,19 @@ hammer2_state_cleanuptx(hammer2_msg_t *msg)
 
        if ((state = msg->state) == NULL) {
                hammer2_msg_free(msg);
-       } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       } else if (msg->any.head.cmd & DMSGF_DELETE) {
                pthread_mutex_lock(&iocom->mtx);
-               state->txcmd |= HAMMER2_MSGF_DELETE;
-               if (state->rxcmd & HAMMER2_MSGF_DELETE) {
+               state->txcmd |= DMSGF_DELETE;
+               if (state->rxcmd & DMSGF_DELETE) {
                        if (state->msg == msg)
                                state->msg = NULL;
                        assert(state->flags & HAMMER2_STATE_INSERTED);
-                       if (state->txcmd & HAMMER2_MSGF_REPLY) {
-                               assert(msg->any.head.cmd & HAMMER2_MSGF_REPLY);
+                       if (state->txcmd & DMSGF_REPLY) {
+                               assert(msg->any.head.cmd & DMSGF_REPLY);
                                RB_REMOVE(hammer2_state_tree,
                                          &iocom->router->staterd_tree, state);
                        } else {
-                               assert((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0);
+                               assert((msg->any.head.cmd & DMSGF_REPLY) == 0);
                                RB_REMOVE(hammer2_state_tree,
                                          &iocom->router->statewr_tree, state);
                        }
@@ -2022,70 +2018,70 @@ hammer2_basecmd_str(uint32_t cmd)
        const char *protostr;
        const char *cmdstr;
 
-       switch(cmd & HAMMER2_MSGF_PROTOS) {
-       case HAMMER2_MSG_PROTO_LNK:
+       switch(cmd & DMSGF_PROTOS) {
+       case DMSG_PROTO_LNK:
                protostr = "LNK_";
                break;
-       case HAMMER2_MSG_PROTO_DBG:
+       case DMSG_PROTO_DBG:
                protostr = "DBG_";
                break;
-       case HAMMER2_MSG_PROTO_DOM:
+       case DMSG_PROTO_DOM:
                protostr = "DOM_";
                break;
-       case HAMMER2_MSG_PROTO_CAC:
+       case DMSG_PROTO_CAC:
                protostr = "CAC_";
                break;
-       case HAMMER2_MSG_PROTO_QRM:
+       case DMSG_PROTO_QRM:
                protostr = "QRM_";
                break;
-       case HAMMER2_MSG_PROTO_BLK:
+       case DMSG_PROTO_BLK:
                protostr = "BLK_";
                break;
-       case HAMMER2_MSG_PROTO_VOP:
+       case DMSG_PROTO_VOP:
                protostr = "VOP_";
                break;
        default:
                snprintf(protobuf, sizeof(protobuf), "%x_",
-                       (cmd & HAMMER2_MSGF_PROTOS) >> 20);
+                       (cmd & DMSGF_PROTOS) >> 20);
                protostr = protobuf;
                break;
        }
 
-       switch(cmd & (HAMMER2_MSGF_PROTOS |
-                     HAMMER2_MSGF_CMDS |
-                     HAMMER2_MSGF_SIZE)) {
-       case HAMMER2_LNK_PAD:
+       switch(cmd & (DMSGF_PROTOS |
+                     DMSGF_CMDS |
+                     DMSGF_SIZE)) {
+       case DMSG_LNK_PAD:
                cmdstr = "PAD";
                break;
-       case HAMMER2_LNK_PING:
+       case DMSG_LNK_PING:
                cmdstr = "PING";
                break;
-       case HAMMER2_LNK_AUTH:
+       case DMSG_LNK_AUTH:
                cmdstr = "AUTH";
                break;
-       case HAMMER2_LNK_CONN:
+       case DMSG_LNK_CONN:
                cmdstr = "CONN";
                break;
-       case HAMMER2_LNK_SPAN:
+       case DMSG_LNK_SPAN:
                cmdstr = "SPAN";
                break;
-       case HAMMER2_LNK_VOLCONF:
+       case DMSG_LNK_VOLCONF:
                cmdstr = "VOLCONF";
                break;
-       case HAMMER2_LNK_ERROR:
-               if (cmd & HAMMER2_MSGF_DELETE)
+       case DMSG_LNK_ERROR:
+               if (cmd & DMSGF_DELETE)
                        cmdstr = "RETURN";
                else
                        cmdstr = "RESULT";
                break;
-       case HAMMER2_DBG_SHELL:
+       case DMSG_DBG_SHELL:
                cmdstr = "SHELL";
                break;
        default:
                snprintf(cmdbuf, sizeof(cmdbuf),
-                        "%06x", (cmd & (HAMMER2_MSGF_PROTOS |
-                                        HAMMER2_MSGF_CMDS |
-                                        HAMMER2_MSGF_SIZE)));
+                        "%06x", (cmd & (DMSGF_PROTOS |
+                                        DMSGF_CMDS |
+                                        DMSGF_SIZE)));
                cmdstr = cmdbuf;
                break;
        }
@@ -2110,17 +2106,17 @@ hammer2_msg_str(hammer2_msg_t *msg)
         * Parse the state
         */
        if ((state = msg->state) != NULL) {
-               basecmd = (state->rxcmd & HAMMER2_MSGF_REPLY) ?
+               basecmd = (state->rxcmd & DMSGF_REPLY) ?
                          state->txcmd : state->rxcmd;
                snprintf(statebuf, sizeof(statebuf),
                         " %s=%s,L=%s%s,R=%s%s",
-                        ((state->txcmd & HAMMER2_MSGF_REPLY) ?
+                        ((state->txcmd & DMSGF_REPLY) ?
                                "rcvcmd" : "sndcmd"),
                         hammer2_basecmd_str(basecmd),
-                        ((state->txcmd & HAMMER2_MSGF_CREATE) ? "C" : ""),
-                        ((state->txcmd & HAMMER2_MSGF_DELETE) ? "D" : ""),
-                        ((state->rxcmd & HAMMER2_MSGF_CREATE) ? "C" : ""),
-                        ((state->rxcmd & HAMMER2_MSGF_DELETE) ? "D" : "")
+                        ((state->txcmd & DMSGF_CREATE) ? "C" : ""),
+                        ((state->txcmd & DMSGF_DELETE) ? "D" : ""),
+                        ((state->rxcmd & DMSGF_CREATE) ? "C" : ""),
+                        ((state->rxcmd & DMSGF_DELETE) ? "D" : "")
                );
                statestr = statebuf;
        } else {
@@ -2194,7 +2190,7 @@ hammer2_msg_str(hammer2_msg_t *msg)
        case HAMMER2_IOQ_ERROR_ALGO:
                errstr = "err=IOQ:ALGOFAIL";
                break;
-       case HAMMER2_MSG_ERR_NOSUPP:
+       case DMSG_ERR_NOSUPP:
                errstr = "err=NOSUPPORT";
                break;
        default:
@@ -2208,16 +2204,16 @@ hammer2_msg_str(hammer2_msg_t *msg)
         * Message flags
         */
        i = 0;
-       if (msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                HAMMER2_MSGF_ABORT | HAMMER2_MSGF_REPLY)) {
+       if (msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                DMSGF_ABORT | DMSGF_REPLY)) {
                flagbuf[i++] = '|';
-               if (msg->any.head.cmd & HAMMER2_MSGF_CREATE)
+               if (msg->any.head.cmd & DMSGF_CREATE)
                        flagbuf[i++] = 'C';
-               if (msg->any.head.cmd & HAMMER2_MSGF_DELETE)
+               if (msg->any.head.cmd & DMSGF_DELETE)
                        flagbuf[i++] = 'D';
-               if (msg->any.head.cmd & HAMMER2_MSGF_REPLY)
+               if (msg->any.head.cmd & DMSGF_REPLY)
                        flagbuf[i++] = 'R';
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT)
+               if (msg->any.head.cmd & DMSGF_ABORT)
                        flagbuf[i++] = 'A';
        }
        flagbuf[i] = 0;
index 9e8d195..1d59488 100644 (file)
@@ -202,8 +202,8 @@ struct h2span_media {
        uuid_t  mediaid;
        int     refs;
        struct h2span_media_config {
-               hammer2_copy_data_t     copy_run;
-               hammer2_copy_data_t     copy_pend;
+               dmsg_vol_data_t         copy_run;
+               dmsg_vol_data_t         copy_pend;
                pthread_t               thread;
                pthread_cond_t          cond;
                int                     ctl;
@@ -426,17 +426,17 @@ hammer2_msg_lnk_signal(hammer2_router_t *router __unused)
 void
 hammer2_msg_lnk(hammer2_msg_t *msg)
 {
-       switch(msg->any.head.cmd & HAMMER2_MSGF_BASECMDMASK) {
-       case HAMMER2_LNK_CONN:
+       switch(msg->any.head.cmd & DMSGF_BASECMDMASK) {
+       case DMSG_LNK_CONN:
                hammer2_lnk_conn(msg);
                break;
-       case HAMMER2_LNK_SPAN:
+       case DMSG_LNK_SPAN:
                hammer2_lnk_span(msg);
                break;
        default:
                fprintf(stderr,
                        "MSG_PROTO_LNK: Unknown msg %08x\n", msg->any.head.cmd);
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                /* state invalid after reply */
                break;
        }
@@ -455,9 +455,9 @@ hammer2_lnk_conn(hammer2_msg_t *msg)
 
        pthread_mutex_lock(&cluster_mtx);
 
-       switch(msg->any.head.cmd & HAMMER2_MSGF_TRANSMASK) {
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_CREATE:
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       switch(msg->any.head.cmd & DMSGF_TRANSMASK) {
+       case DMSG_LNK_CONN | DMSGF_CREATE:
+       case DMSG_LNK_CONN | DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * On transaction start we allocate a new h2span_conn and
                 * acknowledge the request, leaving the transaction open.
@@ -495,14 +495,14 @@ hammer2_lnk_conn(hammer2_msg_t *msg)
                conn->media = media;
                ++media->refs;
 
-               if ((msg->any.head.cmd & HAMMER2_MSGF_DELETE) == 0) {
+               if ((msg->any.head.cmd & DMSGF_DELETE) == 0) {
                        hammer2_msg_result(msg, 0);
                        hammer2_router_signal(msg->router);
                        break;
                }
                /* FALL THROUGH */
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_DELETE:
-       case HAMMER2_LNK_ERROR | HAMMER2_MSGF_DELETE:
+       case DMSG_LNK_CONN | DMSGF_DELETE:
+       case DMSG_LNK_ERROR | DMSGF_DELETE:
 deleteconn:
                /*
                 * On transaction terminate we clean out our h2span_conn
@@ -564,7 +564,7 @@ deleteconn:
                hammer2_msg_reply(msg, 0);
                /* state invalid after reply */
                break;
-       case HAMMER2_LNK_VOLCONF:
+       case DMSG_LNK_VOLCONF:
                /*
                 * One-way volume-configuration message is transmitted
                 * over the open LNK_CONN transaction.
@@ -602,9 +602,9 @@ deleteconn:
                /*
                 * Failsafe
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_DELETE)
+               if (msg->any.head.cmd & DMSGF_DELETE)
                        goto deleteconn;
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
        }
        pthread_mutex_unlock(&cluster_mtx);
@@ -622,14 +622,14 @@ hammer2_lnk_span(hammer2_msg_t *msg)
        h2span_relay_t *relay;
        char *alloc = NULL;
 
-       assert((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0);
+       assert((msg->any.head.cmd & DMSGF_REPLY) == 0);
 
        pthread_mutex_lock(&cluster_mtx);
 
        /*
         * On transaction start we initialize the tracking infrastructure
         */
-       if (msg->any.head.cmd & HAMMER2_MSGF_CREATE) {
+       if (msg->any.head.cmd & DMSGF_CREATE) {
                assert(state->func == NULL);
                state->func = hammer2_lnk_span;
 
@@ -705,7 +705,7 @@ hammer2_lnk_span(hammer2_msg_t *msg)
        /*
         * On transaction terminate we remove the tracking infrastructure.
         */
-       if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       if (msg->any.head.cmd & DMSGF_DELETE) {
                slink = state->any.link;
                assert(slink != NULL);
                node = slink->node;
@@ -786,9 +786,9 @@ hammer2_lnk_relay(hammer2_msg_t *msg)
        hammer2_state_t *state = msg->state;
        h2span_relay_t *relay;
 
-       assert(msg->any.head.cmd & HAMMER2_MSGF_REPLY);
+       assert(msg->any.head.cmd & DMSGF_REPLY);
 
-       if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       if (msg->any.head.cmd & DMSGF_DELETE) {
                pthread_mutex_lock(&cluster_mtx);
                if ((relay = state->any.relay) != NULL) {
                        hammer2_relay_delete(relay);
@@ -890,7 +890,7 @@ hammer2_relay_scan_specific(h2span_node_t *node, h2span_conn_t *conn)
        h2span_relay_t *relay;
        h2span_relay_t *next_relay;
        h2span_link_t *slink;
-       hammer2_lnk_conn_t *lconn;
+       dmsg_lnk_conn_t *lconn;
        hammer2_msg_t *msg;
        int count = 2;
        uint8_t peer_type;
@@ -993,8 +993,8 @@ hammer2_relay_scan_specific(h2span_node_t *node, h2span_conn_t *conn)
                relay->link = slink;
 
                msg = hammer2_msg_alloc(conn->state->iocom->router, 0,
-                                       HAMMER2_LNK_SPAN |
-                                       HAMMER2_MSGF_CREATE,
+                                       DMSG_LNK_SPAN |
+                                       DMSGF_CREATE,
                                        hammer2_lnk_relay, relay);
                relay->state = msg->state;
                relay->router = hammer2_router_alloc();
index 9ca48c4..2f3bbda 100644 (file)
@@ -71,7 +71,7 @@
  */
 struct hammer2_handshake {
        char pad1[8];           /* 000 */
-       uint16_t magic;         /* 008 HAMMER2_MSGHDR_MAGIC for endian detect */
+       uint16_t magic;         /* 008 DMSG_HDR_MAGIC for endian detect */
        uint16_t version;       /* 00A hammer2 protocol version */
        uint32_t flags;         /* 00C protocol extension flags */
        uint8_t sess[64];       /* 010 512-bit session key */
@@ -85,7 +85,7 @@ struct hammer2_handshake {
 typedef struct hammer2_handshake hammer2_handshake_t;
 
 
-#define HAMMER2_CRYPTO_CHUNK_SIZE              HAMMER2_MSG_ALIGN
+#define HAMMER2_CRYPTO_CHUNK_SIZE              DMSG_ALIGN
 #define HAMMER2_MAX_IV_SIZE                    32
 
 #define HAMMER2_CRYPTO_GCM_IV_FIXED_SIZE       4
@@ -161,7 +161,7 @@ struct hammer2_msg {
        size_t          hdr_size;
        size_t          aux_size;
        char            *aux_data;
-       hammer2_msg_any_t any;
+       dmsg_any_t      any;
 };
 
 typedef struct hammer2_state hammer2_state_t;
@@ -197,7 +197,7 @@ struct hammer2_ioq {
        char            iv[HAMMER2_MAX_IV_SIZE]; /* encrypt or decrypt iv[] */
        hammer2_msg_t   *msg;
        hammer2_msg_queue_t msgq;
-       char            buf[HAMMER2_MSGBUF_SIZE]; /* staging buffer */
+       char            buf[DMSG_BUF_SIZE];     /* staging buffer */
 };
 
 typedef struct hammer2_ioq hammer2_ioq_t;
index d04c410..a75e3d6 100644 (file)
@@ -144,7 +144,7 @@ hammer2_demon(void *(*func)(void *), void *arg)
  * header is not adjusted, just the core header.
  */
 void
-hammer2_bswap_head(hammer2_msg_hdr_t *head)
+hammer2_bswap_head(dmsg_hdr_t *head)
 {
        head->magic     = bswap16(head->magic);
        head->reserved02 = bswap16(head->reserved02);
similarity index 75%
rename from sys/vfs/hammer2/hammer2_network.h
rename to sys/sys/dmsg.h
index 8eee05d..f283183 100644 (file)
@@ -3,7 +3,6 @@
  *
  * This code is derived from software contributed to The DragonFly Project
  * by Matthew Dillon <dillon@dragonflybsd.org>
- * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef VFS_HAMMER2_NETWORK_H_
-#define VFS_HAMMER2_NETWORK_H_
 
-#ifndef _VFS_HAMMER2_DISK_H_
-#include "hammer2_disk.h"
+#ifndef _SYS_DMSG_H_
+#define _SYS_DMSG_H_
+
+#ifndef _SYS_MALLOC_H_
+#include <sys/malloc.h>
+#endif
+#ifndef _SYS_TREE_H_
+#include <sys/tree.h>
+#endif
+#ifndef _SYS_UUID_H_
+#include <sys/uuid.h>
 #endif
 
 /*
  * --
  *
  * All base and extended message headers are 64-byte aligned, and all
- * transports must support extended message headers up to HAMMER2_MSGHDR_MAX.
+ * transports must support extended message headers up to DMSG_HDR_MAX.
  * Currently we allow extended message headers up to 2048 bytes.  Note
  * that the extended header size is encoded in the 'cmd' field of the header.
  *
  * multiple copies of one-way messages in higher protocol layers (potentially
  * out of order, too).
  */
-struct hammer2_msg_hdr {
+struct dmsg_hdr {
        uint16_t        magic;          /* 00 sanity, synchro, endian */
        uint16_t        reserved02;     /* 02 */
        uint32_t        salt;           /* 04 random salt helps w/crypto */
@@ -211,21 +217,20 @@ struct hammer2_msg_hdr {
        uint32_t        hdr_crc;        /* 3C (aligned) extended header crc */
 };
 
-typedef struct hammer2_msg_hdr hammer2_msg_hdr_t;
+typedef struct dmsg_hdr dmsg_hdr_t;
 
-#define HAMMER2_MSGHDR_MAGIC           0x4832
-#define HAMMER2_MSGHDR_MAGIC_REV       0x3248
-#define HAMMER2_MSGHDR_CRCOFF          offsetof(hammer2_msg_hdr_t, salt)
-#define HAMMER2_MSGHDR_CRCBYTES                (sizeof(hammer2_msg_hdr_t) -    \
-                                        HAMMER2_MSGHDR_CRCOFF)
+#define DMSG_HDR_MAGIC         0x4832
+#define DMSG_HDR_MAGIC_REV     0x3248
+#define DMSG_HDR_CRCOFF                offsetof(dmsg_hdr_t, salt)
+#define DMSG_HDR_CRCBYTES      (sizeof(dmsg_hdr_t) - DMSG_HDR_CRCOFF)
 
 /*
  * Administrative protocol limits.
  */
-#define HAMMER2_MSGHDR_MAX             2048    /* <= 65535 */
-#define HAMMER2_MSGAUX_MAX             65536   /* <= 1MB */
-#define HAMMER2_MSGBUF_SIZE            (HAMMER2_MSGHDR_MAX * 4)
-#define HAMMER2_MSGBUF_MASK            (HAMMER2_MSGBUF_SIZE - 1)
+#define DMSG_HDR_MAX           2048    /* <= 65535 */
+#define DMSG_AUX_MAX           65536   /* <= 1MB */
+#define DMSG_BUF_SIZE          (DMSG_HDR_MAX * 4)
+#define DMSG_BUF_MASK          (DMSG_BUF_SIZE - 1)
 
 /*
  * The message (cmd) field also encodes various flags and the total size
@@ -233,82 +238,83 @@ typedef struct hammer2_msg_hdr hammer2_msg_hdr_t;
  * persistency and structural settings for every command simply by
  * switch()ing on the (cmd) field.
  */
-#define HAMMER2_MSGF_CREATE            0x80000000U     /* msg start */
-#define HAMMER2_MSGF_DELETE            0x40000000U     /* msg end */
-#define HAMMER2_MSGF_REPLY             0x20000000U     /* reply path */
-#define HAMMER2_MSGF_ABORT             0x10000000U     /* abort req */
-#define HAMMER2_MSGF_AUXOOB            0x08000000U     /* aux-data is OOB */
-#define HAMMER2_MSGF_FLAG2             0x04000000U
-#define HAMMER2_MSGF_FLAG1             0x02000000U
-#define HAMMER2_MSGF_FLAG0             0x01000000U
-
-#define HAMMER2_MSGF_FLAGS             0xFF000000U     /* all flags */
-#define HAMMER2_MSGF_PROTOS            0x00F00000U     /* all protos */
-#define HAMMER2_MSGF_CMDS              0x000FFF00U     /* all cmds */
-#define HAMMER2_MSGF_SIZE              0x000000FFU     /* N*32 */
-
-#define HAMMER2_MSGF_CMDSWMASK         (HAMMER2_MSGF_CMDS |    \
-                                        HAMMER2_MSGF_SIZE |    \
-                                        HAMMER2_MSGF_PROTOS |  \
-                                        HAMMER2_MSGF_REPLY)
-
-#define HAMMER2_MSGF_BASECMDMASK       (HAMMER2_MSGF_CMDS |    \
-                                        HAMMER2_MSGF_SIZE |    \
-                                        HAMMER2_MSGF_PROTOS)
-
-#define HAMMER2_MSGF_TRANSMASK         (HAMMER2_MSGF_CMDS |    \
-                                        HAMMER2_MSGF_SIZE |    \
-                                        HAMMER2_MSGF_PROTOS |  \
-                                        HAMMER2_MSGF_REPLY |   \
-                                        HAMMER2_MSGF_CREATE |  \
-                                        HAMMER2_MSGF_DELETE)
-
-#define HAMMER2_MSG_PROTO_LNK          0x00000000U
-#define HAMMER2_MSG_PROTO_DBG          0x00100000U
-#define HAMMER2_MSG_PROTO_DOM          0x00200000U
-#define HAMMER2_MSG_PROTO_CAC          0x00300000U
-#define HAMMER2_MSG_PROTO_QRM          0x00400000U
-#define HAMMER2_MSG_PROTO_BLK          0x00500000U
-#define HAMMER2_MSG_PROTO_VOP          0x00600000U
+#define DMSGF_CREATE           0x80000000U     /* msg start */
+#define DMSGF_DELETE           0x40000000U     /* msg end */
+#define DMSGF_REPLY            0x20000000U     /* reply path */
+#define DMSGF_ABORT            0x10000000U     /* abort req */
+#define DMSGF_AUXOOB           0x08000000U     /* aux-data is OOB */
+#define DMSGF_FLAG2            0x04000000U
+#define DMSGF_FLAG1            0x02000000U
+#define DMSGF_FLAG0            0x01000000U
+
+#define DMSGF_FLAGS            0xFF000000U     /* all flags */
+#define DMSGF_PROTOS           0x00F00000U     /* all protos */
+#define DMSGF_CMDS             0x000FFF00U     /* all cmds */
+#define DMSGF_SIZE             0x000000FFU     /* N*32 */
+
+#define DMSGF_CMDSWMASK                (DMSGF_CMDS |   \
+                                        DMSGF_SIZE |   \
+                                        DMSGF_PROTOS | \
+                                        DMSGF_REPLY)
+
+#define DMSGF_BASECMDMASK      (DMSGF_CMDS |   \
+                                        DMSGF_SIZE |   \
+                                        DMSGF_PROTOS)
+
+#define DMSGF_TRANSMASK                (DMSGF_CMDS |   \
+                                        DMSGF_SIZE |   \
+                                        DMSGF_PROTOS | \
+                                        DMSGF_REPLY |  \
+                                        DMSGF_CREATE | \
+                                        DMSGF_DELETE)
+
+#define DMSG_PROTO_LNK         0x00000000U
+#define DMSG_PROTO_DBG         0x00100000U
+#define DMSG_PROTO_DOM         0x00200000U
+#define DMSG_PROTO_CAC         0x00300000U
+#define DMSG_PROTO_QRM         0x00400000U
+#define DMSG_PROTO_BLK         0x00500000U
+#define DMSG_PROTO_VOP         0x00600000U
 
 /*
  * Message command constructors, sans flags
  */
-#define HAMMER2_MSG_ALIGN              64
-#define HAMMER2_MSG_ALIGNMASK          (HAMMER2_MSG_ALIGN - 1)
-#define HAMMER2_MSG_DOALIGN(bytes)     (((bytes) + HAMMER2_MSG_ALIGNMASK) & \
-                                        ~HAMMER2_MSG_ALIGNMASK)
-#define HAMMER2_MSG_HDR_ENCODE(elm)    (((uint32_t)sizeof(struct elm) + \
-                                         HAMMER2_MSG_ALIGNMASK) /      \
-                                        HAMMER2_MSG_ALIGN)
-
-#define HAMMER2_MSG_LNK(cmd, elm)      (HAMMER2_MSG_PROTO_LNK |        \
+#define DMSG_ALIGN             64
+#define DMSG_ALIGNMASK         (DMSG_ALIGN - 1)
+#define DMSG_DOALIGN(bytes)    (((bytes) + DMSG_ALIGNMASK) &           \
+                                ~DMSG_ALIGNMASK)
+
+#define DMSG_HDR_ENCODE(elm)   (((uint32_t)sizeof(struct elm) +        \
+                                 DMSG_ALIGNMASK) /                     \
+                                DMSG_ALIGN)
+
+#define DMSG_LNK(cmd, elm)     (DMSG_PROTO_LNK |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_DBG(cmd, elm)      (HAMMER2_MSG_PROTO_DBG |        \
+#define DMSG_DBG(cmd, elm)     (DMSG_PROTO_DBG |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_DOM(cmd, elm)      (HAMMER2_MSG_PROTO_DOM |        \
+#define DMSG_DOM(cmd, elm)     (DMSG_PROTO_DOM |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_CAC(cmd, elm)      (HAMMER2_MSG_PROTO_CAC |        \
+#define DMSG_CAC(cmd, elm)     (DMSG_PROTO_CAC |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_QRM(cmd, elm)      (HAMMER2_MSG_PROTO_QRM |        \
+#define DMSG_QRM(cmd, elm)     (DMSG_PROTO_QRM |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_BLK(cmd, elm)      (HAMMER2_MSG_PROTO_BLK |        \
+#define DMSG_BLK(cmd, elm)     (DMSG_PROTO_BLK |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
-#define HAMMER2_MSG_VOP(cmd, elm)      (HAMMER2_MSG_PROTO_VOP |        \
+#define DMSG_VOP(cmd, elm)     (DMSG_PROTO_VOP |                       \
                                         ((cmd) << 8) |                 \
-                                        HAMMER2_MSG_HDR_ENCODE(elm))
+                                        DMSG_HDR_ENCODE(elm))
 
 /*
  * Link layer ops basically talk to just the other side of a direct
@@ -346,13 +352,13 @@ typedef struct hammer2_msg_hdr hammer2_msg_hdr_t;
  *               service daemon, and any live configuration change
  *               thereafter.
  */
-#define HAMMER2_LNK_PAD                HAMMER2_MSG_LNK(0x000, hammer2_msg_hdr)
-#define HAMMER2_LNK_PING       HAMMER2_MSG_LNK(0x001, hammer2_msg_hdr)
-#define HAMMER2_LNK_AUTH       HAMMER2_MSG_LNK(0x010, hammer2_lnk_auth)
-#define HAMMER2_LNK_CONN       HAMMER2_MSG_LNK(0x011, hammer2_lnk_conn)
-#define HAMMER2_LNK_SPAN       HAMMER2_MSG_LNK(0x012, hammer2_lnk_span)
-#define HAMMER2_LNK_VOLCONF    HAMMER2_MSG_LNK(0x020, hammer2_lnk_volconf)
-#define HAMMER2_LNK_ERROR      HAMMER2_MSG_LNK(0xFFF, hammer2_msg_hdr)
+#define DMSG_LNK_PAD           DMSG_LNK(0x000, dmsg_hdr)
+#define DMSG_LNK_PING          DMSG_LNK(0x001, dmsg_hdr)
+#define DMSG_LNK_AUTH          DMSG_LNK(0x010, dmsg_lnk_auth)
+#define DMSG_LNK_CONN          DMSG_LNK(0x011, dmsg_lnk_conn)
+#define DMSG_LNK_SPAN          DMSG_LNK(0x012, dmsg_lnk_span)
+#define DMSG_LNK_VOLCONF       DMSG_LNK(0x020, dmsg_lnk_volconf)
+#define DMSG_LNK_ERROR         DMSG_LNK(0xFFF, dmsg_hdr)
 
 /*
  * LNK_CONN - Register connection for SPAN (transaction, left open)
@@ -368,8 +374,8 @@ typedef struct hammer2_msg_hdr hammer2_msg_hdr_t;
  * not be executed on the connection, nor is this message a promise that the
  * sending end is a client or node of a cluster.
  */
-struct hammer2_lnk_auth {
-       hammer2_msg_hdr_t head;
+struct dmsg_lnk_auth {
+       dmsg_hdr_t      head;
        char            dummy[64];
 };
 
@@ -380,8 +386,8 @@ struct hammer2_lnk_auth {
  *
  * peer_mask serves to filter the SPANs we receive by peer.  A cluster
  * controller typically sets this to (uint64_t)-1, a block devfs
- * interface might set it to 1 << HAMMER2_PEER_DISK, and a hammer2
- * mount might set it to 1 << HAMMER2_PEER_HAMMER2.
+ * interface might set it to 1 << DMSG_PEER_DISK, and a hammer2
+ * mount might set it to 1 << DMSG_PEER_HAMMER2.
  *
  * mediaid allows multiple (e.g. HAMMER2) connections belonging to the same
  * media, in terms of LNK_VOLCONF updates.
@@ -389,17 +395,17 @@ struct hammer2_lnk_auth {
  * pfs_clid, pfs_fsid, pfs_type, and label are peer-specific and must be
  * left empty (zero-fill) if not supported by a particular peer.
  *
- * HAMMER2_PEER_CLUSTER                filter: none
- * HAMMER2_PEER_DISK           filter: label
- * HAMMER2_PEER_HAMMER2                filter: pfs_clid if not empty, and label
+ * DMSG_PEER_CLUSTER           filter: none
+ * DMSG_PEER_DISK              filter: label
+ * DMSG_PEER_HAMMER2           filter: pfs_clid if not empty, and label
  */
-struct hammer2_lnk_conn {
-       hammer2_msg_hdr_t head;
+struct dmsg_lnk_conn {
+       dmsg_hdr_t      head;
        uuid_t          mediaid;        /* media configuration id */
        uuid_t          pfs_clid;       /* rendezvous pfs uuid */
        uuid_t          pfs_fsid;       /* unique pfs uuid */
        uint64_t        peer_mask;      /* PEER mask for SPAN filtering */
-       uint8_t         peer_type;      /* see HAMMER2_PEER_xxx */
+       uint8_t         peer_type;      /* see DMSG_PEER_xxx */
        uint8_t         pfs_type;       /* pfs type */
        uint16_t        proto_version;  /* high level protocol support */
        uint32_t        status;         /* status flags */
@@ -409,7 +415,7 @@ struct hammer2_lnk_conn {
        char            label[256];     /* PFS label (can be wildcard) */
 };
 
-typedef struct hammer2_lnk_conn hammer2_lnk_conn_t;
+typedef struct dmsg_lnk_conn dmsg_lnk_conn_t;
 
 /*
  * LNK_SPAN - Relay a SPAN (transaction, left open)
@@ -453,8 +459,8 @@ typedef struct hammer2_lnk_conn hammer2_lnk_conn_t;
  *                only contain incremental changes to pfs_type, with the
  *                label field containing a text status.
  */
-struct hammer2_lnk_span {
-       hammer2_msg_hdr_t head;
+struct dmsg_lnk_span {
+       dmsg_hdr_t      head;
        uuid_t          pfs_clid;       /* rendezvous pfs uuid */
        uuid_t          pfs_fsid;       /* unique pfs uuid */
        uint8_t         pfs_type;       /* PFS type */
@@ -467,23 +473,74 @@ struct hammer2_lnk_span {
        char            label[256];     /* PFS label (can be wildcard) */
 };
 
-typedef struct hammer2_lnk_span hammer2_lnk_span_t;
+typedef struct dmsg_lnk_span dmsg_lnk_span_t;
 
-#define HAMMER2_SPAN_PROTO_1   1
+#define DMSG_SPAN_PROTO_1      1
 
 /*
  * LNK_VOLCONF
  */
-struct hammer2_lnk_volconf {
-       hammer2_msg_hdr_t       head;
-       hammer2_copy_data_t     copy;   /* copy spec */
+
+/*
+ * All HAMMER2 directories directly under the super-root on your local
+ * media can be mounted separately, even if they share the same physical
+ * device.
+ *
+ * When you do a HAMMER2 mount you are effectively tying into a HAMMER2
+ * cluster via local media.  The local media does not have to participate
+ * in the cluster, other than to provide the hammer2_copy_data[] array and
+ * root inode for the mount.
+ *
+ * This is important: The mount device path you specify serves to bootstrap
+ * your entry into the cluster, but your mount will make active connections
+ * to ALL copy elements in the hammer2_copy_data[] array which match the
+ * PFSID of the directory in the super-root that you specified.  The local
+ * media path does not have to be mentioned in this array but becomes part
+ * of the cluster based on its type and access rights.  ALL ELEMENTS ARE
+ * TREATED ACCORDING TO TYPE NO MATTER WHICH ONE YOU MOUNT FROM.
+ *
+ * The actual cluster may be far larger than the elements you list in the
+ * hammer2_copy_data[] array.  You list only the elements you wish to
+ * directly connect to and you are able to access the rest of the cluster
+ * indirectly through those connections.
+ *
+ * This structure must be exactly 128 bytes long.
+ *
+ * WARNING!  dmsg_vol_data is embedded in the hammer2 media volume header
+ */
+struct dmsg_vol_data {
+       uint8_t copyid;         /* 00    copyid 0-255 (must match slot) */
+       uint8_t inprog;         /* 01    operation in progress, or 0 */
+       uint8_t chain_to;       /* 02    operation chaining to, or 0 */
+       uint8_t chain_from;     /* 03    operation chaining from, or 0 */
+       uint16_t flags;         /* 04-05 flags field */
+       uint8_t error;          /* 06    last operational error */
+       uint8_t priority;       /* 07    priority and round-robin flag */
+       uint8_t remote_pfs_type;/* 08    probed direct remote PFS type */
+       uint8_t reserved08[23]; /* 09-1F */
+       uuid_t  pfs_clid;       /* 20-2F copy target must match this uuid */
+       uint8_t label[16];      /* 30-3F import/export label */
+       uint8_t path[64];       /* 40-7F target specification string or key */
+};
+
+typedef struct dmsg_vol_data dmsg_vol_data_t;
+
+#define DMSG_VOLF_ENABLED      0x0001
+#define DMSG_VOLF_INPROG       0x0002
+#define DMSG_VOLF_CONN_RR      0x80    /* round-robin at same priority */
+#define DMSG_VOLF_CONN_EF      0x40    /* media errors flagged */
+#define DMSG_VOLF_CONN_PRI     0x0F    /* select priority 0-15 (15=best) */
+
+struct dmsg_lnk_volconf {
+       dmsg_hdr_t              head;
+       dmsg_vol_data_t         copy;   /* copy spec */
        int32_t                 index;
        int32_t                 unused01;
        uuid_t                  mediaid;
        int64_t                 reserved02[32];
 };
 
-typedef struct hammer2_lnk_volconf hammer2_lnk_volconf_t;
+typedef struct dmsg_lnk_volconf dmsg_lnk_volconf_t;
 
 /*
  * Debug layer ops operate on any link
@@ -491,12 +548,12 @@ typedef struct hammer2_lnk_volconf hammer2_lnk_volconf_t;
  * SHELL       - Persist stream, access the debug shell on the target
  *               registration.  Multiple shells can be operational.
  */
-#define HAMMER2_DBG_SHELL      HAMMER2_MSG_DBG(0x001, hammer2_dbg_shell)
+#define DMSG_DBG_SHELL         DMSG_DBG(0x001, dmsg_dbg_shell)
 
-struct hammer2_dbg_shell {
-       hammer2_msg_hdr_t       head;
+struct dmsg_dbg_shell {
+       dmsg_hdr_t      head;
 };
-typedef struct hammer2_dbg_shell hammer2_dbg_shell_t;
+typedef struct dmsg_dbg_shell dmsg_dbg_shell_t;
 
 /*
  * Domain layer ops operate on any link, link-0 may be used when the
@@ -553,7 +610,7 @@ typedef struct hammer2_dbg_shell hammer2_dbg_shell_t;
  *               The cache state includes transaction id information which
  *               can be used to resolve data requests.
  */
-#define HAMMER2_CAC_LOCK       HAMMER2_MSG_CAC(0x001, hammer2_cac_lock)
+#define DMSG_CAC_LOCK          DMSG_CAC(0x001, dmsg_cac_lock)
 
 /*
  * Quorum layer ops operate on any link, link-0 may be used when the
@@ -565,7 +622,7 @@ typedef struct hammer2_dbg_shell hammer2_dbg_shell_t;
  *               the operation to proceed to phase-2.  Message-update to
  *               proceed to phase-2.
  */
-#define HAMMER2_QRM_COMMIT     HAMMER2_MSG_QRM(0x001, hammer2_qrm_commit)
+#define DMSG_QRM_COMMIT                DMSG_QRM(0x001, dmsg_qrm_commit)
 
 /*
  * NOTE!!!! ALL EXTENDED HEADER STRUCTURES MUST BE 64-BYTE ALIGNED!!!
@@ -575,16 +632,16 @@ typedef struct hammer2_dbg_shell hammer2_dbg_shell_t;
  *     0x00 - 0x1F     Local iocomm errors
  *     0x20 - 0x2F     Global errors
  */
-#define HAMMER2_MSG_ERR_NOSUPP         0x20
-
-union hammer2_msg_any {
-       char                    buf[HAMMER2_MSGHDR_MAX];
-       hammer2_msg_hdr_t       head;
-       hammer2_lnk_span_t      lnk_span;
-       hammer2_lnk_conn_t      lnk_conn;
-       hammer2_lnk_volconf_t   lnk_volconf;
+#define DMSG_ERR_NOSUPP                0x20
+
+union dmsg_any {
+       char                    buf[DMSG_HDR_MAX];
+       dmsg_hdr_t              head;
+       dmsg_lnk_span_t         lnk_span;
+       dmsg_lnk_conn_t         lnk_conn;
+       dmsg_lnk_volconf_t      lnk_volconf;
 };
 
-typedef union hammer2_msg_any hammer2_msg_any_t;
+typedef union dmsg_any dmsg_any_t;
 
 #endif
index 595200d..b9cb410 100644 (file)
 #include <sys/buf2.h>
 #include <sys/signal2.h>
 #include <sys/tree.h>
+#include <sys/dmsg.h>
 
 #include "hammer2_disk.h"
 #include "hammer2_mount.h"
 #include "hammer2_ioctl.h"
 #include "hammer2_ccms.h"
-#include "hammer2_network.h"
 
 struct hammer2_chain;
 struct hammer2_inode;
@@ -390,7 +390,7 @@ struct hammer2_msg {
        size_t          hdr_size;
        size_t          aux_size;
        char            *aux_data;
-       hammer2_msg_any_t any;
+       dmsg_any_t      any;
 };
 
 typedef struct hammer2_link hammer2_link_t;
index af13fd3..4ff3921 100644 (file)
@@ -38,6 +38,9 @@
 #ifndef _SYS_UUID_H_
 #include <sys/uuid.h>
 #endif
+#ifndef _SYS_DMSG_H_
+#include <sys/dmsg.h>
+#endif
 
 /*
  * The structures below represent the on-disk media structures for the HAMMER2
@@ -601,54 +604,6 @@ typedef struct hammer2_allocref hammer2_allocref_t;
 #define HAMMER2_ALLOCREF_ALTD          0x0003  /* unsupported */
 #define HAMMER2_ALLOCREF_LEAF          0x0004
 
-/*
- * All HAMMER2 directories directly under the super-root on your local
- * media can be mounted separately, even if they share the same physical
- * device.
- *
- * When you do a HAMMER2 mount you are effectively tying into a HAMMER2
- * cluster via local media.  The local media does not have to participate
- * in the cluster, other than to provide the hammer2_copy_data[] array and
- * root inode for the mount.
- *
- * This is important: The mount device path you specify serves to bootstrap
- * your entry into the cluster, but your mount will make active connections
- * to ALL copy elements in the hammer2_copy_data[] array which match the
- * PFSID of the directory in the super-root that you specified.  The local
- * media path does not have to be mentioned in this array but becomes part
- * of the cluster based on its type and access rights.  ALL ELEMENTS ARE
- * TREATED ACCORDING TO TYPE NO MATTER WHICH ONE YOU MOUNT FROM.
- *
- * The actual cluster may be far larger than the elements you list in the
- * hammer2_copy_data[] array.  You list only the elements you wish to
- * directly connect to and you are able to access the rest of the cluster
- * indirectly through those connections.
- *
- * This structure must be exactly 128 bytes long.
- */
-struct hammer2_copy_data {
-       uint8_t copyid;         /* 00    copyid 0-255 (must match slot) */
-       uint8_t inprog;         /* 01    operation in progress, or 0 */
-       uint8_t chain_to;       /* 02    operation chaining to, or 0 */
-       uint8_t chain_from;     /* 03    operation chaining from, or 0 */
-       uint16_t flags;         /* 04-05 flags field */
-       uint8_t error;          /* 06    last operational error */
-       uint8_t priority;       /* 07    priority and round-robin flag */
-       uint8_t remote_pfs_type;/* 08    probed direct remote PFS type */
-       uint8_t reserved08[23]; /* 09-1F */
-       uuid_t  pfs_clid;       /* 20-2F copy target must match this uuid */
-       uint8_t label[16];      /* 30-3F import/export label */
-       uint8_t path[64];       /* 40-7F target specification string or key */
-};
-
-typedef struct hammer2_copy_data hammer2_copy_data_t;
-
-#define COPYDATAF_ENABLED      0x0001
-#define COPYDATAF_INPROG       0x0002
-#define COPYDATAF_CONN_RR      0x80    /* round-robin at same priority */
-#define COPYDATAF_CONN_EF      0x40    /* media errors flagged */
-#define COPYDATAF_CONN_PRI     0x0F    /* select priority 0-15 (15=best) */
-
 /*
  * The volume header eats a 64K block.  There is currently an issue where
  * we want to try to fit all nominal filesystem updates in a 512-byte section
@@ -789,11 +744,7 @@ struct hammer2_volume_data {
         * indexes into this array.
         */
                                                /* 1000-8FFF copyinfo config */
-       struct hammer2_copy_data copyinfo[HAMMER2_COPYID_COUNT];
-
-       /*
-        *
-        */
+       dmsg_vol_data_t copyinfo[HAMMER2_COPYID_COUNT];
 
        /*
         * Remaining sections are reserved for future use.
index f0f13e6..28a33b9 100644 (file)
@@ -72,8 +72,8 @@ struct hammer2_ioc_remote {
        int                     fd;     /* socket descriptor if applicable */
        int                     reserved03;
        int                     reserved04[8];
-       hammer2_copy_data_t     copy1;  /* copy spec */
-       hammer2_copy_data_t     copy2;  /* copy spec (rename ops only) */
+       dmsg_vol_data_t         copy1;  /* copy spec */
+       dmsg_vol_data_t         copy2;  /* copy spec (rename ops only) */
 };
 
 typedef struct hammer2_ioc_remote hammer2_ioc_remote_t;
index a7619e3..d5fd2b5 100644 (file)
@@ -146,7 +146,7 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                (intmax_t)msg->any.head.msgid,
                (intmax_t)msg->any.head.source,
                (intmax_t)msg->any.head.target);
-       if (msg->any.head.cmd & HAMMER2_MSGF_REPLY)
+       if (msg->any.head.cmd & DMSGF_REPLY)
                state = RB_FIND(hammer2_state_tree, &pmp->statewr_tree, state);
        else
                state = RB_FIND(hammer2_state_tree, &pmp->staterd_tree, state);
@@ -155,8 +155,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
        /*
         * Short-cut one-off or mid-stream messages (state may be NULL).
         */
-       if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                 HAMMER2_MSGF_ABORT)) == 0) {
+       if ((msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                 DMSGF_ABORT)) == 0) {
                lockmgr(&pmp->msglk, LK_RELEASE);
                return(0);
        }
@@ -165,10 +165,9 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
         * Switch on CREATE, DELETE, REPLY, and also handle ABORT from
         * inside the case statements.
         */
-       switch(msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                   HAMMER2_MSGF_REPLY)) {
-       case HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       switch(msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE | DMSGF_REPLY)) {
+       case DMSGF_CREATE:
+       case DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * New persistant command received.
                 */
@@ -182,19 +181,19 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                msg->state = state;
                state->router = msg->router;
                state->msg = msg;
-               state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
-               state->txcmd = HAMMER2_MSGF_REPLY;
+               state->rxcmd = msg->any.head.cmd & ~DMSGF_DELETE;
+               state->txcmd = DMSGF_REPLY;
                RB_INSERT(hammer2_state_tree, &pmp->staterd_tree, state);
                state->flags |= HAMMER2_STATE_INSERTED;
                error = 0;
                break;
-       case HAMMER2_MSGF_DELETE:
+       case DMSGF_DELETE:
                /*
                 * Persistent state is expected but might not exist if an
                 * ABORT+DELETE races the close.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgrx: no state "
@@ -208,8 +207,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * Handle another ABORT+DELETE case if the msgid has already
                 * been reused.
                 */
-               if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->rxcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgrx: state reused "
@@ -225,17 +224,17 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * Check for mid-stream ABORT command received, otherwise
                 * allow.
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->rxcmd & DMSGF_CREATE) == 0) {
                                error = EALREADY;
                                break;
                        }
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_CREATE:
+       case DMSGF_REPLY | DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * When receiving a reply with CREATE set the original
                 * persistent state message should already exist.
@@ -248,16 +247,16 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                        error = EINVAL;
                        break;
                }
-               state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+               state->rxcmd = msg->any.head.cmd & ~DMSGF_DELETE;
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_DELETE:
                /*
                 * Received REPLY+ABORT+DELETE in case where msgid has
                 * already been fully closed, ignore the message.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgrx: no state match "
@@ -272,8 +271,8 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                 * already been reused for an unrelated message,
                 * ignore the message.
                 */
-               if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->rxcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgrx: state reused "
@@ -284,13 +283,13 @@ hammer2_state_msgrx(hammer2_msg_t *msg)
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY:
+       case DMSGF_REPLY:
                /*
                 * Check for mid-stream ABORT reply received to sent command.
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->rxcmd & DMSGF_CREATE) == 0) {
                                error = EALREADY;
                                break;
                        }
@@ -310,21 +309,21 @@ hammer2_state_cleanuprx(hammer2_msg_t *msg)
 
        if ((state = msg->state) == NULL) {
                hammer2_msg_free(msg);
-       } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       } else if (msg->any.head.cmd & DMSGF_DELETE) {
                lockmgr(&pmp->msglk, LK_EXCLUSIVE);
-               state->rxcmd |= HAMMER2_MSGF_DELETE;
-               if (state->txcmd & HAMMER2_MSGF_DELETE) {
+               state->rxcmd |= DMSGF_DELETE;
+               if (state->txcmd & DMSGF_DELETE) {
                        if (state->msg == msg)
                                state->msg = NULL;
                        KKASSERT(state->flags & HAMMER2_STATE_INSERTED);
-                       if (state->rxcmd & HAMMER2_MSGF_REPLY) {
+                       if (state->rxcmd & DMSGF_REPLY) {
                                KKASSERT(msg->any.head.cmd &
-                                        HAMMER2_MSGF_REPLY);
+                                        DMSGF_REPLY);
                                RB_REMOVE(hammer2_state_tree,
                                          &pmp->statewr_tree, state);
                        } else {
                                KKASSERT((msg->any.head.cmd &
-                                         HAMMER2_MSGF_REPLY) == 0);
+                                         DMSGF_REPLY) == 0);
                                RB_REMOVE(hammer2_state_tree,
                                          &pmp->staterd_tree, state);
                        }
@@ -382,8 +381,8 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
        /*
         * Short-cut one-off or mid-stream messages (state may be NULL).
         */
-       if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                 HAMMER2_MSGF_ABORT)) == 0) {
+       if ((msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                 DMSGF_ABORT)) == 0) {
                lockmgr(&pmp->msglk, LK_RELEASE);
                return(0);
        }
@@ -393,10 +392,10 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
         * Switch on CREATE, DELETE, REPLY, and also handle ABORT from
         * inside the case statements.
         */
-       switch(msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
-                                   HAMMER2_MSGF_REPLY)) {
-       case HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       switch(msg->any.head.cmd & (DMSGF_CREATE | DMSGF_DELETE |
+                                   DMSGF_REPLY)) {
+       case DMSGF_CREATE:
+       case DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * Insert the new persistent message state and mark
                 * half-closed if DELETE is set.  Since this is a new
@@ -408,17 +407,17 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                 *     on-transmit.
                 */
                KKASSERT(state != NULL);
-               state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
-               state->rxcmd = HAMMER2_MSGF_REPLY;
+               state->txcmd = msg->any.head.cmd & ~DMSGF_DELETE;
+               state->rxcmd = DMSGF_REPLY;
                error = 0;
                break;
-       case HAMMER2_MSGF_DELETE:
+       case DMSGF_DELETE:
                /*
                 * Sent ABORT+DELETE in case where msgid has already
                 * been fully closed, ignore the message.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgtx: no state match "
@@ -435,8 +434,8 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                 * already been reused for an unrelated message,
                 * ignore the message.
                 */
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->txcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgtx: state reused "
@@ -451,17 +450,17 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                /*
                 * Check for mid-stream ABORT command sent
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->txcmd & DMSGF_CREATE) == 0) {
                                error = EALREADY;
                                break;
                        }
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE:
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_CREATE:
+       case DMSGF_REPLY | DMSGF_CREATE | DMSGF_DELETE:
                /*
                 * When transmitting a reply with CREATE set the original
                 * persistent state message should already exist.
@@ -472,10 +471,10 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                        error = EINVAL;
                        break;
                }
-               state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
+               state->txcmd = msg->any.head.cmd & ~DMSGF_DELETE;
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_DELETE:
+       case DMSGF_REPLY | DMSGF_DELETE:
                /*
                 * When transmitting a reply with DELETE set the original
                 * persistent state message should already exist.
@@ -487,7 +486,7 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                 * already been fully closed, ignore the message.
                 */
                if (state == NULL) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgtx: no state match "
@@ -501,8 +500,8 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                 * Sent REPLY+ABORT+DELETE in case where msgid has already
                 * been reused for an unrelated message, ignore the message.
                 */
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
-                       if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if ((state->txcmd & DMSGF_CREATE) == 0) {
+                       if (msg->any.head.cmd & DMSGF_ABORT) {
                                error = EALREADY;
                        } else {
                                kprintf("hammer2_state_msgtx: state reused "
@@ -513,15 +512,15 @@ hammer2_state_msgtx(hammer2_msg_t *msg)
                }
                error = 0;
                break;
-       case HAMMER2_MSGF_REPLY:
+       case DMSGF_REPLY:
                /*
                 * Check for mid-stream ABORT reply sent.
                 *
                 * One-off REPLY messages are allowed for e.g. status updates.
                 */
-               if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
+               if (msg->any.head.cmd & DMSGF_ABORT) {
                        if (state == NULL ||
-                           (state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
+                           (state->txcmd & DMSGF_CREATE) == 0) {
                                error = EALREADY;
                                break;
                        }
@@ -541,21 +540,21 @@ hammer2_state_cleanuptx(hammer2_msg_t *msg)
 
        if ((state = msg->state) == NULL) {
                hammer2_msg_free(msg);
-       } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
+       } else if (msg->any.head.cmd & DMSGF_DELETE) {
                lockmgr(&pmp->msglk, LK_EXCLUSIVE);
-               state->txcmd |= HAMMER2_MSGF_DELETE;
-               if (state->rxcmd & HAMMER2_MSGF_DELETE) {
+               state->txcmd |= DMSGF_DELETE;
+               if (state->rxcmd & DMSGF_DELETE) {
                        if (state->msg == msg)
                                state->msg = NULL;
                        KKASSERT(state->flags & HAMMER2_STATE_INSERTED);
-                       if (state->txcmd & HAMMER2_MSGF_REPLY) {
+                       if (state->txcmd & DMSGF_REPLY) {
                                KKASSERT(msg->any.head.cmd &
-                                        HAMMER2_MSGF_REPLY);
+                                        DMSGF_REPLY);
                                RB_REMOVE(hammer2_state_tree,
                                          &pmp->staterd_tree, state);
                        } else {
                                KKASSERT((msg->any.head.cmd &
-                                         HAMMER2_MSGF_REPLY) == 0);
+                                         DMSGF_REPLY) == 0);
                                RB_REMOVE(hammer2_state_tree,
                                          &pmp->statewr_tree, state);
                        }
@@ -594,18 +593,18 @@ hammer2_msg_alloc(hammer2_router_t *router, uint32_t cmd,
        hammer2_state_t *state;
        size_t hbytes;
 
-       hbytes = (cmd & HAMMER2_MSGF_SIZE) * HAMMER2_MSG_ALIGN;
+       hbytes = (cmd & DMSGF_SIZE) * DMSG_ALIGN;
        msg = kmalloc(offsetof(struct hammer2_msg, any) + hbytes,
                      pmp->mmsg, M_WAITOK | M_ZERO);
        msg->hdr_size = hbytes;
        msg->router = router;
        KKASSERT(router != NULL);
-       msg->any.head.magic = HAMMER2_MSGHDR_MAGIC;
+       msg->any.head.magic = DMSG_HDR_MAGIC;
        msg->any.head.source = 0;
        msg->any.head.target = router->target;
        msg->any.head.cmd = cmd;
 
-       if (cmd & HAMMER2_MSGF_CREATE) {
+       if (cmd & DMSGF_CREATE) {
                /*
                 * New transaction, requires tracking state and a unique
                 * msgid to be allocated.
@@ -743,7 +742,7 @@ hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
        /*
         * Reply with a simple error code and terminate the transaction.
         */
-       cmd = HAMMER2_LNK_ERROR;
+       cmd = DMSG_LNK_ERROR;
 
        /*
         * Check if our direction has even been initiated yet, set CREATE.
@@ -755,21 +754,21 @@ hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
         * doing anything.
         */
        if (state) {
-               if (state->txcmd & HAMMER2_MSGF_DELETE)
+               if (state->txcmd & DMSGF_DELETE)
                        return;
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
-                       cmd |= HAMMER2_MSGF_CREATE;
-               if (state->txcmd & HAMMER2_MSGF_REPLY)
-                       cmd |= HAMMER2_MSGF_REPLY;
-               cmd |= HAMMER2_MSGF_DELETE;
+               if ((state->txcmd & DMSGF_CREATE) == 0)
+                       cmd |= DMSGF_CREATE;
+               if (state->txcmd & DMSGF_REPLY)
+                       cmd |= DMSGF_REPLY;
+               cmd |= DMSGF_DELETE;
        } else {
-               if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if ((msg->any.head.cmd & DMSGF_REPLY) == 0)
+                       cmd |= DMSGF_REPLY;
        }
        kprintf("MSG_REPLY state=%p msg %08x\n", state, cmd);
 
        /* XXX messy mask cmd to avoid allocating state */
-       nmsg = hammer2_msg_alloc(msg->router, cmd & HAMMER2_MSGF_BASECMDMASK,
+       nmsg = hammer2_msg_alloc(msg->router, cmd & DMSGF_BASECMDMASK,
                                 NULL, NULL);
        nmsg->any.head.cmd = cmd;
        nmsg->any.head.error = error;
@@ -793,7 +792,7 @@ hammer2_msg_result(hammer2_msg_t *msg, uint32_t error)
        /*
         * Return a simple result code, do NOT terminate the transaction.
         */
-       cmd = HAMMER2_LNK_ERROR;
+       cmd = DMSG_LNK_ERROR;
 
        /*
         * Check if our direction has even been initiated yet, set CREATE.
@@ -805,20 +804,20 @@ hammer2_msg_result(hammer2_msg_t *msg, uint32_t error)
         * doing anything.
         */
        if (state) {
-               if (state->txcmd & HAMMER2_MSGF_DELETE)
+               if (state->txcmd & DMSGF_DELETE)
                        return;
-               if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
-                       cmd |= HAMMER2_MSGF_CREATE;
-               if (state->txcmd & HAMMER2_MSGF_REPLY)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if ((state->txcmd & DMSGF_CREATE) == 0)
+                       cmd |= DMSGF_CREATE;
+               if (state->txcmd & DMSGF_REPLY)
+                       cmd |= DMSGF_REPLY;
                /* continuing transaction, do not set MSGF_DELETE */
        } else {
-               if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
-                       cmd |= HAMMER2_MSGF_REPLY;
+               if ((msg->any.head.cmd & DMSGF_REPLY) == 0)
+                       cmd |= DMSGF_REPLY;
        }
 
        /* XXX messy mask cmd to avoid allocating state */
-       nmsg = hammer2_msg_alloc(msg->router, cmd & HAMMER2_MSGF_BASECMDMASK,
+       nmsg = hammer2_msg_alloc(msg->router, cmd & DMSGF_BASECMDMASK,
                                 NULL, NULL);
        nmsg->any.head.cmd = cmd;
        nmsg->any.head.error = error;
index 012cefd..b9277a7 100644 (file)
@@ -56,21 +56,21 @@ hammer2_msg_adhoc_input(hammer2_msg_t *msg)
 int
 hammer2_msg_dbg_rcvmsg(hammer2_msg_t *msg)
 {
-       switch(msg->any.head.cmd & HAMMER2_MSGF_CMDSWMASK) {
-       case HAMMER2_DBG_SHELL:
+       switch(msg->any.head.cmd & DMSGF_CMDSWMASK) {
+       case DMSG_DBG_SHELL:
                /*
                 * Execute shell command (not supported atm)
                 */
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
-       case HAMMER2_DBG_SHELL | HAMMER2_MSGF_REPLY:
+       case DMSG_DBG_SHELL | DMSGF_REPLY:
                if (msg->aux_data) {
                        msg->aux_data[msg->aux_size - 1] = 0;
                        kprintf("DEBUGMSG: %s\n", msg->aux_data);
                }
                break;
        default:
-               hammer2_msg_reply(msg, HAMMER2_MSG_ERR_NOSUPP);
+               hammer2_msg_reply(msg, DMSG_ERR_NOSUPP);
                break;
        }
        return(0);
index 7046890..3a650d8 100644 (file)
@@ -47,7 +47,6 @@
 #include "hammer2.h"
 #include "hammer2_disk.h"
 #include "hammer2_mount.h"
-#include "hammer2_network.h"
 
 struct hammer2_sync_info {
        int error;
@@ -1054,7 +1053,7 @@ void
 hammer2_cluster_thread_rd(void *arg)
 {
        hammer2_pfsmount_t *pmp = arg;
-       hammer2_msg_hdr_t hdr;
+       dmsg_hdr_t hdr;
        hammer2_msg_t *msg;
        hammer2_state_t *state;
        size_t hbytes;
@@ -1068,14 +1067,14 @@ hammer2_cluster_thread_rd(void *arg)
                                NULL, 1, UIO_SYSSPACE);
                if (error)
                        break;
-               if (hdr.magic != HAMMER2_MSGHDR_MAGIC) {
+               if (hdr.magic != DMSG_HDR_MAGIC) {
                        kprintf("hammer2: msgrd: bad magic: %04x\n",
                                hdr.magic);
                        error = EINVAL;
                        break;
                }
-               hbytes = (hdr.cmd & HAMMER2_MSGF_SIZE) * HAMMER2_MSG_ALIGN;
-               if (hbytes < sizeof(hdr) || hbytes > HAMMER2_MSGAUX_MAX) {
+               hbytes = (hdr.cmd & DMSGF_SIZE) * DMSG_ALIGN;
+               if (hbytes < sizeof(hdr) || hbytes > DMSG_AUX_MAX) {
                        kprintf("hammer2: msgrd: bad header size %zd\n",
                                hbytes);
                        error = EINVAL;
@@ -1083,7 +1082,7 @@ hammer2_cluster_thread_rd(void *arg)
                }
                /* XXX messy: mask cmd to avoid allocating state */
                msg = hammer2_msg_alloc(&pmp->router,
-                                       hdr.cmd & HAMMER2_MSGF_BASECMDMASK,
+                                       hdr.cmd & DMSGF_BASECMDMASK,
                                        NULL, NULL);
                msg->any.head = hdr;
                msg->hdr_size = hbytes;
@@ -1097,8 +1096,8 @@ hammer2_cluster_thread_rd(void *arg)
                                break;
                        }
                }
-               msg->aux_size = hdr.aux_bytes * HAMMER2_MSG_ALIGN;
-               if (msg->aux_size > HAMMER2_MSGAUX_MAX) {
+               msg->aux_size = hdr.aux_bytes * DMSG_ALIGN;
+               if (msg->aux_size > DMSG_AUX_MAX) {
                        kprintf("hammer2: illegal msg payload size %zd\n",
                                msg->aux_size);
                        error = EINVAL;
@@ -1138,15 +1137,15 @@ hammer2_cluster_thread_rd(void *arg)
                         */
                        error = msg->state->func(msg->state, msg);
                        hammer2_state_cleanuprx(msg);
-               } else if ((msg->any.head.cmd & HAMMER2_MSGF_PROTOS) ==
-                          HAMMER2_MSG_PROTO_LNK) {
+               } else if ((msg->any.head.cmd & DMSGF_PROTOS) ==
+                          DMSG_PROTO_LNK) {
                        /*
                         * Message related to the LNK protocol set
                         */
                        error = hammer2_msg_lnk_rcvmsg(msg);
                        hammer2_state_cleanuprx(msg);
-               } else if ((msg->any.head.cmd & HAMMER2_MSGF_PROTOS) ==
-                          HAMMER2_MSG_PROTO_DBG) {
+               } else if ((msg->any.head.cmd & DMSGF_PROTOS) ==
+                          DMSG_PROTO_DBG) {
                        /*
                         * Message related to the DBG protocol set
                         */
@@ -1234,13 +1233,12 @@ hammer2_cluster_thread_wr(void *arg)
         * The transaction remains fully open for the duration of the
         * connection.
         */
-       msg = hammer2_msg_alloc(&pmp->router, HAMMER2_LNK_CONN |
-                                             HAMMER2_MSGF_CREATE,
+       msg = hammer2_msg_alloc(&pmp->router, DMSG_LNK_CONN | DMSGF_CREATE,
                                hammer2_msg_conn_reply, pmp);
        msg->any.lnk_conn.pfs_clid = pmp->iroot->ip_data.pfs_clid;
        msg->any.lnk_conn.pfs_fsid = pmp->iroot->ip_data.pfs_fsid;
        msg->any.lnk_conn.pfs_type = pmp->iroot->ip_data.pfs_type;
-       msg->any.lnk_conn.proto_version = HAMMER2_SPAN_PROTO_1;
+       msg->any.lnk_conn.proto_version = DMSG_SPAN_PROTO_1;
        msg->any.lnk_conn.peer_type = pmp->hmp->voldata.peer_type;
        msg->any.lnk_conn.peer_mask = 1LLU << HAMMER2_PEER_HAMMER2;
        name_len = pmp->iroot->ip_data.name_len;
@@ -1356,17 +1354,16 @@ hammer2_cluster_thread_wr(void *arg)
 cleanuprd:
        RB_FOREACH(state, hammer2_state_tree, &pmp->staterd_tree) {
                if (state->func &&
-                   (state->rxcmd & HAMMER2_MSGF_DELETE) == 0) {
+                   (state->rxcmd & DMSGF_DELETE) == 0) {
                        lockmgr(&pmp->msglk, LK_RELEASE);
-                       msg = hammer2_msg_alloc(&pmp->router,
-                                               HAMMER2_LNK_ERROR,
+                       msg = hammer2_msg_alloc(&pmp->router, DMSG_LNK_ERROR,
                                                NULL, NULL);
-                       if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0)
-                               msg->any.head.cmd |= HAMMER2_MSGF_CREATE;
-                       msg->any.head.cmd |= HAMMER2_MSGF_DELETE;
+                       if ((state->rxcmd & DMSGF_CREATE) == 0)
+                               msg->any.head.cmd |= DMSGF_CREATE;
+                       msg->any.head.cmd |= DMSGF_DELETE;
                        msg->state = state;
                        state->rxcmd = msg->any.head.cmd &
-                                      ~HAMMER2_MSGF_DELETE;
+                                      ~DMSGF_DELETE;
                        msg->state->func(state, msg);
                        hammer2_state_cleanuprx(msg);
                        lockmgr(&pmp->msglk, LK_EXCLUSIVE);
@@ -1391,18 +1388,18 @@ cleanupwr:
        hammer2_drain_msgq(pmp);
        RB_FOREACH(state, hammer2_state_tree, &pmp->statewr_tree) {
                if (state->func &&
-                   (state->rxcmd & HAMMER2_MSGF_DELETE) == 0) {
+                   (state->rxcmd & DMSGF_DELETE) == 0) {
                        lockmgr(&pmp->msglk, LK_RELEASE);
                        msg = hammer2_msg_alloc(&pmp->router,
-                                               HAMMER2_LNK_ERROR,
+                                               DMSG_LNK_ERROR,
                                                NULL, NULL);
-                       if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0)
-                               msg->any.head.cmd |= HAMMER2_MSGF_CREATE;
-                       msg->any.head.cmd |= HAMMER2_MSGF_DELETE |
-                                            HAMMER2_MSGF_REPLY;
+                       if ((state->rxcmd & DMSGF_CREATE) == 0)
+                               msg->any.head.cmd |= DMSGF_CREATE;
+                       msg->any.head.cmd |= DMSGF_DELETE |
+                                            DMSGF_REPLY;
                        msg->state = state;
                        state->rxcmd = msg->any.head.cmd &
-                                      ~HAMMER2_MSGF_DELETE;
+                                      ~DMSGF_DELETE;
                        msg->state->func(state, msg);
                        hammer2_state_cleanuprx(msg);
                        lockmgr(&pmp->msglk, LK_EXCLUSIVE);
@@ -1493,18 +1490,18 @@ hammer2_clusterctl_wakeup(hammer2_pfsmount_t *pmp)
 static int
 hammer2_msg_lnk_rcvmsg(hammer2_msg_t *msg)
 {
-       switch(msg->any.head.cmd & HAMMER2_MSGF_TRANSMASK) {
-       case HAMMER2_LNK_CONN | HAMMER2_MSGF_CREATE:
+       switch(msg->any.head.cmd & DMSGF_TRANSMASK) {
+       case DMSG_LNK_CONN | DMSGF_CREATE:
                /*
                 * reply & leave trans open
                 */
                kprintf("CONN RECEIVE - (just ignore it)\n");
                hammer2_msg_result(msg, 0);
                break;
-       case HAMMER2_LNK_SPAN | HAMMER2_MSGF_CREATE:
+       case DMSG_LNK_SPAN | DMSGF_CREATE:
                kprintf("SPAN RECEIVE - ADDED FROM CLUSTER\n");
                break;
-       case HAMMER2_LNK_SPAN | HAMMER2_MSGF_DELETE:
+       case DMSG_LNK_SPAN | DMSGF_DELETE:
                kprintf("SPAN RECEIVE - DELETED FROM CLUSTER\n");
                break;
        default:
@@ -1531,16 +1528,16 @@ hammer2_msg_conn_reply(hammer2_state_t *state, hammer2_msg_t *msg)
 
        kprintf("LNK_CONN REPLY RECEIVED CMD %08x\n", msg->any.head.cmd);
 
-       if (msg->any.head.cmd & HAMMER2_MSGF_CREATE) {
+       if (msg->any.head.cmd & DMSGF_CREATE) {
                kprintf("LNK_CONN transaction replied to, initiate SPAN\n");
-               rmsg = hammer2_msg_alloc(&pmp->router, HAMMER2_LNK_SPAN |
-                                                      HAMMER2_MSGF_CREATE,
+               rmsg = hammer2_msg_alloc(&pmp->router, DMSG_LNK_SPAN |
+                                                      DMSGF_CREATE,
                                        hammer2_msg_span_reply, pmp);
                rmsg->any.lnk_span.pfs_clid = pmp->iroot->ip_data.pfs_clid;
                rmsg->any.lnk_span.pfs_fsid = pmp->iroot->ip_data.pfs_fsid;
                rmsg->any.lnk_span.pfs_type = pmp->iroot->ip_data.pfs_type;
                rmsg->any.lnk_span.peer_type = pmp->hmp->voldata.peer_type;
-               rmsg->any.lnk_span.proto_version = HAMMER2_SPAN_PROTO_1;
+               rmsg->any.lnk_span.proto_version = DMSG_SPAN_PROTO_1;
                name_len = pmp->iroot->ip_data.name_len;
                if (name_len >= sizeof(rmsg->any.lnk_span.label))
                        name_len = sizeof(rmsg->any.lnk_span.label) - 1;
@@ -1561,8 +1558,8 @@ hammer2_msg_conn_reply(hammer2_state_t *state, hammer2_msg_t *msg)
                }
                hammer2_voldata_unlock(hmp);
        }
-       if ((state->txcmd & HAMMER2_MSGF_DELETE) == 0 &&
-           (msg->any.head.cmd & HAMMER2_MSGF_DELETE)) {
+       if ((state->txcmd & DMSGF_DELETE) == 0 &&
+           (msg->any.head.cmd & DMSGF_DELETE)) {
                kprintf("LNK_CONN transaction terminated by remote\n");
                pmp->conn_state = NULL;
                hammer2_msg_reply(msg, 0);
@@ -1576,11 +1573,12 @@ hammer2_msg_conn_reply(hammer2_state_t *state, hammer2_msg_t *msg)
 static int
 hammer2_msg_span_reply(hammer2_state_t *state, hammer2_msg_t *msg)
 {
-       hammer2_pfsmount_t *pmp = state->any.pmp;
+       /*hammer2_pfsmount_t *pmp = state->any.pmp;*/
 
-       kprintf("SPAN REPLY - Our sent span was terminated by the remote %08x state %p\n", msg->any.head.cmd, state);
-       if ((state->txcmd & HAMMER2_MSGF_DELETE) == 0 &&
-           (msg->any.head.cmd & HAMMER2_MSGF_DELETE)) {
+       kprintf("SPAN REPLY - Our sent span was terminated by the "
+               "remote %08x state %p\n", msg->any.head.cmd, state);
+       if ((state->txcmd & DMSGF_DELETE) == 0 &&
+           (msg->any.head.cmd & DMSGF_DELETE)) {
                hammer2_msg_reply(msg, 0);
        }
        return(0);
@@ -1600,7 +1598,7 @@ hammer2_volconf_update(hammer2_pfsmount_t *pmp, int index)
        kprintf("volconf update %p\n", pmp->conn_state);
        if (pmp->conn_state) {
                kprintf("TRANSMIT VOLCONF VIA OPEN CONN TRANSACTION\n");
-               msg = hammer2_msg_alloc(&pmp->router, HAMMER2_LNK_VOLCONF,
+               msg = hammer2_msg_alloc(&pmp->router, DMSG_LNK_VOLCONF,
                                        NULL, NULL);
                msg->state = pmp->conn_state;
                msg->any.lnk_volconf.copy = hmp->voldata.copyinfo[index];