3 * $Id: store_swapin.cc,v 1.23 2000/05/03 17:15:44 adrian Exp $
5 * DEBUG: section 20 Storage Manager Swapin Functions
6 * AUTHOR: Duane Wessels
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by the
14 * National Science Foundation. Squid is Copyrighted (C) 1998 by
15 * the Regents of the University of California. Please see the
16 * COPYRIGHT file for full details. Squid incorporates software
17 * developed and/or copyrighted by other sources. Please see the
18 * CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
38 static STIOCB storeSwapInFileClosed
;
39 static STFNCB storeSwapInFileNotify
;
42 storeSwapInStart(store_client
* sc
)
44 StoreEntry
*e
= sc
->entry
;
45 assert(e
->mem_status
== NOT_IN_MEMORY
);
46 if (!EBIT_TEST(e
->flags
, ENTRY_VALIDATED
)) {
47 /* We're still reloading and haven't validated this entry yet */
50 debug(20, 3) ("storeSwapInStart: called for %d %08X %s \n",
51 e
->swap_dirn
, e
->swap_filen
, storeKeyText(e
->key
));
52 if (e
->swap_status
!= SWAPOUT_WRITING
&& e
->swap_status
!= SWAPOUT_DONE
) {
53 debug(20, 1) ("storeSwapInStart: bad swap_status (%s)\n",
54 swapStatusStr
[e
->swap_status
]);
57 if (e
->swap_filen
< 0) {
58 debug(20, 1) ("storeSwapInStart: swap_filen < 0\n");
61 assert(e
->mem_obj
!= NULL
);
62 debug(20, 3) ("storeSwapInStart: Opening fileno %08X\n",
64 sc
->swapin_sio
= storeOpen(e
, storeSwapInFileNotify
, storeSwapInFileClosed
,
66 cbdataLock(sc
->swapin_sio
);
70 storeSwapInFileClosed(void *data
, int errflag
, storeIOState
* sio
)
72 store_client
*sc
= data
;
74 debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n",
77 sc
->swapin_sio
= NULL
;
78 if ((callback
= sc
->callback
)) {
81 callback(sc
->callback_data
, sc
->copy_buf
, errflag
);
86 storeSwapInFileNotify(void *data
, int errflag
, storeIOState
* sio
)
88 store_client
*sc
= data
;
89 StoreEntry
*e
= sc
->entry
;
91 debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e
->swap_filen
, e
->swap_dirn
, sio
->swap_filen
, sio
->swap_dirn
);
93 e
->swap_filen
= sio
->swap_filen
;
94 e
->swap_dirn
= sio
->swap_dirn
;