]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
split async io counters into started and finished to give better visibility on outsta...
authorrobertc <>
Thu, 3 Oct 2002 04:32:22 +0000 (04:32 +0000)
committerrobertc <>
Thu, 3 Oct 2002 04:32:22 +0000 (04:32 +0000)
src/fs/aufs/aiops.cc
src/fs/aufs/async_io.cc
src/fs/aufs/store_asyncufs.h

index 615c2274938d6725386e49303a25acd01518bd1f..fa735a41279ad3523a712f0733416df62e4b2055 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.13 2002/07/21 00:25:45 hno Exp $
+ * $Id: aiops.cc,v 1.14 2002/10/02 22:32:22 robertc Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -58,19 +58,6 @@ enum _squidaio_thread_status {
 };
 typedef enum _squidaio_thread_status squidaio_thread_status;
 
-enum _squidaio_request_type {
-    _AIO_OP_NONE = 0,
-    _AIO_OP_OPEN,
-    _AIO_OP_READ,
-    _AIO_OP_WRITE,
-    _AIO_OP_CLOSE,
-    _AIO_OP_UNLINK,
-    _AIO_OP_TRUNCATE,
-    _AIO_OP_OPENDIR,
-    _AIO_OP_STAT
-};
-typedef enum _squidaio_request_type squidaio_request_type;
-
 typedef struct squidaio_request_t {
     struct squidaio_request_t *next;
     squidaio_request_type request_type;
@@ -283,6 +270,7 @@ squidaio_init(void)
 
     /* Create threads and get them to sit in their wait loop */
     squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));
+    assert (NUMTHREADS);
     for (i = 0; i < NUMTHREADS; i++) {
        threadp = memPoolAlloc(squidaio_thread_pool);
        threadp->status = _THREAD_STARTING;
@@ -552,6 +540,7 @@ squidaio_cancel(squidaio_result_t * resultp)
        request->cancelled = 1;
        request->resultp = NULL;
        resultp->_data = NULL;
+       resultp->result_type = _AIO_OP_NONE;
        return 0;
     }
     return 1;
@@ -572,6 +561,7 @@ squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resu
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_OPEN;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_OPEN;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -603,6 +593,7 @@ squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_r
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_READ;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_READ;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -635,6 +626,7 @@ squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_WRITE;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_WRITE;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -661,6 +653,7 @@ squidaio_close(int fd, squidaio_result_t * resultp)
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_CLOSE;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_CLOSE;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -689,6 +682,7 @@ squidaio_stat(const char *path, struct stat *sb, squidaio_result_t * resultp)
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_STAT;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_STAT;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -715,6 +709,7 @@ squidaio_unlink(const char *path, squidaio_result_t * resultp)
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_UNLINK;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_UNLINK;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -741,6 +736,7 @@ squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp)
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_TRUNCATE;
     requestp->cancelled = 0;
+    resultp->result_type = _AIO_OP_TRUNCATE;
 
     squidaio_queue_request(requestp);
     return 0;
@@ -767,6 +763,7 @@ squidaio_opendir(const char *path, squidaio_result_t * resultp)
     if (!squidaio_initialised)
        squidaio_init();
     requestp = memPoolAlloc(squidaio_request_pool);
+    resultp->result_type = _AIO_OP_OPENDIR;
     return -1;
 }
 
index 98117807b2c188d550453bb8d42298dd7949d5dc..3c9473c8c86cc30f5fc9b9f0124fa65d15da1a2b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: async_io.cc,v 1.14 2002/07/28 11:31:06 robertc Exp $
+ * $Id: async_io.cc,v 1.15 2002/10/02 22:32:22 robertc Exp $
  *
  * DEBUG: section 32    Asynchronous Disk I/O
  * AUTHOR: Pete Bentley <pete@demon.net>
@@ -59,14 +59,20 @@ typedef struct squidaio_ctrl_t {
 } squidaio_ctrl_t;
 
 static struct {
-    int open;
-    int close;
-    int cancel;
-    int write;
-    int read;
-    int stat;
-    int unlink;
-    int check_callback;
+     int open_start;
+     int open_finish;
+     int close_start;
+     int close_finish;
+     int cancel;
+     int write_start;
+     int write_finish;
+     int read_start;
+     int read_finish;
+     int stat_start;
+     int stat_finish;
+     int unlink_start;
+     int unlink_finish;
+     int check_callback;
 } squidaio_counts;
 
 typedef struct squidaio_unlinkq_t {
@@ -112,7 +118,7 @@ aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callba
     squidaio_ctrl_t *ctrlp;
 
     assert(initialised);
-    squidaio_counts.open++;
+    squidaio_counts.open_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = -2;
     ctrlp->done_handler = callback;
@@ -130,7 +136,7 @@ aioClose(int fd)
     squidaio_ctrl_t *ctrlp;
 
     assert(initialised);
-    squidaio_counts.close++;
+    squidaio_counts.close_start++;
     aioCancel(fd);
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = fd;
@@ -180,7 +186,7 @@ aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callba
     int seekmode;
 
     assert(initialised);
-    squidaio_counts.write++;
+    squidaio_counts.write_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = fd;
     ctrlp->done_handler = callback;
@@ -207,7 +213,7 @@ aioRead(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callbac
     int seekmode;
 
     assert(initialised);
-    squidaio_counts.read++;
+    squidaio_counts.read_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = fd;
     ctrlp->done_handler = callback;
@@ -231,7 +237,7 @@ aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data)
     squidaio_ctrl_t *ctrlp;
 
     assert(initialised);
-    squidaio_counts.stat++;
+    squidaio_counts.stat_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = -2;
     ctrlp->done_handler = callback;
@@ -248,7 +254,7 @@ aioUnlink(const char *path, AIOCB * callback, void *callback_data)
 {
     squidaio_ctrl_t *ctrlp;
     assert(initialised);
-    squidaio_counts.unlink++;
+    squidaio_counts.unlink_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = -2;
     ctrlp->done_handler = callback;
@@ -264,7 +270,7 @@ aioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_dat
 {
     squidaio_ctrl_t *ctrlp;
     assert(initialised);
-    squidaio_counts.unlink++;
+    squidaio_counts.unlink_start++;
     ctrlp = memPoolAlloc(squidaio_ctrl_pool);
     ctrlp->fd = -2;
     ctrlp->done_handler = callback;
@@ -289,6 +295,30 @@ aioCheckCallbacks(SwapDir * SD)
        if ((resultp = squidaio_poll_done()) == NULL)
            break;
        ctrlp = (squidaio_ctrl_t *) resultp->data;
+       switch (resultp->result_type){
+           case _AIO_OP_NONE:
+           case _AIO_OP_TRUNCATE:
+           case _AIO_OP_OPENDIR:
+                break;
+           case _AIO_OP_OPEN:
+                ++squidaio_counts.open_finish;
+                break;
+           case _AIO_OP_READ:
+                ++squidaio_counts.read_finish;
+                break;
+           case _AIO_OP_WRITE:
+                ++squidaio_counts.write_finish;
+                break;
+           case _AIO_OP_CLOSE:
+                ++squidaio_counts.close_finish;
+                break;
+           case _AIO_OP_UNLINK:
+                ++squidaio_counts.unlink_finish;
+                break;
+           case _AIO_OP_STAT:
+                ++squidaio_counts.stat_finish;
+                break;
+       }
        if (ctrlp == NULL)
            continue;           /* XXX Should not happen */
        dlinkDelete(&ctrlp->node, &used_list);
@@ -316,16 +346,16 @@ void
 aioStats(StoreEntry * sentry)
 {
     storeAppendPrintf(sentry, "ASYNC IO Counters:\n");
-    storeAppendPrintf(sentry, "Operation\t# Requests\n");
-    storeAppendPrintf(sentry, "open\t%d\n", squidaio_counts.open);
-    storeAppendPrintf(sentry, "close\t%d\n", squidaio_counts.close);
-    storeAppendPrintf(sentry, "cancel\t%d\n", squidaio_counts.cancel);
-    storeAppendPrintf(sentry, "write\t%d\n", squidaio_counts.write);
-    storeAppendPrintf(sentry, "read\t%d\n", squidaio_counts.read);
-    storeAppendPrintf(sentry, "stat\t%d\n", squidaio_counts.stat);
-    storeAppendPrintf(sentry, "unlink\t%d\n", squidaio_counts.unlink);
-    storeAppendPrintf(sentry, "check_callback\t%d\n", squidaio_counts.check_callback);
-    storeAppendPrintf(sentry, "queue\t%d\n", squidaio_get_queue_len());
+    storeAppendPrintf(sentry, "Operation\t# Requests\tNumber serviced\n");
+    storeAppendPrintf(sentry, "open\t%d\t%d\n", squidaio_counts.open_start,squidaio_counts.open_finish);
+    storeAppendPrintf(sentry, "close\t%d\t%d\n", squidaio_counts.close_start,squidaio_counts.close_finish);
+    storeAppendPrintf(sentry, "cancel\t%d\t-\n", squidaio_counts.cancel);
+    storeAppendPrintf(sentry, "write\t%d\t%d\n", squidaio_counts.write_start,squidaio_counts.write_finish);
+    storeAppendPrintf(sentry, "read\t%d\t%d\n", squidaio_counts.read_start,squidaio_counts.read_finish);
+    storeAppendPrintf(sentry, "stat\t%d\t%d\n", squidaio_counts.stat_start,squidaio_counts.stat_finish);
+    storeAppendPrintf(sentry, "unlink\t%d\t%d\n", squidaio_counts.unlink_start,squidaio_counts.unlink_finish);
+    storeAppendPrintf(sentry, "check_callback\t%d\t-\n", squidaio_counts.check_callback);
+    storeAppendPrintf(sentry, "queue\t%d\t-\n", squidaio_get_queue_len());
 }
 
 /* Flush all pending I/O */
index 34494a79f6365b8d34f438948f85c0e2bdefe5e7..83250e3f70be1cc06f9a2b27ed578fae3c73e9cb 100644 (file)
 #define ASYNC_WRITE 0
 #define ASYNC_READ 1
 
+enum _squidaio_request_type {
+    _AIO_OP_NONE = 0,
+    _AIO_OP_OPEN,
+    _AIO_OP_READ,
+    _AIO_OP_WRITE,
+    _AIO_OP_CLOSE,
+    _AIO_OP_UNLINK,
+    _AIO_OP_TRUNCATE,
+    _AIO_OP_OPENDIR,
+    _AIO_OP_STAT
+};
+typedef enum _squidaio_request_type squidaio_request_type;
+
 struct _squidaio_result_t {
     int aio_return;
     int aio_errno;
+    enum _squidaio_request_type result_type;
     void *_data;               /* Internal housekeeping */
     void *data;                        /* Available to the caller */
 };