summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.h
blob: 8d977e3057354c703437f31edbc9eb2f5b96ca0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	DSVCD_DATASTORE_H
#define	DSVCD_DATASTORE_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/types.h>
#include <synch.h>
#include <door.h>

#include "container.h"

/*
 * Datastore-related data structures, functions and constants.  See
 * comments in datastore.c for a description of how to use the exported
 * functions.
 */

#ifdef	__cplusplus
extern "C" {
#endif

#define	DSVCD_DS_HASH_SIZE	100

/*
 * A linked list of dsvcd_container_t structures.  Contains a lock,
 * `cl_lock', which is used for controlling manipulation of `cl_head'.
 */
typedef struct {
	mutex_t			cl_lock;	/* protects the list */
	dsvcd_container_t	*cl_head;	/* linked list of containers */
	uint8_t			cl_pad[8];	/* prevent false sharing */
} dsvcd_container_list_t;

/*
 * Describes the underlying datastore itself.  There is exactly one
 * dsvcd_datastore_t per datastore using doors (so currently, there are
 * two: one for `ds_files' and one for `ds_data').  Contains per-datastore
 * information, like the door descriptor being used by dsvclockd to listen
 * to requests for this datastore, the datastore name, and a list of all
 * open containers for this datastore.  Instances of this data structure
 * are allocated when dsvclockd is started.
 */
typedef struct dsvcd_datastore {
	char			*ds_name;	/* datastore name */
	int			ds_doorfd;	/* datastore door */

	/*
	 * This hash is used to speed up the open() routine so that a given
	 * container can be located quicker.  Hash based on the filename,
	 * and use it as an index into the array..
	 */
	dsvcd_container_list_t	ds_hash[DSVCD_DS_HASH_SIZE];
} dsvcd_datastore_t;

typedef void dsvcd_svc_t(void *, dsvcd_request_t *, size_t, door_desc_t *,
	uint_t);

extern dsvcd_datastore_t *ds_create(const char *, dsvcd_svc_t *);
extern void ds_destroy(dsvcd_datastore_t *);
extern unsigned int ds_reap_containers(dsvcd_datastore_t *, unsigned int);
extern void ds_release_container(dsvcd_datastore_t *, dsvcd_container_t *);
extern dsvcd_container_t *ds_get_container(dsvcd_datastore_t *, const char *,
    boolean_t);

#ifdef	__cplusplus
}
#endif

#endif	/* DSVCD_DATASTORE_H */