File: extent.h

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (118 lines) | stat: -rw-r--r-- 3,630 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 *  $Id$
 *
 *  Disk extents
 *
 *  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 *  project.
 *
 *  Copyright (C) 1998-2012 OpenLink Software
 *
 *  This project is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; only version 2 of the License, dated June 1991.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */


#define EXTENT_SZ 256
#define KEY_OWN_EXTENT_THRESHOLD (EXTENT_SZ / 2)

#define EXT_FREE 0
#define EXT_INDEX 1
#define EXT_REMAP 2
#define EXT_BLOB 3
#define EXT_FULL 8

#define EXT_TYPE(ext) (7 & (ext)->ext_flags)

/* em_free_dp flags to indicate expected type of ext.  In addition to EXT_* */
#define EMF_INDEX_OR_REMAP 4
#define EMF_DO_NOT_FREE_EXT 16
#define EMF_ANY 32
#define EMF_INDEX_OR_BLOB 64


#define EXT_ROUND(dp) ((dp) & ~(EXTENT_SZ - 1))

typedef struct extent_s
{
  int32	ext_flags;
  dp_addr_t	ext_dp;
  dp_addr_t	ext_prev; /* splits overflowing from that extent come here */
  dp_addr_t	ext_next; /* if this is full, splits here go to that extent */
  int32	ext_pages[EXTENT_SZ / 32];
} extent_t;


struct extent_map_s
{
  caddr_t		em_name; /* registry name, value is the 1st page  */
  dp_addr_t		em_map_start; /* first dp of stored em */
  dp_addr_t		em_n_pages;
  dp_addr_t		em_n_free_pages;
  dp_addr_t		em_n_remap_pages;
  dp_addr_t		em_n_free_remap_pages;
  int32		em_remap_on_hold;  /* no of pages provisionally reserved for possible delta caused by tree splitting */
  dp_addr_t		em_n_blob_pages;
  dp_addr_t		em_n_free_blob_pages;
  extent_t *		em_last_remap_ext;
  extent_t *		em_last_blob_ext;
  buffer_desc_t *	em_buf;
  dk_hash_t *		em_dp_to_ext;
  dk_mutex_t *		em_mtx;
  dbe_storage_t *	em_dbs;
  dbe_key_frag_t *	em_kf; /*  null for general sys ext, else the kf which allocates from here */
  dk_hash_t *		em_read_history;
  uint32		em_last_ext_read;
  dk_mutex_t 		em_read_history_mtx;
  dk_hash_t *		em_uninitialized; /* just alloc'd no buffer yet, avoid these in read ahead even if they look allocd.  Not applied to system ext map. */
};


#define EM_DP_TO_EXT(em, dp) \
  ((extent_t *) gethash (DP_ADDR2VOID (EXT_ROUND (dp)), em->em_dp_to_ext))

#define DP_IN_EXTENT(dp, ext) ((dp) >= (ext)->ext_dp && (dp) < (ext)->ext_dp + EXTENT_SZ)

#define EXT_BIT(ext, dp, inx, bit) \
{ \
  inx = ((dp) - ext->ext_dp) >> 5; \
  bit = (dp - ext->ext_dp) & 0x1f; \
}

#define DP_ANY ((dp_addr_t)-1)

#define EXT_EXTENDS_NONE ((dp_addr_t) -1)

#define DBS_DP_TO_EM(dbs, dp) \
  ((extent_map_t *) gethash (DP_ADDR2VOID (EXT_ROUND (dp)), dbs->dbs_dp_to_extent_map))

#define DP_OUT_OF_DISK ((dp_addr_t)-1)

caddr_t em_page_list (extent_map_t * em, int type);

#define DO_EXT(ext, em) \
{ \
  extent_t * ext; \
  buffer_desc_t * _buf; \
  for (_buf = em->em_buf; _buf; _buf = _buf->bd_next) \
    { \
      int _fill = LONG_REF (_buf->bd_buffer + DP_BLOB_LEN), _off; \
      for (_off = DP_DATA; _off < DP_DATA + _fill; _off += sizeof (extent_t)) \
	{ \
	  ext = (extent_t *) (_buf->bd_buffer + _off);


#define END_DO_EXT } } }

buffer_desc_t **  ext_read (index_tree_t * it, extent_t * ext, int keep_ts, dk_hash_t * phys_to_log);