db_manage.c File Reference

#include <stdlib.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include "odb.h"
#include "op_string.h"
#include "op_libiberty.h"
Include dependency graph for db_manage.c:

Go to the source code of this file.

Defines

#define _GNU_SOURCE
#define DEFAULT_NODE_NR(offset_node)   128
#define FILES_HASH_SIZE   512

Functions

static __inline odb_descr_todb_to_descr (odb_data_t *data)
static __inline odb_node_todb_to_node_base (odb_data_t *data)
static __inline odb_index_todb_to_hash_base (odb_data_t *data)
static unsigned int tables_size (odb_data_t const *data, odb_node_nr_t node_nr)
int odb_grow_hashtable (odb_data_t *data)
void odb_init (odb_t *odb)
static void init_hash ()
static odb_data_tfind_samples_data (size_t hash, char const *filename)
int odb_open (odb_t *odb, char const *filename, enum odb_rw rw, size_t sizeof_header)
void odb_close (odb_t *odb)
int odb_open_count (odb_t const *odb)
void * odb_get_data (odb_t *odb)
void odb_sync (odb_t const *odb)

Variables

static struct list_head files_hash [FILES_HASH_SIZE]

Detailed Description

Management of a DB file

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
Philippe Elie

Definition in file db_manage.c.


Define Documentation

#define _GNU_SOURCE

Definition at line 11 of file db_manage.c.

#define DEFAULT_NODE_NR ( offset_node   )     128

Definition at line 127 of file db_manage.c.

Referenced by odb_open().

#define FILES_HASH_SIZE   512

Definition at line 128 of file db_manage.c.

Referenced by init_hash(), and odb_open().


Function Documentation

static odb_data_t* find_samples_data ( size_t  hash,
char const *  filename 
) [static]

Definition at line 142 of file db_manage.c.

References odb_data::filename, files_hash, init_hash(), list_entry, list_for_each, and list_head::next.

Referenced by odb_open().

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_hash (  )  [static]

Definition at line 133 of file db_manage.c.

References files_hash, FILES_HASH_SIZE, and list_init().

Referenced by find_samples_data().

Here is the call graph for this function:

Here is the caller graph for this function:

void odb_close ( odb_t odb  ) 

Close the given ODB file

Definition at line 263 of file db_manage.c.

References odb_data::base_memory, odb_t::data, odb_data::descr, odb_data::fd, odb_data::filename, odb_data::list, list_del(), odb_data::ref_count, odb_descr_t::size, and tables_size().

Referenced by close_sfile(), ibs_sfile_close(), main(), opd_24_sfile_lru_clear(), opd_close_image_samples_files(), sanity_check(), speed_test(), and test().

Here is the call graph for this function:

Here is the caller graph for this function:

void* odb_get_data ( odb_t odb  ) 

return the start of the mapped data

Definition at line 291 of file db_manage.c.

References odb_data::base_memory, and odb_t::data.

Referenced by import_from_abi(), main(), opd_open_24_sample_file(), opd_open_sample_file(), and operf_open_sample_file().

Here is the caller graph for this function:

int odb_grow_hashtable ( odb_data_t data  ) 

grow the hashtable in such way current_size is the index of the first free node. Take care all node pointer can be invalidated by this call.

Node allocation is done in a two step way 1st) ensure a free node exist eventually, caller can setup it, 2nd) commit the node allocation with odb_commit_reservation(). This is done in this way to ensure node setup is visible from another process like pp tools in an atomic way.

returns 0 on success, non zero on failure in this case this function do nothing and errno is set by the first libc call failure allowing to retry after cleanup some program resource.

Definition at line 63 of file db_manage.c.

References odb_data::base_memory, BUCKET_FACTOR, odb_descr_t::current_size, odb_data::descr, odb_data::fd, odb_data::hash_base, odb_data::hash_mask, odb_node_t::key, odb_node_t::next, odb_data::node_base, odb_do_hash(), odb_to_descr(), odb_to_hash_base(), odb_to_node_base(), odb_descr_t::size, and tables_size().

Referenced by add_node().

Here is the call graph for this function:

Here is the caller graph for this function:

void odb_init ( odb_t odb  ) 

odb_init - initialize a DB file

Parameters:
odb the DB file to init

Definition at line 120 of file db_manage.c.

References odb_t::data.

Referenced by create_sfile(), ibs_sfile_create(), ibs_sfile_dup(), opd_open_24_sample_file(), operf_sfile_dup(), and sfile_dup().

Here is the caller graph for this function:

int odb_open ( odb_t odb,
char const *  filename,
enum odb_rw  rw,
size_t  sizeof_header 
)
int odb_open_count ( odb_t const *  odb  ) 

return the number of times this sample file is open

Definition at line 283 of file db_manage.c.

References odb_t::data, and odb_data::ref_count.

Referenced by get_file(), ibs_sfile_get(), and opd_put_image_sample().

Here is the caller graph for this function:

void odb_sync ( odb_t const *  odb  ) 

issue a msync on the used size of the mmaped file

Definition at line 297 of file db_manage.c.

References odb_data::base_memory, odb_t::data, odb_data::descr, odb_descr_t::size, and tables_size().

Referenced by ibs_sfile_sync(), opd_sync_samples_files(), and sync_sfile().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline odb_descr_t* odb_to_descr ( odb_data_t data  )  [static]

Definition at line 28 of file db_manage.c.

References odb_data::base_memory, and odb_data::sizeof_header.

Referenced by odb_grow_hashtable(), and odb_open().

Here is the caller graph for this function:

static __inline odb_index_t* odb_to_hash_base ( odb_data_t data  )  [static]

Definition at line 40 of file db_manage.c.

References odb_data::base_memory, odb_data::descr, odb_data::offset_node, and odb_descr_t::size.

Referenced by odb_grow_hashtable(), and odb_open().

Here is the caller graph for this function:

static __inline odb_node_t* odb_to_node_base ( odb_data_t data  )  [static]

Definition at line 34 of file db_manage.c.

References odb_data::base_memory, and odb_data::offset_node.

Referenced by odb_grow_hashtable(), and odb_open().

Here is the caller graph for this function:

static unsigned int tables_size ( odb_data_t const *  data,
odb_node_nr_t  node_nr 
) [static]

return the number of bytes used by hash table, node table and header.

Definition at line 51 of file db_manage.c.

References BUCKET_FACTOR, and odb_data::offset_node.

Referenced by odb_close(), odb_grow_hashtable(), odb_open(), and odb_sync().

Here is the caller graph for this function:


Variable Documentation

struct list_head files_hash[FILES_HASH_SIZE] [static]

Definition at line 130 of file db_manage.c.

Referenced by find_samples_data(), init_hash(), and odb_open().


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1