2 * Copyright (C) 1996-2023 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 auto sd
= Store::Disks::SelectSwapDir(e
);
38 debugs(20, 2, "storeCreate: no swapdirs for " << *e
);
39 ++store_io_stats
.create
.select_fail
;
43 /* Now that we have a fs to use, call its storeCreate function */
44 StoreIOState::Pointer sio
= sd
->createStoreIO(*e
, file_callback
, close_callback
, callback_data
);
47 ++store_io_stats
.create
.create_fail
;
49 ++store_io_stats
.create
.success
;
55 * storeOpen() is purely for reading ..
58 storeOpen(StoreEntry
* e
, StoreIOState::STFNCB
* file_callback
, StoreIOState::STIOCB
* callback
,
61 return e
->disk().openStoreIO(*e
, file_callback
, callback
, callback_data
);
65 storeClose(StoreIOState::Pointer sio
, int how
)
67 if (sio
->flags
.closing
) {
68 debugs(20,3, "storeClose: flags.closing already set, bailing");
72 sio
->flags
.closing
= true;
74 debugs(20,3, "storeClose: calling sio->close(" << how
<< ")");
79 storeRead(StoreIOState::Pointer sio
, char *buf
, size_t size
, off_t offset
, StoreIOState::STRCB
* callback
, void *callback_data
)
81 sio
->read_(buf
, size
, offset
, callback
, callback_data
);
85 storeIOWrite(StoreIOState::Pointer sio
, char const *buf
, size_t size
, off_t offset
, FREE
* free_func
)
87 sio
->write(buf
,size
,offset
,free_func
);