]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
64-bit disk I/O, using off_t / size_t where appropriate
authorhno <>
Fri, 17 Aug 2007 05:32:28 +0000 (05:32 +0000)
committerhno <>
Fri, 17 Aug 2007 05:32:28 +0000 (05:32 +0000)
src/DiskIO/DiskDaemon/DiskdFile.cc
src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
src/DiskIO/DiskDaemon/DiskdIOStrategy.h
src/DiskIO/DiskDaemon/diomsg.h
src/DiskIO/DiskDaemon/diskd.cc
src/DiskIO/DiskThreads/DiskThreads.h
src/DiskIO/DiskThreads/aiops.cc
src/DiskIO/DiskThreads/aiops_win32.cc
src/DiskIO/DiskThreads/async_io.cc

index ffc69cdd1424405878e49c9878e0248c07392203..82afabe7c4e518e3401a8f107c58b34be58f63d9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskdFile.cc,v 1.3 2007/04/28 22:26:45 hno Exp $
+ * $Id: DiskdFile.cc,v 1.4 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 79    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -92,7 +92,7 @@ DiskdFile::open (int flags, mode_t aMode, IORequestor::Pointer callback)
     ioRequestor = callback;
     assert (callback.getRaw());
     mode = flags;
-    off_t shm_offset;
+    ssize_t shm_offset;
     char *buf = (char *)IO->shm.get(&shm_offset);
     xstrncpy(buf, path_, SHMBUF_BLKSZ);
     ioAway();
@@ -123,7 +123,7 @@ DiskdFile::create (int flags, mode_t aMode, IORequestor::Pointer callback)
     ioRequestor = callback;
     assert (callback.getRaw());
     mode = flags;
-    off_t shm_offset;
+    ssize_t shm_offset;
     char *buf = (char *)IO->shm.get(&shm_offset);
     xstrncpy(buf, path_, SHMBUF_BLKSZ);
     ioAway();
@@ -152,15 +152,15 @@ void
 DiskdFile::read(ReadRequest *aRead)
 {
     assert (ioRequestor.getRaw() != NULL);
-    off_t shm_offset;
+    ssize_t shm_offset;
     char *rbuf = (char *)IO->shm.get(&shm_offset);
     assert(rbuf);
     ioAway();
     int x = IO->send(_MQD_READ,
                      id,
                      this,
-                     (int) aRead->len,
-                     (int) aRead->offset,
+                     aRead->len,
+                     aRead->offset,
                      shm_offset,
                      aRead);
 
@@ -311,7 +311,7 @@ void
 DiskdFile::write(WriteRequest *aRequest)
 {
     debugs(79, 3, "DiskdFile::write: this " << (void *)this << ", buf " << (void *)aRequest->buf << ", off " << aRequest->offset << ", len " << aRequest->len);
-    off_t shm_offset;
+    ssize_t shm_offset;
     char *sbuf = (char *)IO->shm.get(&shm_offset);
     xmemcpy(sbuf, aRequest->buf, aRequest->len);
 
@@ -323,8 +323,8 @@ DiskdFile::write(WriteRequest *aRequest)
     int x = IO->send(_MQD_WRITE,
                      id,
                      this,
-                     (int) aRequest->len,
-                     (int) aRequest->offset,
+                     aRequest->len,
+                     aRequest->offset,
                      shm_offset,
                      aRequest);
 
index 432d3425be16e42f7e4529db1451ef3459f911a2..d73d24c7a1fc9b0379e374fe94fdf39b07e3acbf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskdIOStrategy.cc,v 1.10 2007/04/28 22:26:45 hno Exp $
+ * $Id: DiskdIOStrategy.cc,v 1.11 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 79    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -123,7 +123,7 @@ DiskdIOStrategy::unlinkFile(char const *path)
     /* We can attempt a diskd unlink */
     int x;
 
-    off_t shm_offset;
+    ssize_t shm_offset;
 
     char *buf;
 
@@ -211,7 +211,7 @@ DiskdIOStrategy::init()
  * SHM manipulation routines
  */
 void
-SharedMemory::put (off_t offset)
+SharedMemory::put(ssize_t offset)
 {
     int i;
     assert(offset >= 0);
@@ -225,8 +225,7 @@ SharedMemory::put (off_t offset)
 
 void *
 
-SharedMemory::get
-    (off_t * shm_offset)
+SharedMemory::get(ssize_t * shm_offset)
 {
     char *aBuf = NULL;
     int i;
@@ -345,7 +344,7 @@ DiskdIOStrategy::handle(diomsg * M)
 }
 
 int
-DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, int size, int offset, off_t shm_offset, RefCountable_ *requestor)
+DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, ssize_t shm_offset, RefCountable_ *requestor)
 {
     diomsg M;
     M.callback_data = cbdataReference(theFile);
@@ -360,7 +359,7 @@ DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, int size, int offse
 }
 
 int
-DiskdIOStrategy::send(int mtype, int id, StoreIOState::Pointer sio, int size, int offset, off_t shm_offset)
+DiskdIOStrategy::send(int mtype, int id, StoreIOState::Pointer sio, size_t size, off_t offset, ssize_t shm_offset)
 {
     diomsg M;
     M.callback_data = cbdataReference(sio.getRaw());
@@ -370,7 +369,7 @@ DiskdIOStrategy::send(int mtype, int id, StoreIOState::Pointer sio, int size, in
 }
 
 int
-DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, int size, int offset, off_t shm_offset)
+DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, size_t size, off_t offset, ssize_t shm_offset)
 {
     static int send_errors = 0;
     static int last_seq_no = 0;
index 7d21790b20c87634bb8c75ad37ee7d4555bbfbf0..433dd4b28eeb5ab4aa7c19aaf5a3a0db95d25b9e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskdIOStrategy.h,v 1.3 2007/01/31 07:13:54 wessels Exp $
+ * $Id: DiskdIOStrategy.h,v 1.4 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 79    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -51,12 +51,11 @@ class SharedMemory
 {
 
 public:
-    void put(off_t);
+    void put(ssize_t);
 
-    void *get
-    (off_t *);
+    void *get(ssize_t *);
 
-    void init (int ikey, int magic2);
+    void init(int ikey, int magic2);
 
     int nbufs;
 
@@ -90,7 +89,7 @@ public:
     virtual void sync();
     virtual int callback();
     virtual void statfs(StoreEntry & sentry)const;
-    int send(int mtype, int id, DiskdFile *theFile, int size, int offset, off_t shm_offset, RefCountable_ *);
+    int send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, ssize_t shm_offset, RefCountable_ *);
     /* public for accessing return address's */
     SharedMemory shm;
 
@@ -102,8 +101,8 @@ private:
     void optionQ1Dump(StoreEntry * e) const;
     bool optionQ2Parse(char const *option, const char *value, int reconfiguring);
     void optionQ2Dump(StoreEntry * e) const;
-    int send(int mtype, int id, RefCount<StoreIOState> sio, int size, int offset, off_t shm_offset);
-    int SEND(diomsg * M, int mtype, int id, int size, int offset, off_t shm_offset);
+    int send(int mtype, int id, RefCount<StoreIOState> sio, size_t size, off_t offset, ssize_t shm_offset);
+    int SEND(diomsg * M, int mtype, int id, size_t size, off_t offset, ssize_t shm_offset);
     void handle(diomsg * M);
     void unlinkDone(diomsg * M);
     int magic1;
index c35894e5cc726e3269390ece52f663de2b45bfdd..ebc2d251e18d0d3267102abc6d02368c7346fb19 100644 (file)
@@ -26,8 +26,8 @@ struct diomsg
     int seq_no;
     void * callback_data;
     RefCountable_ * requestor;
-    int size;
-    int offset;
+    size_t size;
+    off_t offset;
     int status;
     bool newstyle;
     int shm_offset;
index ac51d4d89725d46321dafde63767caa2a3867d8f..863552999ba1cd2794de5c95ff00a0bcc0811b38 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: diskd.cc,v 1.7 2007/04/25 16:41:56 wessels Exp $
+ * $Id: diskd.cc,v 1.8 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section --    External DISKD process implementation.
  * AUTHOR: Harvest Derived
@@ -150,11 +150,11 @@ do_read(diomsg * r, int len, char *buf)
 
     if (r->offset > -1 && r->offset != fs->offset) {
         DEBUG(2)
-        fprintf(stderr, "seeking to %d\n", r->offset);
+        fprintf(stderr, "seeking to %"PRId64"\n", (int64_t)r->offset);
 
         if (lseek(fs->fd, r->offset, SEEK_SET) < 0) {
             DEBUG(1) {
-                fprintf(stderr, "%d FD %d, offset %d: ", (int) mypid, fs->fd, r->offset);
+                fprintf(stderr, "%d FD %d, offset %"PRId64": ", (int) mypid, fs->fd, (int64_t)r->offset);
                 perror("lseek");
             }
         }
@@ -162,8 +162,8 @@ do_read(diomsg * r, int len, char *buf)
 
     x = read(fs->fd, buf, readlen);
     DEBUG(2)
-    fprintf(stderr, "%d READ %d,%d,%d ret %d\n", (int) mypid,
-            fs->fd, readlen, r->offset, x);
+    fprintf(stderr, "%d READ %d,%d,%"PRId64" ret %d\n", (int) mypid,
+            fs->fd, readlen, (int64_t)r->offset, x);
 
     if (x < 0) {
         DEBUG(1) {
@@ -199,15 +199,15 @@ do_write(diomsg * r, int len, const char *buf)
     if (r->offset > -1 && r->offset != fs->offset) {
         if (lseek(fs->fd, r->offset, SEEK_SET) < 0) {
             DEBUG(1) {
-                fprintf(stderr, "%d FD %d, offset %d: ", (int) mypid, fs->fd, r->offset);
+                fprintf(stderr, "%d FD %d, offset %"PRId64": ", (int) mypid, fs->fd, (int64_t)r->offset);
                 perror("lseek");
             }
         }
     }
 
     DEBUG(2)
-    fprintf(stderr, "%d WRITE %d,%d,%d\n", (int) mypid,
-            fs->fd, wrtlen, r->offset);
+    fprintf(stderr, "%d WRITE %d,%d,%"PRId64"\n", (int) mypid,
+            fs->fd, wrtlen, (int64_t)r->offset);
     x = write(fs->fd, buf, wrtlen);
 
     if (x < 0) {
index 59933127a0f5b846d924770f6dff8faa3c890b7a..b4dad445f36f2e79a84d7dcfacb45f27392a7a2b 100644 (file)
@@ -67,8 +67,8 @@ void squidaio_init(void);
 void squidaio_shutdown(void);
 int squidaio_cancel(squidaio_result_t *);
 int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
-int squidaio_read(int, char *, int, off_t, int, squidaio_result_t *);
-int squidaio_write(int, char *, int, off_t, int, squidaio_result_t *);
+int squidaio_read(int, char *, size_t, off_t, int, squidaio_result_t *);
+int squidaio_write(int, char *, size_t, off_t, int, squidaio_result_t *);
 int squidaio_close(int, squidaio_result_t *);
 
 int squidaio_stat(const char *, struct stat *, squidaio_result_t *);
@@ -87,8 +87,8 @@ void aioDone(void);
 void aioCancel(int);
 void aioOpen(const char *, int, mode_t, AIOCB *, void *);
 void aioClose(int);
-void aioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *);
-void aioRead(int, int offset, int size, AIOCB *, void *);
+void aioWrite(int, off_t offset, char *, size_t size, AIOCB *, void *, FREE *);
+void aioRead(int, off_t offset, size_t size, AIOCB *, void *);
 
 void aioStat(char *, struct stat *, AIOCB *, void *);
 void aioUnlink(const char *, AIOCB *, void *);
index fbe7a50ed3915d35ff6d97bf9304b5a13d404738..7ba554426ef7df62476f7a03368b489fcf24ab97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.14 2007/04/28 22:26:47 hno Exp $
+ * $Id: aiops.cc,v 1.15 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -76,7 +76,7 @@ typedef struct squidaio_request_t
     mode_t mode;
     int fd;
     char *bufferp;
-    int buflen;
+    size_t buflen;
     off_t offset;
     int whence;
     int ret;
@@ -703,7 +703,7 @@ squidaio_do_open(squidaio_request_t * requestp)
 
 
 int
-squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp)
+squidaio_read(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
 {
     squidaio_request_t *requestp;
 
@@ -743,7 +743,7 @@ squidaio_do_read(squidaio_request_t * requestp)
 
 
 int
-squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp)
+squidaio_write(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
 {
     squidaio_request_t *requestp;
 
index c26ed91ada2b3f41c38db5995433c8a80c0e29f8..4b9d2b1af5d6256cbd6f5b9721bbf67c36cecf43 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops_win32.cc,v 1.4 2007/04/28 22:26:47 hno Exp $
+ * $Id: aiops_win32.cc,v 1.5 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 43    Windows AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -72,7 +72,7 @@ typedef struct squidaio_request_t
     int fd;
     char *bufferp;
     char *tmpbufp;
-    int buflen;
+    size_t buflen;
     off_t offset;
     int whence;
     int ret;
@@ -788,7 +788,7 @@ squidaio_do_open(squidaio_request_t * requestp)
 
 
 int
-squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp)
+squidaio_read(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
 {
     squidaio_request_t *requestp;
 
@@ -834,7 +834,7 @@ squidaio_do_read(squidaio_request_t * requestp)
 
 
 int
-squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp)
+squidaio_write(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
 {
     squidaio_request_t *requestp;
 
index debd24f1d2ae0b0efe5119ede9eeafeaf115eca2..860b4c3e26d633d026d15c736e18bdb8ee44e954 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: async_io.cc,v 1.4 2007/04/28 22:26:47 hno Exp $
+ * $Id: async_io.cc,v 1.5 2007/08/16 23:32:28 hno Exp $
  *
  * DEBUG: section 32    Asynchronous Disk I/O
  * AUTHOR: Pete Bentley <pete@demon.net>
@@ -134,7 +134,7 @@ aioCancel(int fd)
 
 
 void
-aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func)
+aioWrite(int fd, off_t offset, char *bufp, size_t len, AIOCB * callback, void *callback_data, FREE * free_func)
 {
     squidaio_ctrl_t *ctrlp;
     int seekmode;
@@ -163,7 +163,7 @@ aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callba
 
 
 void
-aioRead(int fd, int offset, int len, AIOCB * callback, void *callback_data)
+aioRead(int fd, off_t offset, size_t len, AIOCB * callback, void *callback_data)
 {
     squidaio_ctrl_t *ctrlp;
     int seekmode;