xref: /titanic_44/usr/src/uts/common/sys/fs/cachefs_filegrp.h (revision 2b4a78020b9c38d1b95e2f3fefa6d6e4be382d1f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_FS_CACHEFS_FILEGRP_H
28 #define	_SYS_FS_CACHEFS_FILEGRP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 struct cachefs_metadata;
37 
38 /*
39  * filegrp structure represents a group of front files.
40  */
41 struct filegrp {
42 	uint_t			 fg_flags;	/* CFS_FS_* flags */
43 	int			 fg_count;	/* cnodes in group */
44 	cfs_cid_t		 fg_id;		/* starting id in group */
45 	struct fscache		*fg_fscp;	/* back ptr to fscache */
46 
47 	struct cnode		*fg_cnodelist;	/* list of cnodes */
48 
49 	struct filegrp		*fg_next;	/* pointer to next */
50 	struct vnode		*fg_dirvp;	/* filegrp directory vp */
51 	struct vnode		*fg_attrvp;	/* attrcache vp */
52 	struct attrcache_header	*fg_header;	/* Attrcache header */
53 	struct attrcache_index	*fg_offsets;	/* ptr to indexes in header */
54 	uchar_t			*fg_alloclist;	/* allocation bitmap */
55 
56 	int			 fg_headersize;	/* attrcache header size */
57 	int			 fg_filesize;	/* size of attrcache file */
58 	kmutex_t		 fg_mutex;	/* filegrp contents/ac lock */
59 	kmutex_t		 fg_cnodelock;	/* cnode list lock */
60 };
61 typedef struct filegrp filegrp_t;
62 
63 extern struct kmem_cache *cachefs_filegrp_cache;
64 
65 /* fg_flags values */
66 #define	CFS_FG_NOCACHE		0x1	/* no cache mode */
67 #define	CFS_FG_ALLOC_ATTR	0x2	/* no attrcache file yet */
68 #define	CFS_FG_UPDATED		0x4	/* attrcache modified */
69 #define	CFS_FG_ALLOC_FILE	0x10	/* no front file dir yet */
70 #define	CFS_FG_RL		0x20	/* no longer used */
71 #define	CFS_FG_READ		0x40	/* attrcache can be read */
72 #define	CFS_FG_WRITE		0x80	/* attrcache can be written */
73 
74 int filegrp_cache_create(void *, void *, int);
75 void filegrp_cache_destroy(void *, void *);
76 filegrp_t *filegrp_create(struct fscache *fscp, cfs_cid_t *cidp);
77 void filegrp_destroy(filegrp_t *fgp);
78 int filegrp_allocattr(filegrp_t *fgp);
79 int filegrpdir_create(filegrp_t *fgp);
80 int filegrpdir_find(filegrp_t *fgp);
81 void filegrp_hold(filegrp_t *fgp);
82 void filegrp_rele(filegrp_t *fgp);
83 int filegrp_ffhold(filegrp_t *fgp);
84 void filegrp_ffrele(filegrp_t *fgp);
85 
86 int filegrp_sync(filegrp_t *fgp);
87 int filegrp_read_metadata(filegrp_t *fgp, cfs_cid_t *cidp,
88     struct cachefs_metadata *mdp);
89 int filegrp_create_metadata(filegrp_t *fgp, struct cachefs_metadata *md,
90     cfs_cid_t *cidp);
91 int filegrp_write_metadata(filegrp_t *fgp, cfs_cid_t *cidp,
92     struct cachefs_metadata *mdp);
93 int filegrp_destroy_metadata(filegrp_t *fgp, cfs_cid_t *cidp);
94 int filegrp_cid_to_slot(filegrp_t *fgp, cfs_cid_t *cidp);
95 
96 filegrp_t *filegrp_list_find(struct fscache *fscp, cfs_cid_t *cidp);
97 void filegrp_list_add(struct fscache *fscp, filegrp_t *fgp);
98 void filegrp_list_remove(struct fscache *fscp, filegrp_t *fgp);
99 void filegrp_list_gc(struct fscache *fscp);
100 void filegrp_list_enable_caching_ro(struct fscache *fscp);
101 void filegrp_list_enable_caching_rw(struct fscache *fscp);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* _SYS_FS_CACHEFS_FILEGRP_H */
108