hammer2 - Fill in lnk_span message
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 6 Jul 2012 05:32:42 +0000 (22:32 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 6 Jul 2012 05:35:41 +0000 (22:35 -0700)
* Fill in the header fields for the lnk_span message.

* Rename hammer2_any to hammer2_msg_any

* Incorporate lnk_span into hammer2_msg_any

sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_msg.c
sys/vfs/hammer2/hammer2_network.h
sys/vfs/hammer2/hammer2_vfsops.c

index 0b3b4da..330558e 100644 (file)
@@ -368,7 +368,7 @@ struct hammer2_msg {
        size_t          hdr_size;
        size_t          aux_size;
        char            *aux_data;
-       hammer2_any_t   any;
+       hammer2_msg_any_t any;
 };
 
 typedef struct hammer2_state hammer2_state_t;
index 33edf39..75750ce 100644 (file)
@@ -626,7 +626,9 @@ hammer2_state_cmp(hammer2_state_t *state1, hammer2_state_t *state2)
 }
 
 /*
- * Write a message.  {source, target, cmd} have been set.
+ * Write a message.  {source, target, cmd} have been set.  This function
+ * merely queues the message to the management thread, it does not write
+ * to the message socket/pipe.
  *
  * If CREATE is set we allocate the state and msgid and do the insertion.
  * If CREATE is not set the state and msgid must already be assigned.
index 6558746..8f1b254 100644 (file)
@@ -225,10 +225,18 @@ typedef struct hammer2_msg_hdr hammer2_msg_hdr_t;
                                         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
@@ -375,6 +383,10 @@ struct hammer2_lnk_span {
        char            label[256];     /* PFS label (can be wildcard) */
 };
 
+typedef struct hammer2_lnk_span hammer2_lnk_span_t;
+
+#define HAMMER2_SPAN_PROTO_1   1
+
 /*
  * Debug layer ops operate on any link
  *
@@ -465,11 +477,12 @@ typedef struct hammer2_dbg_shell hammer2_dbg_shell_t;
  */
 #define HAMMER2_MSG_ERR_UNKNOWN                0x20
 
-union hammer2_any {
+union hammer2_msg_any {
        char                    buf[HAMMER2_MSGHDR_MAX];
        hammer2_msg_hdr_t       head;
+       hammer2_lnk_span_t      lnk_span;
 };
 
-typedef union hammer2_any hammer2_any_t;
+typedef union hammer2_msg_any hammer2_msg_any_t;
 
 #endif
index ce605c0..2095202 100644 (file)
@@ -1131,14 +1131,28 @@ hammer2_cluster_thread_wr(void *arg)
        hammer2_msg_t *msg = NULL;
        hammer2_state_t *state;
        ssize_t res;
+       size_t name_len;
        int error = 0;
 
        /*
         * Initiate a SPAN transaction registering our PFS with the other
         * end using {source}=1.  The transaction is left open.
+        *
+        * The hammer2_msg_write() function will queue the message, and we
+        * pick it off and write it in our transmit loop.
         */
        msg = hammer2_msg_alloc(pmp, 1, 0,
                                HAMMER2_LNK_SPAN | HAMMER2_MSGF_CREATE);
+       msg->any.lnk_span.pfs_id   = pmp->iroot->ip_data.pfs_id;
+       msg->any.lnk_span.pfs_fsid = pmp->iroot->ip_data.pfs_fsid;
+       msg->any.lnk_span.pfs_type = pmp->iroot->ip_data.pfs_type;
+       msg->any.lnk_span.proto_version = HAMMER2_SPAN_PROTO_1;
+       name_len = pmp->iroot->ip_data.name_len;
+       if (name_len >= sizeof(msg->any.lnk_span.label))
+               name_len = sizeof(msg->any.lnk_span.label) - 1;
+       bcopy(pmp->iroot->ip_data.filename, msg->any.lnk_span.label, name_len);
+       msg->any.lnk_span.label[name_len] = 0;
+
        hammer2_msg_write(pmp, msg, hammer2_msg_span_reply);
 
        /*