Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/developer-guide/cache-architecture/architecture.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ start
The offset for the start of the content, after the stripe metadata.

length
Total number of bytes in the stripe. :cpp:member:`StripeSM::len`.
Total number of bytes in the stripe. :cpp:member:`Stripe::len`.

data length
Total number of blocks in the stripe available for content storage.
:cpp:member:`StripeSM::data_blocks`.
:cpp:member:`Stripe::data_blocks`.

.. note::

Expand Down
22 changes: 13 additions & 9 deletions doc/developer-guide/cache-architecture/data-structures.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,14 @@ Data Structures

* Timestamps for request and response from :term:`origin server`.

.. class:: StripeSM
.. class:: Stripe

This represents a :term:`storage unit` inside a :term:`cache volume`.

.. cpp:member:: off_t data_blocks

The number of blocks of storage in the stripe.

.. cpp:member:: int aggWrite(int event, void * e)

Schedule the aggregation buffer to be written to disk.

.. member:: off_t segments

The number of segments in the volume. This will be roughly the total
Expand All @@ -158,15 +154,23 @@ Data Structures
values this is around 16,384 (2^16 / 4). Buckets are used as the targets
of the index hash.

.. member:: off_t len

Length of stripe in bytes.

.. class:: StripeSM

Defined in :ts:git:`src/iocore/cache/Stripe.h`.

.. cpp:member:: int aggWrite(int event, void * e)

Schedule the aggregation buffer to be written to disk.

.. member:: DLL<EvacuationBlock> evacuate

Array of :class:`EvacuationBlock` buckets. This is sized so there
is one bucket for every evacuation span.

.. member:: off_t len

Length of stripe in bytes.

.. member:: int evac_range(off_t low, off_t high, int evac_phase)

Start an evacuation if there is any :class:`EvacuationBlock` in the range
Expand Down
4 changes: 2 additions & 2 deletions src/iocore/cache/AggregateWriteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AggregateWriteBuffer
* have a correct len field, and its headers and data must follow it. This
* requires a pointer to a full document buffer - not just the Doc struct.
* @param approx_size The approximate size of all headers and data as
* determined by StripeSM::round_to_approx_size. The document may not need
* determined by Stripe::round_to_approx_size. The document may not need
* this much space.
*
*/
Expand All @@ -100,7 +100,7 @@ class AggregateWriteBuffer
* The new document will be uninitialized.
*
* @param approx_size The approximate size of all headers and data as
* determined by StripeSM::round_to_approx_size. The document may not need
* determined by Stripe::round_to_approx_size. The document may not need
* this much space.
* @return Returns a non-owning pointer to the new document.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/iocore/cache/Cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,10 @@ CacheProcessor::stop()
}

int
CacheProcessor::dir_check(bool afix)
CacheProcessor::dir_check(bool /* afix ATS_UNUSED */)
{
for (int i = 0; i < gnstripes; i++) {
gstripes[i]->dir_check(afix);
gstripes[i]->dir_check();
}
return 0;
}
Expand Down
33 changes: 17 additions & 16 deletions src/iocore/cache/CacheDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "P_Cache.h"
#include "P_CacheDir.h"
#include "P_CacheDoc.h"
#include "Stripe.h"

#include "tscore/hugepages.h"
#include "tscore/Random.h"
Expand Down Expand Up @@ -214,7 +215,7 @@ dir_bucket_loop_check(Dir *start_dir, Dir *seg)
// adds all the directory entries
// in a segment to the segment freelist
void
dir_init_segment(int s, StripeSM *stripe)
dir_init_segment(int s, Stripe *stripe)
{
stripe->header->freelist[s] = 0;
Dir *seg = stripe->dir_segment(s);
Expand All @@ -231,7 +232,7 @@ dir_init_segment(int s, StripeSM *stripe)
// break the infinite loop in directory entries
// Note : abuse of the token bit in dir entries
int
dir_bucket_loop_fix(Dir *start_dir, int s, StripeSM *stripe)
dir_bucket_loop_fix(Dir *start_dir, int s, Stripe *stripe)
{
if (!dir_bucket_loop_check(start_dir, stripe->dir_segment(s))) {
Warning("Dir loop exists, clearing segment %d", s);
Expand All @@ -242,7 +243,7 @@ dir_bucket_loop_fix(Dir *start_dir, int s, StripeSM *stripe)
}

int
dir_freelist_length(StripeSM *stripe, int s)
dir_freelist_length(Stripe *stripe, int s)
{
int free = 0;
Dir *seg = stripe->dir_segment(s);
Expand All @@ -258,7 +259,7 @@ dir_freelist_length(StripeSM *stripe, int s)
}

int
dir_bucket_length(Dir *b, int s, StripeSM *stripe)
dir_bucket_length(Dir *b, int s, Stripe *stripe)
{
Dir *e = b;
int i = 0;
Expand All @@ -278,7 +279,7 @@ dir_bucket_length(Dir *b, int s, StripeSM *stripe)
}

int
check_dir(StripeSM *stripe)
check_dir(Stripe *stripe)
{
int i, s;
Dbg(dbg_ctl_cache_check_dir, "inside check dir");
Expand All @@ -301,7 +302,7 @@ check_dir(StripeSM *stripe)
}

inline void
unlink_from_freelist(Dir *e, int s, StripeSM *stripe)
unlink_from_freelist(Dir *e, int s, Stripe *stripe)
{
Dir *seg = stripe->dir_segment(s);
Dir *p = dir_from_offset(dir_prev(e), seg);
Expand All @@ -317,7 +318,7 @@ unlink_from_freelist(Dir *e, int s, StripeSM *stripe)
}

inline Dir *
dir_delete_entry(Dir *e, Dir *p, int s, StripeSM *stripe)
dir_delete_entry(Dir *e, Dir *p, int s, Stripe *stripe)
{
Dir *seg = stripe->dir_segment(s);
int no = dir_next(e);
Expand Down Expand Up @@ -347,7 +348,7 @@ dir_delete_entry(Dir *e, Dir *p, int s, StripeSM *stripe)
}

inline void
dir_clean_bucket(Dir *b, int s, StripeSM *stripe)
dir_clean_bucket(Dir *b, int s, Stripe *stripe)
{
Dir *e = b, *p = nullptr;
Dir *seg = stripe->dir_segment(s);
Expand Down Expand Up @@ -380,7 +381,7 @@ dir_clean_bucket(Dir *b, int s, StripeSM *stripe)
}

void
dir_clean_segment(int s, StripeSM *stripe)
dir_clean_segment(int s, Stripe *stripe)
{
Dir *seg = stripe->dir_segment(s);
for (int64_t i = 0; i < stripe->buckets; i++) {
Expand All @@ -390,7 +391,7 @@ dir_clean_segment(int s, StripeSM *stripe)
}

void
dir_clean_vol(StripeSM *stripe)
dir_clean_vol(Stripe *stripe)
{
for (int64_t i = 0; i < stripe->segments; i++) {
dir_clean_segment(i, stripe);
Expand All @@ -399,7 +400,7 @@ dir_clean_vol(StripeSM *stripe)
}

void
dir_clear_range(off_t start, off_t end, StripeSM *stripe)
dir_clear_range(off_t start, off_t end, Stripe *stripe)
{
for (off_t i = 0; i < stripe->buckets * DIR_DEPTH * stripe->segments; i++) {
Dir *e = dir_index(stripe, i);
Expand All @@ -426,7 +427,7 @@ check_bucket_not_contains(Dir *b, Dir *e, Dir *seg)
}

void
freelist_clean(int s, StripeSM *stripe)
freelist_clean(int s, Stripe *stripe)
{
dir_clean_segment(s, stripe);
if (stripe->header->freelist[s]) {
Expand All @@ -450,7 +451,7 @@ freelist_clean(int s, StripeSM *stripe)
}

inline Dir *
freelist_pop(int s, StripeSM *stripe)
freelist_pop(int s, Stripe *stripe)
{
Dir *seg = stripe->dir_segment(s);
Dir *e = dir_from_offset(stripe->header->freelist[s], seg);
Expand All @@ -472,7 +473,7 @@ freelist_pop(int s, StripeSM *stripe)
}

int
dir_segment_accounted(int s, StripeSM *stripe, int offby, int *f, int *u, int *et, int *v, int *av, int *as)
dir_segment_accounted(int s, Stripe *stripe, int offby, int *f, int *u, int *et, int *v, int *av, int *as)
{
int free = dir_freelist_length(stripe, s);
int used = 0, empty = 0;
Expand Down Expand Up @@ -525,7 +526,7 @@ dir_segment_accounted(int s, StripeSM *stripe, int offby, int *f, int *u, int *e
}

void
dir_free_entry(Dir *e, int s, StripeSM *stripe)
dir_free_entry(Dir *e, int s, Stripe *stripe)
{
Dir *seg = stripe->dir_segment(s);
unsigned int fo = stripe->header->freelist[s];
Expand Down Expand Up @@ -932,7 +933,7 @@ CacheSync::aio_write(int fd, char *b, int n, off_t o)
}

uint64_t
dir_entries_used(StripeSM *stripe)
dir_entries_used(Stripe *stripe)
{
uint64_t full = 0;
uint64_t sfull = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/iocore/cache/CacheVC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "P_CacheDoc.h"
#include "P_CacheHttp.h"
#include "P_CacheInternal.h"
#include "P_CacheVol.h"
#include "Stripe.h"

// must be included after the others
#include "iocore/cache/CacheVC.h"
Expand Down Expand Up @@ -97,7 +97,7 @@ extern int64_t cache_config_ram_cache_cutoff;
* vol_map - precalculated map
* offset - offset to start looking at (and data at this location has not been read yet). */
static off_t
next_in_map(StripeSM *stripe, char *vol_map, off_t offset)
next_in_map(Stripe *stripe, char *vol_map, off_t offset)
{
off_t start_offset = stripe->vol_offset_to_offset(0);
off_t new_off = (offset - start_offset);
Expand All @@ -113,16 +113,16 @@ next_in_map(StripeSM *stripe, char *vol_map, off_t offset)
}

// Function in CacheDir.cc that we need for make_vol_map().
int dir_bucket_loop_fix(Dir *start_dir, int s, StripeSM *stripe);
int dir_bucket_loop_fix(Dir *start_dir, int s, Stripe *stripe);

// TODO: If we used a bit vector, we could make a smaller map structure.
// TODO: If we saved a high water mark we could have a smaller buf, and avoid searching it
// when we are asked about the highest interesting offset.
/* Make map of what blocks in partition are used.
*
* d - StripeSM to make a map of. */
* d - Stripe to make a map of. */
static char *
make_vol_map(StripeSM *stripe)
make_vol_map(Stripe *stripe)
{
// Map will be one byte for each SCAN_BUF_SIZE bytes.
off_t start_offset = stripe->vol_offset_to_offset(0);
Expand Down
42 changes: 21 additions & 21 deletions src/iocore/cache/P_CacheDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// aio
#include "iocore/aio/AIO.h"

class Stripe;
class StripeSM;
struct InterimCacheVol;
struct CacheVC;
Expand Down Expand Up @@ -266,29 +267,28 @@ struct CacheSync : public Continuation {

// Global Functions

int dir_probe(const CacheKey *, StripeSM *, Dir *, Dir **);
int dir_insert(const CacheKey *key, StripeSM *stripe, Dir *to_part);
int dir_overwrite(const CacheKey *key, StripeSM *stripe, Dir *to_part, Dir *overwrite, bool must_overwrite = true);
int dir_delete(const CacheKey *key, StripeSM *stripe, Dir *del);
int dir_lookaside_probe(const CacheKey *key, StripeSM *stripe, Dir *result, EvacuationBlock **eblock);
int dir_lookaside_insert(EvacuationBlock *b, StripeSM *stripe, Dir *to);
int dir_lookaside_fixup(const CacheKey *key, StripeSM *stripe);
void dir_lookaside_cleanup(StripeSM *stripe);
void dir_lookaside_remove(const CacheKey *key, StripeSM *stripe);
void dir_free_entry(Dir *e, int s, StripeSM *stripe);
void dir_sync_init();
int check_dir(StripeSM *stripe);
void dir_clean_vol(StripeSM *stripe);
void dir_clear_range(off_t start, off_t end, StripeSM *stripe);
int dir_segment_accounted(int s, StripeSM *stripe, int offby = 0, int *free = nullptr, int *used = nullptr, int *empty = nullptr,
int *valid = nullptr, int *agg_valid = nullptr, int *avg_size = nullptr);
uint64_t dir_entries_used(StripeSM *stripe);
int dir_probe(const CacheKey *, StripeSM *, Dir *, Dir **);
int dir_insert(const CacheKey *key, StripeSM *stripe, Dir *to_part);
int dir_overwrite(const CacheKey *key, StripeSM *stripe, Dir *to_part, Dir *overwrite, bool must_overwrite = true);
int dir_delete(const CacheKey *key, StripeSM *stripe, Dir *del);
int dir_lookaside_probe(const CacheKey *key, StripeSM *stripe, Dir *result, EvacuationBlock **eblock);
int dir_lookaside_insert(EvacuationBlock *b, StripeSM *stripe, Dir *to);
int dir_lookaside_fixup(const CacheKey *key, StripeSM *stripe);
void dir_lookaside_cleanup(StripeSM *stripe);
void dir_lookaside_remove(const CacheKey *key, StripeSM *stripe);
void dir_free_entry(Dir *e, int s, Stripe *stripe);
void dir_sync_init();
int check_dir(Stripe *stripe);
void dir_clean_vol(Stripe *stripe);
void dir_clear_range(off_t start, off_t end, Stripe *stripe);
int dir_segment_accounted(int s, Stripe *stripe, int offby = 0, int *free = nullptr, int *used = nullptr, int *empty = nullptr,
int *valid = nullptr, int *agg_valid = nullptr, int *avg_size = nullptr);
uint64_t dir_entries_used(Stripe *stripe);
void sync_cache_dir_on_shutdown();
int dir_freelist_length(StripeSM *stripe, int s);

int dir_bucket_length(Dir *b, int s, StripeSM *stripe);
int dir_freelist_length(StripeSM *stripe, int s);
void dir_clean_segment(int s, StripeSM *stripe);
int dir_bucket_length(Dir *b, int s, Stripe *stripe);
int dir_freelist_length(Stripe *stripe, int s);
void dir_clean_segment(int s, Stripe *stripe);

// Inline Functions

Expand Down
Loading