Home | History | Annotate | Download | only in nfs
      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 (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 
     26 #ifndef _NNODE_IMPL_H
     27 #define	_NNODE_IMPL_H
     28 
     29 #include <nfs/nnode.h>
     30 
     31 #include <sys/vnode.h>
     32 #include <sys/vfs.h>
     33 #include <sys/avl.h>
     34 #include <sys/list.h>
     35 #include <nfs/nfs4.h>
     36 #include <nfs/export.h>
     37 
     38 #ifdef	__cplusplus
     39 extern "C" {
     40 #endif
     41 
     42 /*
     43  * The nnode.
     44  */
     45 
     46 struct nnode {
     47 	void *nn_key;
     48 	int (*nn_key_compare)(const void *, const void *);
     49 	void (*nn_key_free)(void *);
     50 
     51 	pid_t nn_instance_id;
     52 
     53 	kmutex_t nn_lock;
     54 	uint32_t nn_flags;
     55 	int nn_refcount;
     56 	kcondvar_t nn_refcount_cv;
     57 	hrtime_t nn_last_access;
     58 
     59 	avl_node_t nn_avl;
     60 
     61 	void *nn_data_ops_data;
     62 	nnode_data_ops_t *nn_data_ops;
     63 
     64 	void *nn_metadata_ops_data;
     65 	nnode_metadata_ops_t *nn_metadata_ops;
     66 
     67 	void *nn_state_ops_data;
     68 	nnode_state_ops_t *nn_state_ops;
     69 };
     70 
     71 typedef struct {
     72 	avl_tree_t nb_tree;
     73 	krwlock_t nb_lock;
     74 } nnode_bucket_t;
     75 
     76 typedef enum {
     77 	NNODE_SWEEP_SYNC = 0,
     78 	NNODE_SWEEP_ASYNC
     79 } nnode_sweep_how_t;
     80 
     81 struct nnode_bucket_sweep_task;
     82 
     83 typedef void (*nnode_bucket_sweep_node_t)(struct nnode_bucket_sweep_task *,
     84     nnode_t *);
     85 
     86 typedef struct nnode_bucket_sweep_task {
     87 	uint32_t nbst_flags;
     88 	nnode_bucket_sweep_node_t nbst_proc;
     89 
     90 	nnode_bucket_t *nbst_bucket;
     91 
     92 	pid_t nbst_inst_id;
     93 	hrtime_t nbst_maxage;
     94 	exportinfo_t *nbst_export;
     95 } nnode_bucket_sweep_task_t;
     96 #define	NNODE_BUCKET_SWEEP_TASK_SYNC	0x01
     97 #define	NNODE_BUCKET_SWEEP_TASK_FREEME	0x02
     98 
     99 #define	NNODE_HASH_SIZE		(251)
    100 #define	NNODE_MAX_WORKERS	(4)
    101 #define	NNODE_MIN_TASKALLOC	(8)
    102 #define	NNODE_MAX_TASKALLOC	(NNODE_HASH_SIZE + NNODE_MIN_TASKALLOC)
    103 #define	NNODE_GC_INTERVAL	(30LL * NANOSEC)
    104 #define	NNODE_GC_TOO_OLD	(45LL * NANOSEC)
    105 
    106 #ifdef	__cplusplus
    107 }
    108 #endif
    109 
    110 #endif /* _NNODE_IMPL_H */
    111