2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
10 #include "MemObject.h"
11 #include "SquidConfig.h"
13 #include "store/Disk.h"
14 #include "store/Disks.h"
16 StoreIoStats store_io_stats
;
19 * submit a request to create a cache object for writing.
20 * The StoreEntry structure is sent as a hint to the filesystem
21 * to what will be stored in this object, to allow the filesystem
22 * to select different polices depending on object size or type.
25 storeCreate(StoreEntry
* e
, StoreIOState::STFNCB
* file_callback
, StoreIOState::STIOCB
* close_callback
, void *callback_data
)
29 ++store_io_stats
.create
.calls
;
33 * We assume that the header has been packed by now ..
35 const sdirno dirn
= storeDirSelectSwapDir(e
);
38 debugs(20, 2, "storeCreate: no swapdirs for " << *e
);
39 ++store_io_stats
.create
.select_fail
;
43 debugs(20, 2, "storeCreate: Selected dir " << dirn
<< " for " << *e
);
44 SwapDir
*SD
= dynamic_cast<SwapDir
*>(INDEXSD(dirn
));
46 /* Now that we have a fs to use, call its storeCreate function */
47 StoreIOState::Pointer sio
= SD
->createStoreIO(*e
, file_callback
, close_callback
, callback_data
);
50 ++store_io_stats
.create
.create_fail
;
52 ++store_io_stats
.create
.success
;
58 * storeOpen() is purely for reading ..
61 storeOpen(StoreEntry
* e
, StoreIOState::STFNCB
* file_callback
, StoreIOState::STIOCB
* callback
,
64 return e
->disk().openStoreIO(*e
, file_callback
, callback
, callback_data
);
68 storeClose(StoreIOState::Pointer sio
, int how
)
70 if (sio
->flags
.closing
) {
71 debugs(20,3,HERE
<< "storeClose: flags.closing already set, bailing");
75 sio
->flags
.closing
= true;
77 debugs(20,3,HERE
<< "storeClose: calling sio->close(" << how
<< ")");
82 storeRead(StoreIOState::Pointer sio
, char *buf
, size_t size
, off_t offset
, StoreIOState::STRCB
* callback
, void *callback_data
)
84 sio
->read_(buf
, size
, offset
, callback
, callback_data
);
88 storeIOWrite(StoreIOState::Pointer sio
, char const *buf
, size_t size
, off_t offset
, FREE
* free_func
)
90 sio
->write(buf
,size
,offset
,free_func
);