1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Margo Seltzer. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)page.h 5.1 (Berkeley) 02/12/91 11 */ 12 13 /* 14 Definitions for hashing page file format. 15 */ 16 extern HTAB *hashp; 17 /* 18 * routines dealing with a data page 19 * 20 * page format: 21 * +------------------------------+ 22 * p | n | keyoff | datoff | keyoff | 23 * +------------+--------+--------+ 24 * | datoff | free | ptr | --> | 25 * +--------+---------------------+ 26 * | F R E E A R E A | 27 * +--------------+---------------+ 28 * | <---- - - - | data | 29 * +--------+-----+----+----------+ 30 * | key | data | key | 31 * +--------+----------+----------+ 32 * 33 * Pointer to the free space is always: p[p[0] + 2] 34 * Amount of free space on the page is: p[p[0] + 1] 35 */ 36 37 /* 38 How many bytes required for this pair? 39 2 shorts in the table at the top of the page + 40 room for the key and room for the data 41 42 We prohibit entering a pair on a page unless there is also 43 room to append an overflow page. The reason for this it that 44 you can get in a situation where a single key/data pair fits 45 on a page, but you can't append an overflow page and later 46 you'd have to split the key/data and handle like a big pair. 47 You might as well do this up front. 48 49 */ 50 #define PAIRSIZE(K,D) (2*sizeof(u_short) + K->size + D->size) 51 #define BIGOVERHEAD (4*sizeof(u_short)) 52 #define KEYSIZE(K) (4*sizeof(u_short) + K->size); 53 #define OVFLSIZE (2*sizeof(u_short)) 54 #define FREESPACE(P) (P[P[0]+1]) 55 #define OFFSET(P) (P[P[0]+2]) 56 #define PAIRFITS(P,K,D) ((P[1] >= REAL_KEY) && \ 57 (PAIRSIZE(K,D) + OVFLSIZE) <= FREESPACE(P)) 58 #define PAGE_META(N) ((N+3) * sizeof(u_short)) 59 60 typedef struct { 61 BUFHEAD *newp; 62 BUFHEAD *oldp; 63 BUFHEAD *nextp; 64 u_short next_addr; 65 } SPLIT_RETURN; 66 67