]>
Commit | Line | Data |
---|---|---|
9cef6668 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 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 | ||
26ac0430 AJ |
34 | debugs(20, 3, "storeSwapInStart: called for : " << e->swap_dirn << " " << |
35 | std::hex << std::setw(8) << std::setfill('0') << std::uppercase << | |
bf8fe701 | 36 | e->swap_filen << " " << e->getMD5Text()); |
62e76326 | 37 | |
5bd1abac | 38 | if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) { |
e0236918 | 39 | debugs(20, DBG_IMPORTANT, "storeSwapInStart: bad swap_status (" << swapStatusStr[e->swap_status] << ")"); |
62e76326 | 40 | return; |
5bd1abac | 41 | } |
62e76326 | 42 | |
cd748f27 | 43 | if (e->swap_filen < 0) { |
e0236918 | 44 | debugs(20, DBG_IMPORTANT, "storeSwapInStart: swap_filen < 0"); |
62e76326 | 45 | return; |
5bd1abac | 46 | } |
62e76326 | 47 | |
f09f5b26 | 48 | assert(e->mem_obj != NULL); |
bf8fe701 | 49 | debugs(20, 3, "storeSwapInStart: Opening fileno " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << e->swap_filen); |
d3b3ab85 | 50 | sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed, sc); |
f09f5b26 | 51 | } |
52 | ||
2391a162 | 53 | static void |
e5de8b13 | 54 | storeSwapInFileClosed(void *data, int errflag, StoreIOState::Pointer self) |
f09f5b26 | 55 | { |
e6ccf245 | 56 | store_client *sc = (store_client *)data; |
bf8fe701 | 57 | debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag); |
d3b3ab85 | 58 | sc->swapin_sio = NULL; |
62e76326 | 59 | |
d23511c0 | 60 | if (sc->_callback.pending()) { |
62e76326 | 61 | assert (errflag <= 0); |
528b2c61 | 62 | sc->callback(0, errflag ? true : false); |
9bc73deb | 63 | } |
62e76326 | 64 | |
e4f1fdae | 65 | ++statCounter.swap.ins; |
f09f5b26 | 66 | } |
cd748f27 | 67 | |
68 | static void | |
e5de8b13 | 69 | storeSwapInFileNotify(void *data, int errflag, StoreIOState::Pointer self) |
cd748f27 | 70 | { |
e6ccf245 | 71 | store_client *sc = (store_client *)data; |
a4b8110e | 72 | StoreEntry *e = sc->entry; |
73 | ||
bf8fe701 | 74 | debugs(1, 3, "storeSwapInFileNotify: changing " << e->swap_filen << "/" << |
75 | e->swap_dirn << " to " << sc->swapin_sio->swap_filen << "/" << | |
76 | sc->swapin_sio->swap_dirn); | |
cd748f27 | 77 | |
f58bb2f4 | 78 | assert(e->swap_filen < 0); // if this fails, call SwapDir::disconnect(e) |
e877aaac | 79 | e->swap_filen = sc->swapin_sio->swap_filen; |
80 | e->swap_dirn = sc->swapin_sio->swap_dirn; | |
cd748f27 | 81 | } |
f53969cc | 82 |