]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/fs/rock/RockIoState.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / fs / rock / RockIoState.h
index d797284056bb31fe95ed05b238ab2b83bd51b8e6..d87c3aa9aceb8ee3e4aea36208d8b2b0399552b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -9,8 +9,9 @@
 #ifndef SQUID_FS_ROCK_IO_STATE_H
 #define SQUID_FS_ROCK_IO_STATE_H
 
+#include "fs/rock/forward.h"
 #include "fs/rock/RockSwapDir.h"
-#include "MemBlob.h"
+#include "sbuf/MemBlob.h"
 
 class DiskFile;
 
@@ -41,17 +42,25 @@ public:
     /// whether we are still waiting for the I/O results (i.e., not closed)
     bool stillWaiting() const { return theFile != NULL; }
 
-    /// forwards read data to the reader that initiated this I/O
-    void callReaderBack(const char *buf, int rlen);
+    /// forwards read data (or an error) to the reader that initiated this I/O
+    void handleReadCompletion(Rock::ReadRequest &request, const int rlen, const int errFlag);
 
     /// called by SwapDir::writeCompleted() after the last write and on error
     void finishedWriting(const int errFlag);
 
+    /// notes that the disker has satisfied the given I/O request
+    /// \returns whether all earlier I/O requests have been satisfied already
+    bool expectedReply(const IoXactionId receivedId);
+
     /* one and only one of these will be set and locked; access via *Anchor() */
     const Ipc::StoreMapAnchor *readableAnchor_; ///< starting point for reading
     Ipc::StoreMapAnchor *writeableAnchor_; ///< starting point for writing
 
-    SlotId sidCurrent; ///< ID of the db slot currently being read or written
+    /// the last db slot successfully read or written
+    SlotId splicingPoint;
+    /// when reading, this is the next slot we are going to read (if asked)
+    /// when writing, this is the next slot to use after the last fresh slot
+    SlotId staleSplicingPointNext;
 
 private:
     const Ipc::StoreMapAnchor &readAnchor() const;
@@ -60,16 +69,37 @@ private:
 
     void tryWrite(char const *buf, size_t size, off_t offset);
     size_t writeToBuffer(char const *buf, size_t size);
-    void writeToDisk(const SlotId nextSlot);
-    void writeBufToDisk(const SlotId nextSlot, const bool eof);
-    SlotId reserveSlotForWriting();
+    void writeToDisk();
 
+    void callReaderBack(const char *buf, int rlen);
     void callBack(int errflag);
 
     Rock::SwapDir::Pointer dir; ///< swap dir that initiated I/O
     const size_t slotSize; ///< db cell size
     int64_t objOffset; ///< object offset for current db slot
 
+    /// The very first entry slot. Usually the same as anchor.first,
+    /// but writers set anchor.first only after the first write is done.
+    SlotId sidFirst;
+
+    /// Unused by readers.
+    /// For writers, the slot pointing (via .next) to sidCurrent.
+    SlotId sidPrevious;
+
+    /// For readers, the db slot currently being read from disk.
+    /// For writers, the reserved db slot currently being filled (to be written).
+    SlotId sidCurrent;
+
+    /// Unused by readers.
+    /// For writers, the reserved db slot that sidCurrent.next will point to.
+    SlotId sidNext;
+
+    /// the number of read or write requests we sent to theFile
+    uint64_t requestsSent;
+
+    /// the number of successful responses we received from theFile
+    uint64_t repliesReceived;
+
     RefCount<DiskFile> theFile; // "file" responsible for this I/O
     MemBlob theBuf; // use for write content accumulation only
 };