2 * DEBUG: section 20 Storage Manager Swapin Functions
3 * AUTHOR: Duane Wessels
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
35 #include "StatCounters.h"
36 #include "StoreClient.h"
38 #include "store_swapin.h"
40 static StoreIOState::STIOCB storeSwapInFileClosed
;
41 static StoreIOState::STFNCB storeSwapInFileNotify
;
44 storeSwapInStart(store_client
* sc
)
46 StoreEntry
*e
= sc
->entry
;
48 if (!EBIT_TEST(e
->flags
, ENTRY_VALIDATED
)) {
49 /* We're still reloading and haven't validated this entry yet */
53 if (e
->mem_status
!= NOT_IN_MEMORY
)
54 debugs(20, 3, HERE
<< "already IN_MEMORY");
56 debugs(20, 3, "storeSwapInStart: called for : " << e
->swap_dirn
<< " " <<
57 std::hex
<< std::setw(8) << std::setfill('0') << std::uppercase
<<
58 e
->swap_filen
<< " " << e
->getMD5Text());
60 if (e
->swap_status
!= SWAPOUT_WRITING
&& e
->swap_status
!= SWAPOUT_DONE
) {
61 debugs(20, DBG_IMPORTANT
, "storeSwapInStart: bad swap_status (" << swapStatusStr
[e
->swap_status
] << ")");
65 if (e
->swap_filen
< 0) {
66 debugs(20, DBG_IMPORTANT
, "storeSwapInStart: swap_filen < 0");
70 assert(e
->mem_obj
!= NULL
);
71 debugs(20, 3, "storeSwapInStart: Opening fileno " << std::hex
<< std::setw(8) << std::setfill('0') << std::uppercase
<< e
->swap_filen
);
72 sc
->swapin_sio
= storeOpen(e
, storeSwapInFileNotify
, storeSwapInFileClosed
, sc
);
76 storeSwapInFileClosed(void *data
, int errflag
, StoreIOState::Pointer self
)
78 store_client
*sc
= (store_client
*)data
;
79 debugs(20, 3, "storeSwapInFileClosed: sio=" << sc
->swapin_sio
.getRaw() << ", errflag=" << errflag
);
80 sc
->swapin_sio
= NULL
;
82 if (sc
->_callback
.pending()) {
83 assert (errflag
<= 0);
84 sc
->callback(0, errflag
? true : false);
87 ++statCounter
.swap
.ins
;
91 storeSwapInFileNotify(void *data
, int errflag
, StoreIOState::Pointer self
)
93 store_client
*sc
= (store_client
*)data
;
94 StoreEntry
*e
= sc
->entry
;
96 debugs(1, 3, "storeSwapInFileNotify: changing " << e
->swap_filen
<< "/" <<
97 e
->swap_dirn
<< " to " << sc
->swapin_sio
->swap_filen
<< "/" <<
98 sc
->swapin_sio
->swap_dirn
);
100 assert(e
->swap_filen
< 0); // if this fails, call SwapDir::disconnect(e)
101 e
->swap_filen
= sc
->swapin_sio
->swap_filen
;
102 e
->swap_dirn
= sc
->swapin_sio
->swap_dirn
;