Sat Sep 24 20:11:43 2016 UTC ()
sync with mit/kerberos db


(christos)
diff -r1.26 -r1.27 src/include/db.h
diff -r1.14 -r1.15 src/include/mpool.h

cvs diff -r1.26 -r1.27 src/include/db.h (expand / switch to unified diff)

--- src/include/db.h 2013/12/01 00:23:11 1.26
+++ src/include/db.h 2016/09/24 20:11:43 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db.h,v 1.26 2013/12/01 00:23:11 christos Exp $ */ 1/* $NetBSD: db.h,v 1.27 2016/09/24 20:11:43 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1990, 1993, 1994 4 * Copyright (c) 1990, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -59,26 +59,43 @@ typedef struct { @@ -59,26 +59,43 @@ typedef struct {
59/* Routine flags. */ 59/* Routine flags. */
60#define R_CURSOR 1 /* del, put, seq */ 60#define R_CURSOR 1 /* del, put, seq */
61#define __R_UNUSED 2 /* UNUSED */ 61#define __R_UNUSED 2 /* UNUSED */
62#define R_FIRST 3 /* seq */ 62#define R_FIRST 3 /* seq */
63#define R_IAFTER 4 /* put (RECNO) */ 63#define R_IAFTER 4 /* put (RECNO) */
64#define R_IBEFORE 5 /* put (RECNO) */ 64#define R_IBEFORE 5 /* put (RECNO) */
65#define R_LAST 6 /* seq (BTREE, RECNO) */ 65#define R_LAST 6 /* seq (BTREE, RECNO) */
66#define R_NEXT 7 /* seq */ 66#define R_NEXT 7 /* seq */
67#define R_NOOVERWRITE 8 /* put */ 67#define R_NOOVERWRITE 8 /* put */
68#define R_PREV 9 /* seq (BTREE, RECNO) */ 68#define R_PREV 9 /* seq (BTREE, RECNO) */
69#define R_SETCURSOR 10 /* put (RECNO) */ 69#define R_SETCURSOR 10 /* put (RECNO) */
70#define R_RECNOSYNC 11 /* sync (RECNO) */ 70#define R_RECNOSYNC 11 /* sync (RECNO) */
71 71
 72/*
 73 * Recursive sequential scan.
 74 *
 75 * This avoids using sibling pointers, permitting (possibly partial)
 76 * recovery from some kinds of btree corruption. Start a sequential
 77 * scan as usual, but use R_RNEXT or R_RPREV to move forward or
 78 * backward.
 79 *
 80 * This probably doesn't work with btrees that allow duplicate keys.
 81 * Database modifications during the scan can also modify the parent
 82 * page stack needed for correct functioning. Intermixing
 83 * non-recursive traversal by using R_NEXT or R_PREV can also make the
 84 * page stack inconsistent with the cursor and cause problems.
 85 */
 86#define R_RNEXT 128 /* seq (BTREE, RECNO) */
 87#define R_RPREV 129 /* seq (BTREE, RECNO) */
 88
72typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; 89typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
73 90
74/* 91/*
75 * !!! 92 * !!!
76 * The following flags are included in the dbopen(3) call as part of the 93 * The following flags are included in the dbopen(3) call as part of the
77 * open(2) flags. In order to avoid conflicts with the open flags, start 94 * open(2) flags. In order to avoid conflicts with the open flags, start
78 * at the top of the 16 or 32-bit number space and work our way down. If 95 * at the top of the 16 or 32-bit number space and work our way down. If
79 * the open flags were significantly expanded in the future, it could be 96 * the open flags were significantly expanded in the future, it could be
80 * a problem. Wish I'd left another flags word in the dbopen call. 97 * a problem. Wish I'd left another flags word in the dbopen call.
81 * 98 *
82 * !!! 99 * !!!
83 * None of this stuff is implemented yet. The only reason that it's here 100 * None of this stuff is implemented yet. The only reason that it's here
84 * is so that the access methods can skip copying the key/data pair when 101 * is so that the access methods can skip copying the key/data pair when

cvs diff -r1.14 -r1.15 src/include/mpool.h (expand / switch to unified diff)

--- src/include/mpool.h 2013/11/22 16:25:01 1.14
+++ src/include/mpool.h 2016/09/24 20:11:43 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mpool.h,v 1.14 2013/11/22 16:25:01 christos Exp $ */ 1/* $NetBSD: mpool.h,v 1.15 2016/09/24 20:11:43 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -46,26 +46,27 @@ @@ -46,26 +46,27 @@
46 */ 46 */
47#define HASHSIZE 128 47#define HASHSIZE 128
48#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) 48#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE)
49 49
50/* The BKT structures are the elements of the queues. */ 50/* The BKT structures are the elements of the queues. */
51typedef struct _bkt { 51typedef struct _bkt {
52 TAILQ_ENTRY(_bkt) hq; /* hash queue */ 52 TAILQ_ENTRY(_bkt) hq; /* hash queue */
53 TAILQ_ENTRY(_bkt) q; /* lru queue */ 53 TAILQ_ENTRY(_bkt) q; /* lru queue */
54 void *page; /* page */ 54 void *page; /* page */
55 pgno_t pgno; /* page number */ 55 pgno_t pgno; /* page number */
56 56
57#define MPOOL_DIRTY 0x01 /* page needs to be written */ 57#define MPOOL_DIRTY 0x01 /* page needs to be written */
58#define MPOOL_PINNED 0x02 /* page is pinned into memory */ 58#define MPOOL_PINNED 0x02 /* page is pinned into memory */
 59#define MPOOL_INUSE 0x04 /* page address is valid */
59 uint8_t flags; /* flags */ 60 uint8_t flags; /* flags */
60} BKT; 61} BKT;
61 62
62typedef struct MPOOL { 63typedef struct MPOOL {
63 TAILQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */ 64 TAILQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */
64 /* hash queue array */ 65 /* hash queue array */
65 TAILQ_HEAD(_hqh, _bkt) hqh[HASHSIZE]; 66 TAILQ_HEAD(_hqh, _bkt) hqh[HASHSIZE];
66 pgno_t curcache; /* current number of cached pages */ 67 pgno_t curcache; /* current number of cached pages */
67 pgno_t maxcache; /* max number of cached pages */ 68 pgno_t maxcache; /* max number of cached pages */
68 pgno_t npages; /* number of pages in the file */ 69 pgno_t npages; /* number of pages in the file */
69 unsigned long pagesize; /* file page size */ 70 unsigned long pagesize; /* file page size */
70 int fd; /* file descriptor */ 71 int fd; /* file descriptor */
71 /* page in conversion routine */ 72 /* page in conversion routine */
@@ -76,28 +77,39 @@ typedef struct MPOOL { @@ -76,28 +77,39 @@ typedef struct MPOOL {
76#ifdef STATISTICS 77#ifdef STATISTICS
77 unsigned long cachehit; 78 unsigned long cachehit;
78 unsigned long cachemiss; 79 unsigned long cachemiss;
79 unsigned long pagealloc; 80 unsigned long pagealloc;
80 unsigned long pageflush; 81 unsigned long pageflush;
81 unsigned long pageget; 82 unsigned long pageget;
82 unsigned long pagenew; 83 unsigned long pagenew;
83 unsigned long pageput; 84 unsigned long pageput;
84 unsigned long pageread; 85 unsigned long pageread;
85 unsigned long pagewrite; 86 unsigned long pagewrite;
86#endif 87#endif
87} MPOOL; 88} MPOOL;
88 89
 90/* flags for get/put */
 91#define MPOOL_IGNOREPIN 0x01 /* Ignore if the page is pinned. */
 92/* flags for newf */
 93#define MPOOL_PAGE_REQUEST 0x01 /* Allocate a new page with a
 94 specific page number. */
 95#define MPOOL_PAGE_NEXT 0x02 /* Allocate a new page with the next
 96 page number. */
 97
89__BEGIN_DECLS 98__BEGIN_DECLS
90MPOOL *mpool_open(void *, int, pgno_t, pgno_t); 99MPOOL *mpool_open(void *, int, pgno_t, pgno_t);
91void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *), 100void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *),
92 void (*)(void *, pgno_t, void *), void *); 101 void (*)(void *, pgno_t, void *), void *);
93void *mpool_new(MPOOL *, pgno_t *); 102void *mpool_new(MPOOL *, pgno_t *);
94void *mpool_get(MPOOL *, pgno_t, unsigned int); 103void *mpool_newf(MPOOL *, pgno_t *, unsigned int);
 104int mpool_delete(MPOOL *, void *);
 105void *mpool_get(MPOOL *, pgno_t);
 106void *mpool_getf(MPOOL *, pgno_t, unsigned int);
95int mpool_put(MPOOL *, void *, unsigned int); 107int mpool_put(MPOOL *, void *, unsigned int);
96int mpool_sync(MPOOL *); 108int mpool_sync(MPOOL *);
97int mpool_close(MPOOL *); 109int mpool_close(MPOOL *);
98#ifdef STATISTICS 110#ifdef STATISTICS
99void mpool_stat(MPOOL *); 111void mpool_stat(MPOOL *);
100#endif 112#endif
101__END_DECLS 113__END_DECLS
102 114
103#endif /* _MPOOL_H_ */ 115#endif /* _MPOOL_H_ */