]>
Commit | Line | Data |
---|---|---|
9cef6668 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
9cef6668 | 3 | * |
bbc27441 AJ |
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. | |
9cef6668 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 20 Storage Manager Swapin Functions */ |
10 | ||
582c2af2 FC |
11 | #include "squid.h" |
12 | #include "globals.h" | |
e4f1fdae | 13 | #include "StatCounters.h" |
e6ccf245 | 14 | #include "Store.h" |
f82b5c64 | 15 | #include "store_swapin.h" |
602d9612 | 16 | #include "StoreClient.h" |
f09f5b26 | 17 | |
4fcc8876 | 18 | static StoreIOState::STIOCB storeSwapInFileClosed; |
19 | static StoreIOState::STFNCB storeSwapInFileNotify; | |
2391a162 | 20 | |
1f38f50a | 21 | void |
22 | storeSwapInStart(store_client * sc) | |
f09f5b26 | 23 | { |
1f38f50a | 24 | StoreEntry *e = sc->entry; |
62e76326 | 25 | |
d46a87a8 | 26 | if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) { |
62e76326 | 27 | /* We're still reloading and haven't validated this entry yet */ |
28 | return; | |
f09f5b26 | 29 | } |
62e76326 | 30 | |
e2851fe7 AR |
31 | if (e->mem_status != NOT_IN_MEMORY) |
32 | debugs(20, 3, HERE << "already IN_MEMORY"); | |
33 | ||
4310f8b0 | 34 | debugs(20, 3, *e << " " << e->getMD5Text()); |
62e76326 | 35 | |
4310f8b0 EB |
36 | if (!e->hasDisk()) { |
37 | debugs(20, DBG_IMPORTANT, "BUG: Attempt to swap in a not-stored entry " << *e << ". Salvaged."); | |
62e76326 | 38 | return; |
5bd1abac | 39 | } |
62e76326 | 40 | |
02ba667b EB |
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 | ||
f09f5b26 | 46 | assert(e->mem_obj != NULL); |
d3b3ab85 | 47 | sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed, sc); |
f09f5b26 | 48 | } |
49 | ||
2391a162 | 50 | static void |
ced8def3 | 51 | storeSwapInFileClosed(void *data, int errflag, StoreIOState::Pointer) |
f09f5b26 | 52 | { |
e6ccf245 | 53 | store_client *sc = (store_client *)data; |
bf8fe701 | 54 | debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag); |
d3b3ab85 | 55 | sc->swapin_sio = NULL; |
62e76326 | 56 | |
d23511c0 | 57 | if (sc->_callback.pending()) { |
62e76326 | 58 | assert (errflag <= 0); |
528b2c61 | 59 | sc->callback(0, errflag ? true : false); |
9bc73deb | 60 | } |
62e76326 | 61 | |
e4f1fdae | 62 | ++statCounter.swap.ins; |
f09f5b26 | 63 | } |
cd748f27 | 64 | |
65 | static void | |
ced8def3 | 66 | storeSwapInFileNotify(void *data, int, StoreIOState::Pointer) |
cd748f27 | 67 | { |
e6ccf245 | 68 | store_client *sc = (store_client *)data; |
a4b8110e | 69 | StoreEntry *e = sc->entry; |
70 | ||
bf8fe701 | 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); | |
cd748f27 | 74 | |
f58bb2f4 | 75 | assert(e->swap_filen < 0); // if this fails, call SwapDir::disconnect(e) |
e877aaac | 76 | e->swap_filen = sc->swapin_sio->swap_filen; |
77 | e->swap_dirn = sc->swapin_sio->swap_dirn; | |
cd748f27 | 78 | } |
f53969cc | 79 |