The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/dirhash.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: dirhash.h,v 1.4 2008/10/30 23:02:12 rmind Exp $ */
    2 
    3 /*
    4  * Copyright (c) 2008 Reinoud Zandijk
    5  * All rights reserved.
    6  * 
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  */
   27 
   28 #ifndef _SYS_DIRHASH_H_
   29 #define _SYS_DIRHASH_H_
   30 
   31 #include <sys/queue.h>
   32 #include <sys/dirent.h>
   33 
   34 #ifndef DIRHASH_SIZE
   35 #define DIRHASH_SIZE    (1024*1024)
   36 #endif
   37 
   38 #define DIRHASH_HASHBITS        5
   39 #define DIRHASH_HASHSIZE        (1 << DIRHASH_HASHBITS)
   40 #define DIRHASH_HASHMASK        (DIRHASH_HASHSIZE - 1)
   41 
   42 /* dirent's d_namlen is to avoid useless costly fid->dirent translations */
   43 struct dirhash_entry {
   44         uint32_t                 hashvalue;
   45         uint64_t                 offset;
   46         uint32_t                 d_namlen;
   47         uint32_t                 entry_size;
   48         LIST_ENTRY(dirhash_entry) next;
   49 };
   50 
   51 struct dirhash {
   52         uint32_t                 flags;
   53         uint32_t                 size;                  /* in bytes */
   54         uint32_t                 refcnt;
   55         LIST_HEAD(, dirhash_entry) entries[DIRHASH_HASHSIZE];
   56         LIST_HEAD(, dirhash_entry) free_entries;
   57         TAILQ_ENTRY(dirhash) next;
   58 };
   59 
   60 #define DIRH_PURGED     0x0001  /* dirhash has been purged */
   61 #define DIRH_COMPLETE   0x0002  /* dirhash is complete */
   62 #define DIRH_BROKEN     0x0004  /* dirhash is broken on readin */
   63 #define DIRH_FLAGBITS   "\1\1DIRH_PURGED\2DIRH_COMPLETE\3DIRH_BROKEN"
   64 
   65 void    dirhash_init(void);
   66 /* void dirhash_finish(void); */
   67 
   68 void    dirhash_purge(struct dirhash **);
   69 void    dirhash_purge_entries(struct dirhash *);
   70 void    dirhash_get(struct dirhash **);
   71 void    dirhash_put(struct dirhash *);
   72 void    dirhash_enter(struct dirhash *, struct dirent *, uint64_t,
   73             uint32_t, int);
   74 void    dirhash_enter_freed(struct dirhash *, uint64_t, uint32_t);
   75 void    dirhash_remove(struct dirhash *, struct dirent *dirent,
   76             uint64_t, uint32_t);
   77 int     dirhash_lookup(struct dirhash *, const char *, int,
   78             struct dirhash_entry **);
   79 int     dirhash_lookup_freed(struct dirhash *, uint32_t,
   80             struct dirhash_entry **);
   81 
   82 #endif /* _SYS_DIRHASH_H_ */

Cache object: ba82df8d244a6d3daacf29559fbfe656


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.