nfs-ganesha 1.4

cache_inode_avl.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010, Linux Box Corporation
00003  * All Rights Reserved
00004  *
00005  * Contributor: Matt Benjamin
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 3 of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  * -------------
00022  */
00023 
00024 
00043 #ifndef _CACHE_INODE_AVL_H
00044 #define _CACHE_INODE_AVL_H
00045 
00046 #ifdef HAVE_CONFIG_H
00047 #include "config.h"
00048 #endif                          /* HAVE_CONFIG_H */
00049 
00050 #ifdef _SOLARIS
00051 #include "solaris_port.h"
00052 #endif                          /* _SOLARIS */
00053 
00054 #include "log.h"
00055 #include "cache_inode.h"
00056 #include "avltree.h"
00057 
00058 static inline int
00059 avl_dirent_hk_cmpf(const struct avltree_node *lhs,
00060                    const struct avltree_node *rhs)
00061 {
00062     cache_inode_dir_entry_t *lk, *rk;
00063 
00064     lk = avltree_container_of(lhs, cache_inode_dir_entry_t, node_hk);
00065     rk = avltree_container_of(rhs, cache_inode_dir_entry_t, node_hk);
00066 
00067     if (lk->hk.k < rk->hk.k)
00068         return (-1);
00069 
00070     if (lk->hk.k == rk->hk.k)
00071         return (0);
00072 
00073     return (1);
00074 }
00075 
00076 void avl_dirent_set_deleted(cache_entry_t *entry,
00077                             cache_inode_dir_entry_t *v);
00078 void avl_dirent_clear_deleted(cache_entry_t *entry,
00079                               cache_inode_dir_entry_t *v);
00080 void cache_inode_avl_init(cache_entry_t *entry);
00081 int cache_inode_avl_qp_insert(cache_entry_t *entry,
00082                               cache_inode_dir_entry_t *v);
00083 
00084 #define CACHE_INODE_FLAG_NEXT_ACTIVE     0x0001
00085 
00086 cache_inode_dir_entry_t *cache_inode_avl_lookup_k(
00087     cache_entry_t *entry,
00088     uint64_t k,
00089     uint32_t flags);
00090 cache_inode_dir_entry_t *cache_inode_avl_qp_lookup_s(
00091     cache_entry_t *entry,
00092     cache_inode_dir_entry_t *v,
00093     int maxj);
00094 
00095 static inline void
00096 cache_inode_avl_remove(cache_entry_t *entry,
00097                        cache_inode_dir_entry_t *v)
00098 {
00099     avltree_remove(&v->node_hk, &entry->object.dir.avl.t);
00100 }
00101 
00102 #endif /* _CACHE_INODE_AVL_H */