Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Functions
io.c File Reference
#include "groonga_in.h"
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include "ctx.h"
#include "io.h"
#include "plugin_in.h"
#include "hash.h"
#include "ctx_impl.h"
#include <sys/mman.h>
Include dependency graph for io.c:

Go to the source code of this file.

Data Structures

struct  _grn_io_fileinfo
struct  ja_element

Macros

#define __USE_GNU   /* O_DIRECT */
#define GRN_IO_IDSTR   "GROONGA:IO:00001"
#define MAX_REQUEST   (64*1024)
#define MEM_ALIGN   grn_cache_block
#define O_BINARY   0
#define IO_HEADER_SIZE   64
#define GRN_MUNMAP(ctx, fmo, start, length)   (grn_munmap((ctx), (start), (length)))
#define GRN_MMAP(ctx, fmo, fi, offset, length)   (grn_mmap((ctx), (fi), (offset), (length)))
#define DO_MAP(io, fmo, fi, pos, size, segno, res)
#define SEG_MAP(io, segno, info)

Typedefs

typedef struct _grn_io_fileinfo fileinfo

Functions

grn_rc grn_io_init (void)
grn_rc grn_io_fin (void)
grn_iogrn_io_create_tmp (uint32_t header_size, uint32_t segment_size, uint32_t max_segment, grn_io_mode mode, uint32_t flags)
grn_iogrn_io_create (grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t segment_size, uint32_t max_segment, grn_io_mode mode, uint32_t flags)
grn_iogrn_io_create_with_array (grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t segment_size, grn_io_mode mode, int n_arrays, grn_io_array_spec *array_specs)
void grn_io_segment_alloc (grn_ctx *ctx, grn_io *io, grn_io_array_info *ai, uint32_t lseg, int *flags, void **p)
void * grn_io_array_at (grn_ctx *ctx, grn_io *io, uint32_t array, off_t offset, int *flags)
uint32_t grn_io_detect_type (grn_ctx *ctx, const char *path)
grn_iogrn_io_open (grn_ctx *ctx, const char *path, grn_io_mode mode)
grn_rc grn_io_close (grn_ctx *ctx, grn_io *io)
uint32_t grn_io_base_seg (grn_io *io)
const char * grn_io_path (grn_io *io)
void * grn_io_header (grn_io *io)
grn_rc grn_io_set_type (grn_io *io, uint32_t type)
uint32_t grn_io_get_type (grn_io *io)
grn_rc grn_io_size (grn_ctx *ctx, grn_io *io, uint64_t *size)
grn_rc grn_io_remove (grn_ctx *ctx, const char *path)
grn_rc grn_io_rename (grn_ctx *ctx, const char *old_name, const char *new_name)
grn_rc grn_io_read_ja (grn_io *io, grn_ctx *ctx, grn_io_ja_einfo *einfo, uint32_t epos, uint32_t key, uint32_t segment, uint32_t offset, void **value, uint32_t *value_len)
grn_rc grn_io_write_ja (grn_io *io, grn_ctx *ctx, uint32_t key, uint32_t segment, uint32_t offset, void *value, uint32_t value_len)
grn_rc grn_io_write_ja_ehead (grn_io *io, grn_ctx *ctx, uint32_t key, uint32_t segment, uint32_t offset, uint32_t value_len)
void * grn_io_win_map (grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment, uint32_t offset, uint32_t size, grn_io_rw_mode mode)
grn_rc grn_io_win_unmap (grn_io_win *iw)
void * grn_io_win_map2 (grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment, uint32_t offset, uint32_t size, grn_io_rw_mode mode)
grn_rc grn_io_win_unmap2 (grn_io_win *iw)
void grn_io_seg_map_ (grn_ctx *ctx, grn_io *io, uint32_t segno, grn_io_mapinfo *info)
grn_rc grn_io_seg_expire (grn_ctx *ctx, grn_io *io, uint32_t segno, uint32_t nretry)
uint32_t grn_io_expire (grn_ctx *ctx, grn_io *io, int count_thresh, uint32_t limit)
uint32_t grn_expire (grn_ctx *ctx, int count_thresh, uint32_t limit)
void * grn_io_anon_map (grn_ctx *ctx, grn_io_mapinfo *mi, size_t length)
void grn_io_anon_unmap (grn_ctx *ctx, grn_io_mapinfo *mi, size_t length)
grn_rc grn_io_lock (grn_ctx *ctx, grn_io *io, int timeout)
void grn_io_unlock (grn_io *io)
void grn_io_clear_lock (grn_io *io)
uint32_t grn_io_is_locked (grn_io *io)

Macro Definition Documentation

#define __USE_GNU   /* O_DIRECT */

Definition at line 23 of file io.c.

#define DO_MAP (   io,
  fmo,
  fi,
  pos,
  size,
  segno,
  res 
)
Value:
do {\
if (((res) = GRN_MMAP(&grn_gctx, (fmo), (fi), (pos), (size)))) {\
uint32_t nmaps;\
if (io->max_map_seg < segno) { io->max_map_seg = segno; }\
GRN_ATOMIC_ADD_EX(&io->nmaps, 1, nmaps);\
{\
uint64_t tail = io->base + (uint64_t)(size) * ((segno) + 1);\
if (tail > io->header->curr_size) { io->header->curr_size = tail; }\
}\
}\
} while (0)

Definition at line 1268 of file io.c.

#define GRN_IO_IDSTR   "GROONGA:IO:00001"

Definition at line 35 of file io.c.

#define GRN_MMAP (   ctx,
  fmo,
  fi,
  offset,
  length 
)    (grn_mmap((ctx), (fi), (offset), (length)))

Definition at line 89 of file io.c.

#define GRN_MUNMAP (   ctx,
  fmo,
  start,
  length 
)    (grn_munmap((ctx), (start), (length)))

Definition at line 81 of file io.c.

#define IO_HEADER_SIZE   64

Definition at line 65 of file io.c.

#define MAX_REQUEST   (64*1024)

Definition at line 39 of file io.c.

#define MEM_ALIGN   grn_cache_block

Definition at line 41 of file io.c.

#define O_BINARY   0

Definition at line 49 of file io.c.

#define SEG_MAP (   io,
  segno,
  info 
)
Value:
do {\
uint32_t segment_size = io->header->segment_size;\
if ((io->flags & GRN_IO_TEMPORARY)) {\
DO_MAP(io, &info->fmo, NULL, 0, segment_size, segno, info->map);\
} else {\
uint32_t segments_per_file = GRN_IO_FILE_SIZE / segment_size;\
uint32_t bseg = segno + io->base_seg;\
uint32_t fno = bseg / segments_per_file;\
off_t base = fno ? 0 : io->base - (uint64_t)segment_size * io->base_seg;\
off_t pos = (uint64_t)segment_size * (bseg % segments_per_file) + base;\
fileinfo *fi = &io->fis[fno];\
if (!grn_opened(fi)) {\
char path[PATH_MAX];\
gen_pathname(io->path, path, fno);\
if (!grn_open(ctx, fi, path, O_RDWR|O_CREAT, GRN_IO_FILE_SIZE)) { \
DO_MAP(io, &info->fmo, fi, pos, segment_size, segno, info->map);\
}\
} else {\
DO_MAP(io, &info->fmo, fi, pos, segment_size, segno, info->map);\
}\
}\
} while (0)

Definition at line 1280 of file io.c.

Typedef Documentation

typedef struct _grn_io_fileinfo fileinfo

Function Documentation

uint32_t grn_expire ( grn_ctx ctx,
int  count_thresh,
uint32_t  limit 
)

Definition at line 1428 of file io.c.

void* grn_io_anon_map ( grn_ctx ctx,
grn_io_mapinfo mi,
size_t  length 
)

Definition at line 1451 of file io.c.

Here is the caller graph for this function:

void grn_io_anon_unmap ( grn_ctx ctx,
grn_io_mapinfo mi,
size_t  length 
)

Definition at line 1457 of file io.c.

Here is the caller graph for this function:

void* grn_io_array_at ( grn_ctx ctx,
grn_io io,
uint32_t  array,
off_t  offset,
int *  flags 
)

Definition at line 390 of file io.c.

uint32_t grn_io_base_seg ( grn_io io)

Definition at line 545 of file io.c.

void grn_io_clear_lock ( grn_io io)

Definition at line 1516 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_close ( grn_ctx ctx,
grn_io io 
)

Definition at line 502 of file io.c.

Here is the caller graph for this function:

grn_io* grn_io_create ( grn_ctx ctx,
const char *  path,
uint32_t  header_size,
uint32_t  segment_size,
uint32_t  max_segment,
grn_io_mode  mode,
uint32_t  flags 
)

Definition at line 193 of file io.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_io* grn_io_create_tmp ( uint32_t  header_size,
uint32_t  segment_size,
uint32_t  max_segment,
grn_io_mode  mode,
uint32_t  flags 
)

Definition at line 109 of file io.c.

Here is the caller graph for this function:

grn_io* grn_io_create_with_array ( grn_ctx ctx,
const char *  path,
uint32_t  header_size,
uint32_t  segment_size,
grn_io_mode  mode,
int  n_arrays,
grn_io_array_spec array_specs 
)

Definition at line 304 of file io.c.

Here is the call graph for this function:

uint32_t grn_io_detect_type ( grn_ctx ctx,
const char *  path 
)

Definition at line 398 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_expire ( grn_ctx ctx,
grn_io io,
int  count_thresh,
uint32_t  limit 
)

Definition at line 1353 of file io.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_io_fin ( void  )

Definition at line 103 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_get_type ( grn_io io)

Definition at line 573 of file io.c.

Here is the caller graph for this function:

void* grn_io_header ( grn_io io)

Definition at line 557 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_init ( void  )

Definition at line 97 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_is_locked ( grn_io io)

Definition at line 1522 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_lock ( grn_ctx ctx,
grn_io io,
int  timeout 
)

Definition at line 1467 of file io.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_io* grn_io_open ( grn_ctx ctx,
const char *  path,
grn_io_mode  mode 
)

Definition at line 426 of file io.c.

Here is the caller graph for this function:

const char* grn_io_path ( grn_io io)

Definition at line 551 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_read_ja ( grn_io io,
grn_ctx ctx,
grn_io_ja_einfo einfo,
uint32_t  epos,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
void **  value,
uint32_t *  value_len 
)

Definition at line 681 of file io.c.

grn_rc grn_io_remove ( grn_ctx ctx,
const char *  path 
)

Definition at line 623 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_rename ( grn_ctx ctx,
const char *  old_name,
const char *  new_name 
)

Definition at line 648 of file io.c.

grn_rc grn_io_seg_expire ( grn_ctx ctx,
grn_io io,
uint32_t  segno,
uint32_t  nretry 
)

Definition at line 1310 of file io.c.

Here is the caller graph for this function:

void grn_io_seg_map_ ( grn_ctx ctx,
grn_io io,
uint32_t  segno,
grn_io_mapinfo info 
)

Definition at line 1304 of file io.c.

void grn_io_segment_alloc ( grn_ctx ctx,
grn_io io,
grn_io_array_info ai,
uint32_t  lseg,
int *  flags,
void **  p 
)

Definition at line 372 of file io.c.

grn_rc grn_io_set_type ( grn_io io,
uint32_t  type 
)

Definition at line 563 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_size ( grn_ctx ctx,
grn_io io,
uint64_t *  size 
)

Definition at line 594 of file io.c.

Here is the caller graph for this function:

void grn_io_unlock ( grn_io io)

Definition at line 1507 of file io.c.

Here is the caller graph for this function:

void* grn_io_win_map ( grn_io io,
grn_ctx ctx,
grn_io_win iw,
uint32_t  segment,
uint32_t  offset,
uint32_t  size,
grn_io_rw_mode  mode 
)

Definition at line 856 of file io.c.

void* grn_io_win_map2 ( grn_io io,
grn_ctx ctx,
grn_io_win iw,
uint32_t  segment,
uint32_t  offset,
uint32_t  size,
grn_io_rw_mode  mode 
)

Definition at line 1175 of file io.c.

grn_rc grn_io_win_unmap ( grn_io_win iw)

Definition at line 1098 of file io.c.

grn_rc grn_io_win_unmap2 ( grn_io_win iw)

Definition at line 1231 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_write_ja ( grn_io io,
grn_ctx ctx,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
void *  value,
uint32_t  value_len 
)

Definition at line 776 of file io.c.

grn_rc grn_io_write_ja_ehead ( grn_io io,
grn_ctx ctx,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
uint32_t  value_len 
)

Definition at line 831 of file io.c.