xref: /linux/fs/ocfs2/cluster/nodemanager.h (revision f6656d26d17b2598f43cd41be088853fa2a03397)
10c83ed8eSKurt Hackel /* -*- mode: c; c-basic-offset: 8; -*-
20c83ed8eSKurt Hackel  * vim: noexpandtab sw=8 ts=8 sts=0:
30c83ed8eSKurt Hackel  *
40c83ed8eSKurt Hackel  * nodemanager.h
50c83ed8eSKurt Hackel  *
60c83ed8eSKurt Hackel  * Function prototypes
70c83ed8eSKurt Hackel  *
80c83ed8eSKurt Hackel  * Copyright (C) 2004 Oracle.  All rights reserved.
90c83ed8eSKurt Hackel  *
100c83ed8eSKurt Hackel  * This program is free software; you can redistribute it and/or
110c83ed8eSKurt Hackel  * modify it under the terms of the GNU General Public
120c83ed8eSKurt Hackel  * License as published by the Free Software Foundation; either
130c83ed8eSKurt Hackel  * version 2 of the License, or (at your option) any later version.
140c83ed8eSKurt Hackel  *
150c83ed8eSKurt Hackel  * This program is distributed in the hope that it will be useful,
160c83ed8eSKurt Hackel  * but WITHOUT ANY WARRANTY; without even the implied warranty of
170c83ed8eSKurt Hackel  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
180c83ed8eSKurt Hackel  * General Public License for more details.
190c83ed8eSKurt Hackel  *
200c83ed8eSKurt Hackel  * You should have received a copy of the GNU General Public
210c83ed8eSKurt Hackel  * License along with this program; if not, write to the
220c83ed8eSKurt Hackel  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
230c83ed8eSKurt Hackel  * Boston, MA 021110-1307, USA.
240c83ed8eSKurt Hackel  *
250c83ed8eSKurt Hackel  */
260c83ed8eSKurt Hackel 
270c83ed8eSKurt Hackel #ifndef O2CLUSTER_NODEMANAGER_H
280c83ed8eSKurt Hackel #define O2CLUSTER_NODEMANAGER_H
290c83ed8eSKurt Hackel 
300c83ed8eSKurt Hackel #include "ocfs2_nodemanager.h"
310c83ed8eSKurt Hackel 
320c83ed8eSKurt Hackel /* This totally doesn't belong here. */
330c83ed8eSKurt Hackel #include <linux/configfs.h>
340c83ed8eSKurt Hackel #include <linux/rbtree.h>
350c83ed8eSKurt Hackel 
36*f6656d26SSunil Mushran enum o2nm_fence_method {
37*f6656d26SSunil Mushran 	O2NM_FENCE_RESET	= 0,
38*f6656d26SSunil Mushran 	O2NM_FENCE_PANIC,
39*f6656d26SSunil Mushran 	O2NM_FENCE_METHODS,	/* Number of fence methods */
40*f6656d26SSunil Mushran };
41*f6656d26SSunil Mushran 
420c83ed8eSKurt Hackel struct o2nm_node {
430c83ed8eSKurt Hackel 	spinlock_t		nd_lock;
440c83ed8eSKurt Hackel 	struct config_item	nd_item;
450c83ed8eSKurt Hackel 	char			nd_name[O2NM_MAX_NAME_LEN+1]; /* replace? */
460c83ed8eSKurt Hackel 	__u8			nd_num;
470c83ed8eSKurt Hackel 	/* only one address per node, as attributes, for now. */
480c83ed8eSKurt Hackel 	__be32			nd_ipv4_address;
490c83ed8eSKurt Hackel 	__be16			nd_ipv4_port;
500c83ed8eSKurt Hackel 	struct rb_node		nd_ip_node;
510c83ed8eSKurt Hackel 	/* there can be only one local node for now */
520c83ed8eSKurt Hackel 	int			nd_local;
530c83ed8eSKurt Hackel 
540c83ed8eSKurt Hackel 	unsigned long		nd_set_attributes;
550c83ed8eSKurt Hackel };
560c83ed8eSKurt Hackel 
57296b75edSAndrew Beekhof struct o2nm_cluster {
58296b75edSAndrew Beekhof 	struct config_group	cl_group;
59296b75edSAndrew Beekhof 	unsigned		cl_has_local:1;
60296b75edSAndrew Beekhof 	u8			cl_local_node;
61296b75edSAndrew Beekhof 	rwlock_t		cl_nodes_lock;
62296b75edSAndrew Beekhof 	struct o2nm_node  	*cl_nodes[O2NM_MAX_NODES];
63296b75edSAndrew Beekhof 	struct rb_root		cl_node_ip_tree;
64b5dd8030SJeff Mahoney 	unsigned int		cl_idle_timeout_ms;
65b5dd8030SJeff Mahoney 	unsigned int		cl_keepalive_delay_ms;
66b5dd8030SJeff Mahoney 	unsigned int		cl_reconnect_delay_ms;
67*f6656d26SSunil Mushran 	enum o2nm_fence_method	cl_fence_method;
68296b75edSAndrew Beekhof 
69296b75edSAndrew Beekhof 	/* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */
70296b75edSAndrew Beekhof 	unsigned long	cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
71296b75edSAndrew Beekhof };
72296b75edSAndrew Beekhof 
73296b75edSAndrew Beekhof extern struct o2nm_cluster *o2nm_single_cluster;
74296b75edSAndrew Beekhof 
750c83ed8eSKurt Hackel u8 o2nm_this_node(void);
760c83ed8eSKurt Hackel 
770c83ed8eSKurt Hackel int o2nm_configured_node_map(unsigned long *map, unsigned bytes);
780c83ed8eSKurt Hackel struct o2nm_node *o2nm_get_node_by_num(u8 node_num);
790c83ed8eSKurt Hackel struct o2nm_node *o2nm_get_node_by_ip(__be32 addr);
800c83ed8eSKurt Hackel void o2nm_node_get(struct o2nm_node *node);
810c83ed8eSKurt Hackel void o2nm_node_put(struct o2nm_node *node);
820c83ed8eSKurt Hackel 
8314829422SJoel Becker int o2nm_depend_item(struct config_item *item);
8414829422SJoel Becker void o2nm_undepend_item(struct config_item *item);
8516c6a4f2SJoel Becker int o2nm_depend_this_node(void);
8616c6a4f2SJoel Becker void o2nm_undepend_this_node(void);
8714829422SJoel Becker 
880c83ed8eSKurt Hackel #endif /* O2CLUSTER_NODEMANAGER_H */
89