Data Structures | Defines | Typedefs | Functions | Variables

P_CacheDir.h File Reference

A brief file description. More...

#include "P_CacheHttp.h"
Include dependency graph for P_CacheDir.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Dir
struct  FreeDir
struct  OpenDir
struct  CacheSync

Defines

#define DIR_TAG_WIDTH   12
#define DIR_MASK_TAG(_t)   ((_t) & ((1 << DIR_TAG_WIDTH) - 1))
#define SIZEOF_DIR   10
#define ESTIMATED_OBJECT_SIZE   8000
#define MAX_DIR_SEGMENTS   (32 * (1<<16))
#define DIR_DEPTH   4
#define DIR_SIZE_WIDTH   6
#define DIR_BLOCK_SIZES   4
#define DIR_BLOCK_SHIFT(_i)   (3*(_i))
#define DIR_BLOCK_SIZE(_i)   (CACHE_BLOCK_SIZE << DIR_BLOCK_SHIFT(_i))
#define DIR_SIZE_WITH_BLOCK(_i)   ((1<<DIR_SIZE_WIDTH) * DIR_BLOCK_SIZE(_i))
#define DIR_OFFSET_BITS   40
#define DIR_OFFSET_MAX   ((((off_t)1) << DIR_OFFSET_BITS) - 1)
#define SYNC_MAX_WRITE   (2 * 1024 * 1024)
#define SYNC_DELAY   HRTIME_MSECONDS(500)
#define DO_NOT_REMOVE_THIS   0
#define CHECK_DIR(_d)   ((void)0)
#define dir_index(_e, _i)   ((Dir*)((char*)(_e)->dir + (SIZEOF_DIR * (_i))))
#define dir_assign(_e, _x)
#define dir_assign_data(_e, _x)
#define dir_valid(_d, _e)
#define dir_agg_valid(_d, _e)
#define dir_write_valid(_d, _e)
#define dir_agg_buf_valid(_d, _e)   (_d->header->phase == dir_phase(_e) && vol_in_phase_agg_buf_valid(_d, _e))
#define dir_is_empty(_e)   (!dir_offset(_e))
#define dir_clear(_e)
#define dir_clean(_e)   dir_set_offset(_e,0)
#define dir_segment(_s, _d)   vol_dir_segment(_d, _s)
#define OPEN_DIR_BUCKETS   256
#define dir_offset(_e)
#define dir_set_offset(_e, _o)
#define dir_bit(_e, _w, _b)   ((uint32_t)(((_e)->w[_w] >> (_b)) & 1))
#define dir_set_bit(_e, _w, _b, _v)   (_e)->w[_w] = (uint16_t)(((_e)->w[_w] & ~(1<<(_b))) | (((_v)?1:0)<<(_b)))
#define dir_big(_e)   ((uint32_t)((((_e)->w[1]) >> 8)&0x3))
#define dir_set_big(_e, _v)   (_e)->w[1] = (uint16_t)(((_e)->w[1] & 0xFCFF) | (((uint16_t)(_v))&0x3)<<8)
#define dir_size(_e)   ((uint32_t)(((_e)->w[1]) >> 10))
#define dir_set_size(_e, _v)   (_e)->w[1] = (uint16_t)(((_e)->w[1] & ((1<<10)-1)) | ((_v)<<10))
#define dir_set_approx_size(_e, _s)
#define dir_approx_size(_e)   ((dir_size(_e) + 1) * DIR_BLOCK_SIZE(dir_big(_e)))
#define round_to_approx_dir_size(_s)
#define dir_tag(_e)   ((uint32_t)((_e)->w[2]&((1<<DIR_TAG_WIDTH)-1)))
#define dir_set_tag(_e, _t)   (_e)->w[2] = (uint16_t)(((_e)->w[2]&~((1<<DIR_TAG_WIDTH)-1)) | ((_t)&((1<<DIR_TAG_WIDTH)-1)))
#define dir_phase(_e)   dir_bit(_e,2,12)
#define dir_set_phase(_e, _v)   dir_set_bit(_e,2,12,_v)
#define dir_head(_e)   dir_bit(_e,2,13)
#define dir_set_head(_e, _v)   dir_set_bit(_e,2,13,_v)
#define dir_pinned(_e)   dir_bit(_e,2,14)
#define dir_set_pinned(_e, _v)   dir_set_bit(_e,2,14,_v)
#define dir_token(_e)   dir_bit(_e,2,15)
#define dir_set_token(_e, _v)   dir_set_bit(_e,2,15,_v)
#define dir_next(_e)   (_e)->w[3]
#define dir_set_next(_e, _o)   (_e)->w[3] = (uint16_t)(_o)
#define dir_prev(_e)   (_e)->w[2]
#define dir_set_prev(_e, _o)   (_e)->w[2] = (uint16_t)(_o)
#define dir_in_seg(_s, _i)   ((Dir*)(((char*)(_s)) + (SIZEOF_DIR *(_i))))

Typedefs

typedef uint32_t DirInfo

Functions

 LINK_FORWARD_DECLARATION (CacheVC, opendir_link) struct OpenDirEntry
void vol_init_dir (Vol *d)
int dir_token_probe (CacheKey *, Vol *, Dir *)
int dir_probe (CacheKey *, Vol *, Dir *, Dir **)
int dir_insert (CacheKey *key, Vol *d, Dir *to_part)
int dir_overwrite (CacheKey *key, Vol *d, Dir *to_part, Dir *overwrite, bool must_overwrite=true)
int dir_delete (CacheKey *key, Vol *d, Dir *del)
int dir_lookaside_probe (CacheKey *key, Vol *d, Dir *result, EvacuationBlock **eblock)
int dir_lookaside_insert (EvacuationBlock *b, Vol *d, Dir *to)
int dir_lookaside_fixup (CacheKey *key, Vol *d)
void dir_lookaside_cleanup (Vol *d)
void dir_lookaside_remove (CacheKey *key, Vol *d)
void dir_free_entry (Dir *e, int s, Vol *d)
void dir_sync_init ()
int check_dir (Vol *d)
void dir_clean_vol (Vol *d)
void dir_clear_range (off_t start, off_t end, Vol *d)
int dir_segment_accounted (int s, Vol *d, int offby=0, int *free=0, int *used=0, int *empty=0, int *valid=0, int *agg_valid=0, int *avg_size=0)
uint64_t dir_entries_used (Vol *d)
void sync_cache_dir_on_shutdown ()
TS_INLINE bool dir_compare_tag (Dir *e, CacheKey *key)
TS_INLINE Dirdir_from_offset (int64_t i, Dir *seg)
TS_INLINE Dirnext_dir (Dir *d, Dir *seg)
TS_INLINE int64_t dir_to_offset (Dir *d, Dir *seg)
TS_INLINE Dirdir_bucket (int64_t b, Dir *seg)
TS_INLINE Dirdir_bucket_row (Dir *b, int64_t i)

Variables

Dir empty_dir

Detailed Description

A brief file description.

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file P_CacheDir.h.


Define Documentation

#define CHECK_DIR (   _d  )     ((void)0)
#define dir_agg_buf_valid (   _d,
  _e 
)    (_d->header->phase == dir_phase(_e) && vol_in_phase_agg_buf_valid(_d, _e))

Definition at line 98 of file P_CacheDir.h.

Referenced by CacheVC::handleRead().

#define dir_agg_valid (   _d,
  _e 
)
#define dir_approx_size (   _e  )     ((dir_size(_e) + 1) * DIR_BLOCK_SIZE(dir_big(_e)))
#define dir_assign (   _e,
  _x 
)
Value:
do {                \
    (_e)->w[0] = (_x)->w[0];                  \
    (_e)->w[1] = (_x)->w[1];                  \
    (_e)->w[2] = (_x)->w[2];                  \
    (_e)->w[3] = (_x)->w[3];                  \
    (_e)->w[4] = (_x)->w[4];                  \
} while (0)

Definition at line 73 of file P_CacheDir.h.

Referenced by dir_delete_entry(), dir_insert(), dir_probe(), CacheVC::do_read_call(), CacheVC::openReadStartEarliest(), CacheVC::openWriteCloseHeadDone(), and CacheVC::scanOpenWrite().

#define dir_assign_data (   _e,
  _x 
)
Value:
do {           \
  unsigned short next = dir_next(_e);         \
  dir_assign(_e, _x);                         \
  dir_set_next(_e, next);                     \
} while(0)

Definition at line 80 of file P_CacheDir.h.

Referenced by dir_insert(), and dir_overwrite().

#define dir_big (   _e  )     ((uint32_t)((((_e)->w[1]) >> 8)&0x3))

Definition at line 211 of file P_CacheDir.h.

#define dir_bit (   _e,
  _w,
  _b 
)    ((uint32_t)(((_e)->w[_w] >> (_b)) & 1))

Definition at line 209 of file P_CacheDir.h.

#define DIR_BLOCK_SHIFT (   _i  )     (3*(_i))

Definition at line 49 of file P_CacheDir.h.

#define DIR_BLOCK_SIZE (   _i  )     (CACHE_BLOCK_SIZE << DIR_BLOCK_SHIFT(_i))

Definition at line 50 of file P_CacheDir.h.

#define DIR_BLOCK_SIZES   4

Definition at line 48 of file P_CacheDir.h.

#define dir_clean (   _e  )     dir_set_offset(_e,0)

Definition at line 109 of file P_CacheDir.h.

Referenced by CacheVC::openReadFromWriter().

#define dir_clear (   _e  ) 
Value:
do { \
    (_e)->w[0] = 0; \
    (_e)->w[1] = 0; \
    (_e)->w[2] = 0; \
    (_e)->w[3] = 0; \
    (_e)->w[4] = 0; \
} while (0)

Definition at line 102 of file P_CacheDir.h.

Referenced by Vol::aggWriteDone(), Cache_dir(), Dir::Dir(), dir_delete_entry(), FreeDir::FreeDir(), new_CacheVC(), OpenDir::open_write(), and Cache::remove().

#define DIR_DEPTH   4
#define dir_head (   _e  )     dir_bit(_e,2,13)
#define dir_in_seg (   _s,
  _i 
)    ((Dir*)(((char*)(_s)) + (SIZEOF_DIR *(_i))))

Definition at line 345 of file P_CacheDir.h.

Referenced by dir_bucket(), dir_bucket_row(), and dir_from_offset().

#define dir_index (   _e,
  _i 
)    ((Dir*)((char*)(_e)->dir + (SIZEOF_DIR * (_i))))

Definition at line 72 of file P_CacheDir.h.

Referenced by dir_clear_range().

#define dir_is_empty (   _e  )     (!dir_offset(_e))
#define DIR_MASK_TAG (   _t  )     ((_t) & ((1 << DIR_TAG_WIDTH) - 1))
#define dir_next (   _e  )     (_e)->w[3]
#define dir_offset (   _e  ) 
#define DIR_OFFSET_BITS   40

Definition at line 52 of file P_CacheDir.h.

#define DIR_OFFSET_MAX   ((((off_t)1) << DIR_OFFSET_BITS) - 1)

Definition at line 53 of file P_CacheDir.h.

Referenced by Vol::handle_recover_from_data().

#define dir_phase (   _e  )     dir_bit(_e,2,12)
#define dir_pinned (   _e  )     dir_bit(_e,2,14)

Definition at line 241 of file P_CacheDir.h.

Referenced by CacheVC::openReadClose(), and Vol::scan_for_pinned_documents().

#define dir_prev (   _e  )     (_e)->w[2]

Definition at line 247 of file P_CacheDir.h.

Referenced by unlink_from_freelist().

#define dir_segment (   _s,
  _d 
)    vol_dir_segment(_d, _s)
#define dir_set_approx_size (   _e,
  _s 
)
Value:
do {                         \
  if ((_s) <= DIR_SIZE_WITH_BLOCK(0)) {                          \
    dir_set_big(_e,0);                                           \
    dir_set_size(_e,((_s)-1) / DIR_BLOCK_SIZE(0));               \
  } else if ((_s) <= DIR_SIZE_WITH_BLOCK(1)) {                   \
    dir_set_big(_e,1);                                           \
    dir_set_size(_e,((_s)-1) / DIR_BLOCK_SIZE(1));               \
  } else if ((_s) <= DIR_SIZE_WITH_BLOCK(2)) {                   \
    dir_set_big(_e,2);                                           \
    dir_set_size(_e,((_s)-1) / DIR_BLOCK_SIZE(2));               \
  } else {                                                       \
    dir_set_big(_e,3);                                           \
    dir_set_size(_e,((_s)-1) / DIR_BLOCK_SIZE(3));               \
  }                                                              \
} while (0)

Definition at line 215 of file P_CacheDir.h.

Referenced by agg_copy(), and CacheVC::handleReadDone().

#define dir_set_big (   _e,
  _v 
)    (_e)->w[1] = (uint16_t)(((_e)->w[1] & 0xFCFF) | (((uint16_t)(_v))&0x3)<<8)

Definition at line 212 of file P_CacheDir.h.

#define dir_set_bit (   _e,
  _w,
  _b,
  _v 
)    (_e)->w[_w] = (uint16_t)(((_e)->w[_w] & ~(1<<(_b))) | (((_v)?1:0)<<(_b)))

Definition at line 210 of file P_CacheDir.h.

#define dir_set_head (   _e,
  _v 
)    dir_set_bit(_e,2,13,_v)

Definition at line 240 of file P_CacheDir.h.

Referenced by agg_copy(), and Cache_dir().

#define dir_set_next (   _e,
  _o 
)    (_e)->w[3] = (uint16_t)(_o)
#define dir_set_offset (   _e,
  _o 
)
Value:
do { \
    (_e)->w[0] = (uint16_t)_o;                                                    \
    (_e)->w[1] = (uint16_t)((((_o) >> 16) & 0xFF) | ((_e)->w[1] & 0xFF00));       \
    (_e)->w[4] = (uint16_t)((_o) >> 24);                                          \
} while (0)

Definition at line 203 of file P_CacheDir.h.

Referenced by agg_copy(), Vol::aggWriteDone(), Cache_dir(), dir_clear_range(), and freelist_clean().

#define dir_set_phase (   _e,
  _v 
)    dir_set_bit(_e,2,12,_v)

Definition at line 238 of file P_CacheDir.h.

Referenced by agg_copy(), and Cache_dir().

#define dir_set_pinned (   _e,
  _v 
)    dir_set_bit(_e,2,14,_v)

Definition at line 242 of file P_CacheDir.h.

Referenced by agg_copy().

#define dir_set_prev (   _e,
  _o 
)    (_e)->w[2] = (uint16_t)(_o)

Definition at line 248 of file P_CacheDir.h.

Referenced by dir_delete_entry(), dir_free_entry(), freelist_pop(), and unlink_from_freelist().

#define dir_set_size (   _e,
  _v 
)    (_e)->w[1] = (uint16_t)(((_e)->w[1] & ((1<<10)-1)) | ((_v)<<10))

Definition at line 214 of file P_CacheDir.h.

#define dir_set_tag (   _e,
  _t 
)    (_e)->w[2] = (uint16_t)(((_e)->w[2]&~((1<<DIR_TAG_WIDTH)-1)) | ((_t)&((1<<DIR_TAG_WIDTH)-1)))
#define dir_set_token (   _e,
  _v 
)    dir_set_bit(_e,2,15,_v)

Definition at line 244 of file P_CacheDir.h.

#define dir_size (   _e  )     ((uint32_t)(((_e)->w[1]) >> 10))

Definition at line 213 of file P_CacheDir.h.

#define DIR_SIZE_WIDTH   6

Definition at line 47 of file P_CacheDir.h.

#define DIR_SIZE_WITH_BLOCK (   _i  )     ((1<<DIR_SIZE_WIDTH) * DIR_BLOCK_SIZE(_i))

Definition at line 51 of file P_CacheDir.h.

#define dir_tag (   _e  )     ((uint32_t)((_e)->w[2]&((1<<DIR_TAG_WIDTH)-1)))
#define DIR_TAG_WIDTH   12

Definition at line 40 of file P_CacheDir.h.

#define dir_token (   _e  )     dir_bit(_e,2,15)

Definition at line 243 of file P_CacheDir.h.

Referenced by dir_clear_range().

#define dir_valid (   _d,
  _e 
)
#define dir_write_valid (   _d,
  _e 
)
Value:
(_d->header->phase == dir_phase(_e) ? vol_in_phase_valid(_d, _e) :   \
                                        vol_out_of_phase_write_valid(_d, _e))

Definition at line 95 of file P_CacheDir.h.

#define DO_NOT_REMOVE_THIS   0

Definition at line 57 of file P_CacheDir.h.

#define ESTIMATED_OBJECT_SIZE   8000

Definition at line 43 of file P_CacheDir.h.

#define MAX_DIR_SEGMENTS   (32 * (1<<16))

Definition at line 45 of file P_CacheDir.h.

#define OPEN_DIR_BUCKETS   256

Definition at line 114 of file P_CacheDir.h.

#define round_to_approx_dir_size (   _s  ) 
Value:

Definition at line 231 of file P_CacheDir.h.

Referenced by Vol::round_to_approx_size().

#define SIZEOF_DIR   10
#define SYNC_DELAY   HRTIME_MSECONDS(500)

Definition at line 56 of file P_CacheDir.h.

Referenced by CacheSync::mainEvent().

#define SYNC_MAX_WRITE   (2 * 1024 * 1024)

Definition at line 55 of file P_CacheDir.h.


Typedef Documentation

typedef uint32_t DirInfo

Definition at line 116 of file P_CacheDir.h.


Function Documentation

int check_dir ( Vol d  ) 
TS_INLINE Dir* dir_bucket ( int64_t  b,
Dir seg 
)
TS_INLINE Dir* dir_bucket_row ( Dir b,
int64_t  i 
)

Definition at line 388 of file P_CacheDir.h.

References dir_in_seg.

Referenced by Cache_dir(), dir_init_segment(), dir_insert(), dir_overwrite(), freelist_clean(), and vol_init_dir().

void dir_clean_vol ( Vol d  ) 

Definition at line 367 of file CacheDir.cc.

References CHECK_DIR, dir_clean_segment(), and Vol::segments.

Referenced by Vol::agg_wrap(), and dir_clear_range().

void dir_clear_range ( off_t  start,
off_t  end,
Vol d 
)
TS_INLINE bool dir_compare_tag ( Dir e,
CacheKey key 
)
int dir_delete ( CacheKey key,
Vol d,
Dir del 
)
uint64_t dir_entries_used ( Vol d  ) 
void dir_free_entry ( Dir e,
int  s,
Vol d 
)
TS_INLINE Dir* dir_from_offset ( int64_t  i,
Dir seg 
)
int dir_insert ( CacheKey key,
Vol d,
Dir to_part 
)
void dir_lookaside_cleanup ( Vol d  ) 
int dir_lookaside_fixup ( CacheKey key,
Vol d 
)
int dir_lookaside_insert ( EvacuationBlock b,
Vol d,
Dir to 
)
int dir_lookaside_probe ( CacheKey key,
Vol d,
Dir result,
EvacuationBlock **  eblock 
)
void dir_lookaside_remove ( CacheKey key,
Vol d 
)
int dir_overwrite ( CacheKey key,
Vol d,
Dir to_part,
Dir overwrite,
bool  must_overwrite = true 
)
int dir_probe ( CacheKey ,
Vol ,
Dir ,
Dir **   
)
int dir_segment_accounted ( int  s,
Vol d,
int  offby = 0,
int *  free = 0,
int *  used = 0,
int *  empty = 0,
int *  valid = 0,
int *  agg_valid = 0,
int *  avg_size = 0 
)
void dir_sync_init (  ) 
TS_INLINE int64_t dir_to_offset ( Dir d,
Dir seg 
)
int dir_token_probe ( CacheKey ,
Vol ,
Dir  
)
LINK_FORWARD_DECLARATION ( CacheVC  ,
opendir_link   
)

Definition at line 256 of file P_CacheDir.h.

References LINK.

TS_INLINE Dir* next_dir ( Dir d,
Dir seg 
)
void sync_cache_dir_on_shutdown (  ) 
void vol_init_dir ( Vol d  ) 

Variable Documentation

Definition at line 52 of file CacheDir.cc.