2 * Copyright (c) 2012 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 RB_GENERATE(hammer2_state_tree, hammer2_state, rbnode, hammer2_state_cmp);
40 * Process state tracking for a message after reception, prior to
43 * Called with msglk held and the msg dequeued.
45 * All messages are called with dummy state and return actual state.
46 * (One-off messages often just return the same dummy state).
48 * May request that caller discard the message by setting *discardp to 1.
49 * The returned state is not used in this case and is allowed to be NULL.
53 * These routines handle persistent and command/reply message state via the
54 * CREATE and DELETE flags. The first message in a command or reply sequence
55 * sets CREATE, the last message in a command or reply sequence sets DELETE.
57 * There can be any number of intermediate messages belonging to the same
58 * sequence sent inbetween the CREATE message and the DELETE message,
59 * which set neither flag. This represents a streaming command or reply.
61 * Any command message received with CREATE set expects a reply sequence to
62 * be returned. Reply sequences work the same as command sequences except the
63 * REPLY bit is also sent. Both the command side and reply side can
64 * degenerate into a single message with both CREATE and DELETE set. Note
65 * that one side can be streaming and the other side not, or neither, or both.
67 * The msgid is unique for the initiator. That is, two sides sending a new
68 * message can use the same msgid without colliding.
72 * ABORT sequences work by setting the ABORT flag along with normal message
73 * state. However, ABORTs can also be sent on half-closed messages, that is
74 * even if the command or reply side has already sent a DELETE, as long as
75 * the message has not been fully closed it can still send an ABORT+DELETE
76 * to terminate the half-closed message state.
78 * Since ABORT+DELETEs can race we silently discard ABORT's for message
79 * state which has already been fully closed. REPLY+ABORT+DELETEs can
80 * also race, and in this situation the other side might have already
81 * initiated a new unrelated command with the same message id. Since
82 * the abort has not set the CREATE flag the situation can be detected
83 * and the message will also be discarded.
85 * Non-blocking requests can be initiated with ABORT+CREATE[+DELETE].
86 * The ABORT request is essentially integrated into the command instead
87 * of being sent later on. In this situation the command implementation
88 * detects that CREATE and ABORT are both set (vs ABORT alone) and can
89 * special-case non-blocking operation for the command.
91 * NOTE! Messages with ABORT set without CREATE or DELETE are considered
92 * to be mid-stream aborts for command/reply sequences. ABORTs on
93 * one-way messages are not supported.
95 * NOTE! If a command sequence does not support aborts the ABORT flag is
100 * One-off messages (no reply expected) are sent with neither CREATE or DELETE
101 * set. One-off messages cannot be aborted and typically aren't processed
102 * by these routines. The REPLY bit can be used to distinguish whether a
103 * one-off message is a command or reply. For example, one-off replies
104 * will typically just contain status updates.
107 hammer2_state_msgrx(hammer2_msg_t *msg)
109 hammer2_pfsmount_t *pmp;
110 hammer2_state_t *state;
113 pmp = msg->router->pmp;
116 * XXX resolve msg->any.head.source and msg->any.head.target
117 * into LNK_SPAN references.
119 * XXX replace msg->router
123 * Make sure a state structure is ready to go in case we need a new
124 * one. This is the only routine which uses freerd_state so no
125 * races are possible.
127 if ((state = pmp->freerd_state) == NULL) {
128 state = kmalloc(sizeof(*state), pmp->mmsg, M_WAITOK | M_ZERO);
130 state->flags = HAMMER2_STATE_DYNAMIC;
131 pmp->freerd_state = state;
135 * Lock RB tree and locate existing persistent state, if any.
137 * If received msg is a command state is on staterd_tree.
138 * If received msg is a reply state is on statewr_tree.
140 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
142 state->msgid = msg->any.head.msgid;
143 state->router = &pmp->router;
144 kprintf("received msg %08x msgid %jx source=%jx target=%jx\n",
146 (intmax_t)msg->any.head.msgid,
147 (intmax_t)msg->any.head.source,
148 (intmax_t)msg->any.head.target);
149 if (msg->any.head.cmd & HAMMER2_MSGF_REPLY)
150 state = RB_FIND(hammer2_state_tree, &pmp->statewr_tree, state);
152 state = RB_FIND(hammer2_state_tree, &pmp->staterd_tree, state);
156 * Short-cut one-off or mid-stream messages (state may be NULL).
158 if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
159 HAMMER2_MSGF_ABORT)) == 0) {
160 lockmgr(&pmp->msglk, LK_RELEASE);
165 * Switch on CREATE, DELETE, REPLY, and also handle ABORT from
166 * inside the case statements.
168 switch(msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
169 HAMMER2_MSGF_REPLY)) {
170 case HAMMER2_MSGF_CREATE:
171 case HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
173 * New persistant command received.
176 kprintf("hammer2_state_msgrx: duplicate transaction\n");
180 state = pmp->freerd_state;
181 pmp->freerd_state = NULL;
183 state->router = msg->router;
185 state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
186 state->txcmd = HAMMER2_MSGF_REPLY;
187 RB_INSERT(hammer2_state_tree, &pmp->staterd_tree, state);
188 state->flags |= HAMMER2_STATE_INSERTED;
191 case HAMMER2_MSGF_DELETE:
193 * Persistent state is expected but might not exist if an
194 * ABORT+DELETE races the close.
197 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
200 kprintf("hammer2_state_msgrx: no state "
208 * Handle another ABORT+DELETE case if the msgid has already
211 if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
212 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
215 kprintf("hammer2_state_msgrx: state reused "
225 * Check for mid-stream ABORT command received, otherwise
228 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
230 (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
237 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE:
238 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
240 * When receiving a reply with CREATE set the original
241 * persistent state message should already exist.
244 kprintf("hammer2_state_msgrx: no state match for "
245 "REPLY cmd=%08x msgid=%016jx\n",
247 (intmax_t)msg->any.head.msgid);
251 state->rxcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
254 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_DELETE:
256 * Received REPLY+ABORT+DELETE in case where msgid has
257 * already been fully closed, ignore the message.
260 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
263 kprintf("hammer2_state_msgrx: no state match "
264 "for REPLY|DELETE\n");
271 * Received REPLY+ABORT+DELETE in case where msgid has
272 * already been reused for an unrelated message,
273 * ignore the message.
275 if ((state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
276 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
279 kprintf("hammer2_state_msgrx: state reused "
280 "for REPLY|DELETE\n");
287 case HAMMER2_MSGF_REPLY:
289 * Check for mid-stream ABORT reply received to sent command.
291 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
293 (state->rxcmd & HAMMER2_MSGF_CREATE) == 0) {
301 lockmgr(&pmp->msglk, LK_RELEASE);
306 hammer2_state_cleanuprx(hammer2_msg_t *msg)
308 hammer2_pfsmount_t *pmp = msg->router->pmp;
309 hammer2_state_t *state;
311 if ((state = msg->state) == NULL) {
312 hammer2_msg_free(msg);
313 } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
314 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
315 state->rxcmd |= HAMMER2_MSGF_DELETE;
316 if (state->txcmd & HAMMER2_MSGF_DELETE) {
317 if (state->msg == msg)
319 KKASSERT(state->flags & HAMMER2_STATE_INSERTED);
320 if (state->rxcmd & HAMMER2_MSGF_REPLY) {
321 KKASSERT(msg->any.head.cmd &
323 RB_REMOVE(hammer2_state_tree,
324 &pmp->statewr_tree, state);
326 KKASSERT((msg->any.head.cmd &
327 HAMMER2_MSGF_REPLY) == 0);
328 RB_REMOVE(hammer2_state_tree,
329 &pmp->staterd_tree, state);
331 state->flags &= ~HAMMER2_STATE_INSERTED;
332 lockmgr(&pmp->msglk, LK_RELEASE);
333 hammer2_state_free(state);
335 lockmgr(&pmp->msglk, LK_RELEASE);
337 hammer2_msg_free(msg);
338 } else if (state->msg != msg) {
339 hammer2_msg_free(msg);
344 * Process state tracking for a message prior to transmission.
346 * Called with msglk held and the msg dequeued.
348 * One-off messages are usually with dummy state and msg->state may be NULL
351 * New transactions (when CREATE is set) will insert the state.
353 * May request that caller discard the message by setting *discardp to 1.
354 * A NULL state may be returned in this case.
357 hammer2_state_msgtx(hammer2_msg_t *msg)
359 hammer2_pfsmount_t *pmp = msg->router->pmp;
360 hammer2_state_t *state;
364 * Make sure a state structure is ready to go in case we need a new
365 * one. This is the only routine which uses freewr_state so no
366 * races are possible.
368 if ((state = pmp->freewr_state) == NULL) {
369 state = kmalloc(sizeof(*state), pmp->mmsg, M_WAITOK | M_ZERO);
371 state->flags = HAMMER2_STATE_DYNAMIC;
372 pmp->freewr_state = state;
376 * Lock RB tree. If persistent state is present it will have already
377 * been assigned to msg.
379 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
383 * Short-cut one-off or mid-stream messages (state may be NULL).
385 if ((msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
386 HAMMER2_MSGF_ABORT)) == 0) {
387 lockmgr(&pmp->msglk, LK_RELEASE);
393 * Switch on CREATE, DELETE, REPLY, and also handle ABORT from
394 * inside the case statements.
396 switch(msg->any.head.cmd & (HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE |
397 HAMMER2_MSGF_REPLY)) {
398 case HAMMER2_MSGF_CREATE:
399 case HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
401 * Insert the new persistent message state and mark
402 * half-closed if DELETE is set. Since this is a new
403 * message it isn't possible to transition into the fully
406 * XXX state must be assigned and inserted by
407 * hammer2_msg_write(). txcmd is assigned by us
410 KKASSERT(state != NULL);
411 state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
412 state->rxcmd = HAMMER2_MSGF_REPLY;
415 case HAMMER2_MSGF_DELETE:
417 * Sent ABORT+DELETE in case where msgid has already
418 * been fully closed, ignore the message.
421 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
424 kprintf("hammer2_state_msgtx: no state match "
425 "for DELETE cmd=%08x msgid=%016jx\n",
427 (intmax_t)msg->any.head.msgid);
434 * Sent ABORT+DELETE in case where msgid has
435 * already been reused for an unrelated message,
436 * ignore the message.
438 if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
439 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
442 kprintf("hammer2_state_msgtx: state reused "
452 * Check for mid-stream ABORT command sent
454 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
456 (state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
463 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE:
464 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_CREATE | HAMMER2_MSGF_DELETE:
466 * When transmitting a reply with CREATE set the original
467 * persistent state message should already exist.
470 kprintf("hammer2_state_msgtx: no state match "
471 "for REPLY | CREATE\n");
475 state->txcmd = msg->any.head.cmd & ~HAMMER2_MSGF_DELETE;
478 case HAMMER2_MSGF_REPLY | HAMMER2_MSGF_DELETE:
480 * When transmitting a reply with DELETE set the original
481 * persistent state message should already exist.
483 * This is very similar to the REPLY|CREATE|* case except
484 * txcmd is already stored, so we just add the DELETE flag.
486 * Sent REPLY+ABORT+DELETE in case where msgid has
487 * already been fully closed, ignore the message.
490 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
493 kprintf("hammer2_state_msgtx: no state match "
494 "for REPLY | DELETE\n");
501 * Sent REPLY+ABORT+DELETE in case where msgid has already
502 * been reused for an unrelated message, ignore the message.
504 if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
505 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
508 kprintf("hammer2_state_msgtx: state reused "
509 "for REPLY | DELETE\n");
516 case HAMMER2_MSGF_REPLY:
518 * Check for mid-stream ABORT reply sent.
520 * One-off REPLY messages are allowed for e.g. status updates.
522 if (msg->any.head.cmd & HAMMER2_MSGF_ABORT) {
524 (state->txcmd & HAMMER2_MSGF_CREATE) == 0) {
532 lockmgr(&pmp->msglk, LK_RELEASE);
537 hammer2_state_cleanuptx(hammer2_msg_t *msg)
539 hammer2_pfsmount_t *pmp = msg->router->pmp;
540 hammer2_state_t *state;
542 if ((state = msg->state) == NULL) {
543 hammer2_msg_free(msg);
544 } else if (msg->any.head.cmd & HAMMER2_MSGF_DELETE) {
545 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
546 state->txcmd |= HAMMER2_MSGF_DELETE;
547 if (state->rxcmd & HAMMER2_MSGF_DELETE) {
548 if (state->msg == msg)
550 KKASSERT(state->flags & HAMMER2_STATE_INSERTED);
551 if (state->txcmd & HAMMER2_MSGF_REPLY) {
552 KKASSERT(msg->any.head.cmd &
554 RB_REMOVE(hammer2_state_tree,
555 &pmp->staterd_tree, state);
557 KKASSERT((msg->any.head.cmd &
558 HAMMER2_MSGF_REPLY) == 0);
559 RB_REMOVE(hammer2_state_tree,
560 &pmp->statewr_tree, state);
562 state->flags &= ~HAMMER2_STATE_INSERTED;
563 lockmgr(&pmp->msglk, LK_RELEASE);
564 hammer2_state_free(state);
566 lockmgr(&pmp->msglk, LK_RELEASE);
568 hammer2_msg_free(msg);
569 } else if (state->msg != msg) {
570 hammer2_msg_free(msg);
575 hammer2_state_free(hammer2_state_t *state)
577 hammer2_pfsmount_t *pmp = state->pmp;
582 kfree(state, pmp->mmsg);
584 hammer2_msg_free(msg);
588 hammer2_msg_alloc(hammer2_router_t *router, uint32_t cmd)
593 hbytes = (cmd & HAMMER2_MSGF_SIZE) * HAMMER2_MSG_ALIGN;
594 msg = kmalloc(offsetof(struct hammer2_msg, any) + hbytes,
595 router->pmp->mmsg, M_WAITOK | M_ZERO);
596 msg->hdr_size = hbytes;
597 msg->router = router;
598 KKASSERT(router != NULL);
599 msg->any.head.magic = HAMMER2_MSGHDR_MAGIC;
600 msg->any.head.source = 0;
601 msg->any.head.target = router->target;
602 msg->any.head.cmd = cmd;
608 hammer2_msg_free(hammer2_msg_t *msg)
610 hammer2_pfsmount_t *pmp = msg->router->pmp;
612 if (msg->aux_data && msg->aux_size) {
613 kfree(msg->aux_data, pmp->mmsg);
614 msg->aux_data = NULL;
618 kfree(msg, pmp->mmsg);
622 * Indexed messages are stored in a red-black tree indexed by their
623 * msgid. Only persistent messages are indexed.
626 hammer2_state_cmp(hammer2_state_t *state1, hammer2_state_t *state2)
628 if (state1->router < state2->router)
630 if (state1->router > state2->router)
632 if (state1->msgid < state2->msgid)
634 if (state1->msgid > state2->msgid)
640 * Write a message. All requisit command flags have been set.
642 * If msg->state is non-NULL the message is written to the existing
643 * transaction. msgid will be set accordingly.
645 * If msg->state is NULL and CREATE is set new state is allocated and
646 * (func, data) is installed. A msgid is assigned.
648 * If msg->state is NULL and CREATE is not set the message is assumed
649 * to be a one-way message. The originator must assign the msgid
650 * (or leave it 0, which is typical.
652 * This function merely queues the message to the management thread, it
653 * does not write to the message socket/pipe.
656 hammer2_msg_write(hammer2_msg_t *msg,
657 int (*func)(hammer2_state_t *, hammer2_msg_t *), void *data)
659 hammer2_pfsmount_t *pmp = msg->router->pmp;
660 hammer2_state_t *state;
664 * Continuance or termination of existing transaction.
665 * The transaction could have been initiated by either end.
667 * (Function callback and aux data for the receive side can
668 * be replaced or left alone).
671 msg->any.head.msgid = state->msgid;
672 msg->any.head.source = 0;
673 msg->any.head.target = state->router->target;
674 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
677 state->any.any = data;
679 } else if (msg->any.head.cmd & HAMMER2_MSGF_CREATE) {
681 * New transaction, requires tracking state and a unique
682 * msgid to be allocated.
684 KKASSERT(msg->state == NULL);
685 state = kmalloc(sizeof(*state), pmp->mmsg, M_WAITOK | M_ZERO);
687 state->flags = HAMMER2_STATE_DYNAMIC;
689 state->any.any = data;
691 state->msgid = (uint64_t)(uintptr_t)state;
692 state->router = msg->router;
694 msg->any.head.source = 0;
695 msg->any.head.target = state->router->target;
696 msg->any.head.msgid = state->msgid;
698 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
699 if (RB_INSERT(hammer2_state_tree, &pmp->statewr_tree, state))
700 panic("duplicate msgid allocated");
701 msg->any.head.msgid = state->msgid;
704 * One-off message (always uses msgid 0 to distinguish
705 * between a possibly lost in-transaction message due to
706 * competing aborts and a real one-off message?)
708 msg->any.head.msgid = 0;
709 msg->any.head.source = 0;
710 msg->any.head.target = msg->router->target;
711 lockmgr(&pmp->msglk, LK_EXCLUSIVE);
715 * Finish up the msg fields
717 msg->any.head.salt = /* (random << 8) | */ (pmp->msg_seq & 255);
720 msg->any.head.hdr_crc = 0;
721 msg->any.head.hdr_crc = hammer2_icrc32(msg->any.buf, msg->hdr_size);
723 TAILQ_INSERT_TAIL(&pmp->msgq, msg, qentry);
724 lockmgr(&pmp->msglk, LK_RELEASE);
728 * Reply to a message and terminate our side of the transaction.
730 * If msg->state is non-NULL we are replying to a one-way message.
733 hammer2_msg_reply(hammer2_msg_t *msg, uint32_t error)
735 hammer2_state_t *state = msg->state;
740 * Reply with a simple error code and terminate the transaction.
742 cmd = HAMMER2_LNK_ERROR;
745 * Check if our direction has even been initiated yet, set CREATE.
747 * Check what direction this is (command or reply direction). Note
748 * that txcmd might not have been initiated yet.
750 * If our direction has already been closed we just return without
754 if (state->txcmd & HAMMER2_MSGF_DELETE) {
755 hammer2_msg_free(msg);
758 if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
759 cmd |= HAMMER2_MSGF_CREATE;
760 if (state->txcmd & HAMMER2_MSGF_REPLY)
761 cmd |= HAMMER2_MSGF_REPLY;
762 cmd |= HAMMER2_MSGF_DELETE;
764 if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
765 cmd |= HAMMER2_MSGF_REPLY;
768 nmsg = hammer2_msg_alloc(msg->router, cmd);
769 nmsg->any.head.error = error;
771 hammer2_msg_write(nmsg, NULL, NULL);
775 * Reply to a message and continue our side of the transaction.
777 * If msg->state is non-NULL we are replying to a one-way message and this
778 * function degenerates into the same as hammer2_msg_reply().
781 hammer2_msg_result(hammer2_msg_t *msg, uint32_t error)
783 hammer2_state_t *state = msg->state;
788 * Return a simple result code, do NOT terminate the transaction.
790 cmd = HAMMER2_LNK_ERROR;
793 * Check if our direction has even been initiated yet, set CREATE.
795 * Check what direction this is (command or reply direction). Note
796 * that txcmd might not have been initiated yet.
798 * If our direction has already been closed we just return without
802 if (state->txcmd & HAMMER2_MSGF_DELETE) {
803 hammer2_msg_free(msg);
806 if ((state->txcmd & HAMMER2_MSGF_CREATE) == 0)
807 cmd |= HAMMER2_MSGF_CREATE;
808 if (state->txcmd & HAMMER2_MSGF_REPLY)
809 cmd |= HAMMER2_MSGF_REPLY;
810 /* continuing transaction, do not set MSGF_DELETE */
812 if ((msg->any.head.cmd & HAMMER2_MSGF_REPLY) == 0)
813 cmd |= HAMMER2_MSGF_REPLY;
816 nmsg = hammer2_msg_alloc(msg->router, cmd);
817 nmsg->any.head.error = error;
819 hammer2_msg_write(nmsg, NULL, NULL);