From 42e2a62ef34aa8bcaa4c94eeba0cfced40e989b6 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 5 Jul 2012 22:32:42 -0700 Subject: [PATCH 1/1] hammer2 - Fill in lnk_span message * 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 | 2 +- sys/vfs/hammer2/hammer2_msg.c | 4 +++- sys/vfs/hammer2/hammer2_network.h | 17 +++++++++++++++-- sys/vfs/hammer2/hammer2_vfsops.c | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/sys/vfs/hammer2/hammer2.h b/sys/vfs/hammer2/hammer2.h index 0b3b4daf8c..330558e1bb 100644 --- a/sys/vfs/hammer2/hammer2.h +++ b/sys/vfs/hammer2/hammer2.h @@ -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; diff --git a/sys/vfs/hammer2/hammer2_msg.c b/sys/vfs/hammer2/hammer2_msg.c index 33edf39e12..75750ceab5 100644 --- a/sys/vfs/hammer2/hammer2_msg.c +++ b/sys/vfs/hammer2/hammer2_msg.c @@ -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. diff --git a/sys/vfs/hammer2/hammer2_network.h b/sys/vfs/hammer2/hammer2_network.h index 6558746478..8f1b2547f3 100644 --- a/sys/vfs/hammer2/hammer2_network.h +++ b/sys/vfs/hammer2/hammer2_network.h @@ -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 diff --git a/sys/vfs/hammer2/hammer2_vfsops.c b/sys/vfs/hammer2/hammer2_vfsops.c index ce605c00a6..20952025d3 100644 --- a/sys/vfs/hammer2/hammer2_vfsops.c +++ b/sys/vfs/hammer2/hammer2_vfsops.c @@ -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); /* -- 2.41.0