kernel/netgraph7: Fix panic
[dragonfly.git] / sbin / hammer2 / cmd_leaf.c
CommitLineData
9ab15106
MD
1/*
2 * Copyright (c) 2011-2012 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include "hammer2.h"
37
38/*
39 * Start-up the leaf daemon for a PFS on this machine.
40 *
41 * One leaf daemon is run for each mounted PFS. The daemon may multi-thread
42 * to improve performance if desired. The daemon performs the following
43 * functions:
44 *
45 * (1) Makes and maintains connections to all cluster nodes found for
46 * the PFS, retrieved from the REMOTE configuration stored in
47 * the HAMMER2 mount. A localhost connection is always implied
48 * (using the backbone), but also having more direct connections
49 * can result in higher performance.
50 *
51 * This also includes any required encryption or authentication.
52 *
53 * (2) Runs the spanning tree protocol as a leaf, meaning that
54 * the leaf daemon does not serve as a relay and the individual
55 * connections made in (1) do not cross-connect.
56 *
57 * (3) Obtains the PFS's registration and makes it available to the
58 * cluster via the spanning tree protocol.
59 *
60 * (4) Creates a communications pipe to the HAMMER2 VFS in the kernel
61 * (installed via ioctl()) which the HAMMER2 VFS uses to accept and
62 * communicate high-level requests.
63 *
64 * (5) Performs all complex high-level messaging protocol operations,
65 * such as quorum operations, maintains persistent cache state,
66 * and so on and so forth.
67 *
68 * As you may have noted, the leaf daemon serves as an intermediary between
69 * the kernel and the rest of the cluster. The kernel will issue high level
70 * protocol commands to the leaf which performs the protocol and sends a
71 * response. The kernel does NOT have to deal with the quorum or other
72 * complex maintainance.
73 *
74 * Basically the kernel is simply another client from the point of view
75 * of the high-level protocols, requesting cache state locks and such from
76 * the leaf (in a degenerate situation one master lock is all that is needed).
77 * If the kernel PFS has local media storage that storage can be used for
78 * numerous purposes, such as caching, and in the degenerate non-clustered
79 * case simply represents the one-and-only master copy of the filesystem.
80 */
81int
82cmd_leaf(const char *sel_info)
83{
84 int ecode = 0;
85 int fd;
86
87 /*
88 * Obtain an ioctl descriptor and retrieve the registration info
89 * for the PFS.
90 */
91 if ((fd = hammer2_ioctl_handle(sel_info)) < 0)
92 return(1);
93
94 /*
95 * Start a daemon to interconnect the HAMMER2 PFS in-kernel to the
96 * master-node daemon. This daemon's thread will spend most of its
97 * time in the kernel.
98 */
99/* hammer2_demon(helper_pfs_interlink, (void *)(intptr_t)fd);*/
100 if (NormalExit)
101 close(fd);
102
103 return ecode;
104}
105
106#if 0
107/*
108 * LEAF interconnect between PFS and the messaging core. We create a
109 * socket connection to the messaging core, register the PFS with the
110 * core, and then pass the messaging descriptor to the kernel.
111 *
112 * The kernel takes over operation of the interconnect until the filesystem
113 * is unmounted or the descriptor is lost or explicitly terminated via
114 * a hammer2 command.
115 *
116 * This is essentially a localhost connection, so we don't have to worry
117 * about encryption. Any encryption will be handled by the messaging
118 * core.
119 */
120static
121void *
122leaf_connect(void *data)
123{
124 int fd;
125
126 fd = (int)(intptr_t)data;
127
128 return (NULL);
129}
130#endif