store_swapin.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 
19 
20 void
22 {
23  StoreEntry *e = sc->entry;
24 
25  if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
26  /* We're still reloading and haven't validated this entry yet */
27  return;
28  }
29 
30  if (e->mem_status != NOT_IN_MEMORY)
31  debugs(20, 3, "already IN_MEMORY");
32 
33  debugs(20, 3, *e << " " << e->getMD5Text());
34 
35  if (!e->hasDisk()) {
36  debugs(20, DBG_IMPORTANT, "ERROR: Squid BUG: Attempt to swap in a not-stored entry " << *e << ". Salvaged.");
37  return;
38  }
39 
40  if (e->swapoutFailed()) {
41  debugs(20, DBG_IMPORTANT, "ERROR: Squid BUG: Attempt to swap in a failed-to-store entry " << *e << ". Salvaged.");
42  return;
43  }
44 
45  assert(e->mem_obj != nullptr);
46  sc->swapin_sio = storeOpen(e, storeSwapInFileClosed, sc);
47 }
48 
49 static void
51 {
52  store_client *sc = (store_client *)data;
53  debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag);
54  sc->swapin_sio = nullptr;
55 
56  if (sc->_callback.pending()) {
57  assert (errflag <= 0);
58  sc->noteSwapInDone(errflag);
59  }
60 
62 }
63 
struct StatCounters::@120 swap
MemObject * mem_obj
Definition: Store.h:220
@ ENTRY_VALIDATED
Definition: enums.h:108
uint16_t flags
Definition: Store.h:231
static StoreIOState::STIOCB storeSwapInFileClosed
Definition: store_swapin.cc:18
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1929
#define EBIT_TEST(flag, bit)
Definition: defines.h:67
#define assert(EX)
Definition: assert.h:17
@ NOT_IN_MEMORY
Definition: enums.h:30
bool swapoutFailed() const
whether we failed to write this entry to disk
Definition: Store.h:137
mem_status_t mem_status
Definition: Store.h:239
static int sc[16]
Definition: smbdes.c:121
StoreIOState::Pointer storeOpen(StoreEntry *e, StoreIOState::STIOCB *callback, void *callback_data)
Definition: store_io.cc:58
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
#define DBG_IMPORTANT
Definition: Stream.h:38
void storeSwapInStart(store_client *sc)
Definition: store_swapin.cc:21
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:192
const char * getMD5Text() const
Definition: store.cc:207
StatCounters statCounter
Definition: StatCounters.cc:12

 

Introduction

Documentation

Support

Miscellaneous