store_swapin.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 20 Storage Manager Swapin Functions */
10 
11 #include "squid.h"
12 #include "globals.h"
13 #include "StatCounters.h"
14 #include "Store.h"
15 #include "store_swapin.h"
16 #include "StoreClient.h"
17 
20 
21 void
23 {
24  StoreEntry *e = sc->entry;
25 
26  if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
27  /* We're still reloading and haven't validated this entry yet */
28  return;
29  }
30 
31  if (e->mem_status != NOT_IN_MEMORY)
32  debugs(20, 3, HERE << "already IN_MEMORY");
33 
34  debugs(20, 3, *e << " " << e->getMD5Text());
35 
36  if (!e->hasDisk()) {
37  debugs(20, DBG_IMPORTANT, "BUG: Attempt to swap in a not-stored entry " << *e << ". Salvaged.");
38  return;
39  }
40 
41  if (e->swapoutFailed()) {
42  debugs(20, DBG_IMPORTANT, "BUG: Attempt to swap in a failed-to-store entry " << *e << ". Salvaged.");
43  return;
44  }
45 
46  assert(e->mem_obj != NULL);
48 }
49 
50 static void
52 {
54  debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag);
55  sc->swapin_sio = NULL;
56 
57  if (sc->_callback.pending()) {
58  assert (errflag <= 0);
59  sc->callback(0, errflag ? true : false);
60  }
61 
63 }
64 
65 static void
67 {
69  StoreEntry *e = sc->entry;
70 
71  debugs(1, 3, "storeSwapInFileNotify: changing " << e->swap_filen << "/" <<
72  e->swap_dirn << " to " << sc->swapin_sio->swap_filen << "/" <<
73  sc->swapin_sio->swap_dirn);
74 
75  assert(e->swap_filen < 0); // if this fails, call SwapDir::disconnect(e)
76  e->swap_filen = sc->swapin_sio->swap_filen;
77  e->swap_dirn = sc->swapin_sio->swap_dirn;
78 }
79 
StoreIOState::Pointer storeOpen(StoreEntry *e, StoreIOState::STFNCB *file_callback, StoreIOState::STIOCB *callback, void *callback_data)
Definition: store_io.cc:61
MemObject * mem_obj
Definition: Store.h:213
uint16_t flags
Definition: Store.h:224
struct StatCounters::@138 swap
#define DBG_IMPORTANT
Definition: Debug.h:46
static StoreIOState::STIOCB storeSwapInFileClosed
Definition: store_swapin.cc:18
#define NULL
Definition: types.h:166
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:128
@ ENTRY_VALIDATED
Definition: enums.h:113
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1990
sdirno swap_dirn
Definition: Store.h:230
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:157
void const char HLPCB void * data
Definition: stub_helper.cc:16
#define assert(EX)
Definition: assert.h:19
@ NOT_IN_MEMORY
Definition: enums.h:35
bool swapoutFailed() const
whether we failed to write this entry to disk
Definition: Store.h:128
mem_status_t mem_status
Definition: Store.h:232
static int sc[16]
Definition: smbdes.c:121
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
void storeSwapInStart(store_client *sc)
Definition: store_swapin.cc:22
static StoreIOState::STFNCB storeSwapInFileNotify
Definition: store_swapin.cc:19
const char * getMD5Text() const
Definition: store.cc:205
StatCounters statCounter
Definition: StatCounters.cc:12
sfileno swap_filen
unique ID inside a cache_dir for swapped out entries; -1 for others
Definition: Store.h:228

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors