diff -rNu 0/squid-2.4.STABLE2/src/fs/aufs/aiops.c 1/squid-2.4.STABLE2/src/fs/aufs/aiops.c --- 0/squid-2.4.STABLE2/src/fs/aufs/aiops.c Fri Jan 12 02:52:00 2001 +++ 1/squid-2.4.STABLE2/src/fs/aufs/aiops.c Mon Sep 17 13:37:09 2001 @@ -1,5 +1,5 @@ /* - * $Id: aiops.c,v 1.4.2.3 2001/01/12 00:52:00 wessels Exp $ + * $Id: squidaiops.c,v 1.4.2.3 2001/01/12 00:52:00 wessels Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -49,7 +49,7 @@ #define RIDICULOUS_LENGTH 4096 -enum _aio_thread_status { +enum _squidaio_thread_status { _THREAD_STARTING = 0, _THREAD_WAITING, _THREAD_BUSY, @@ -57,7 +57,7 @@ _THREAD_DONE }; -enum _aio_request_type { +enum _squidaio_request_type { _AIO_OP_NONE = 0, _AIO_OP_OPEN, _AIO_OP_READ, @@ -69,9 +69,9 @@ _AIO_OP_STAT }; -typedef struct aio_request_t { - struct aio_request_t *next; - enum _aio_request_type request_type; +typedef struct squidaio_request_t { + struct squidaio_request_t *next; + enum _squidaio_request_type request_type; int cancelled; char *path; int oflag; @@ -86,57 +86,57 @@ int err; struct stat *tmpstatp; struct stat *statp; - aio_result_t *resultp; -} aio_request_t; + squidaio_result_t *resultp; +} squidaio_request_t; -typedef struct aio_request_queue_t { +typedef struct squidaio_request_queue_t { pthread_mutex_t mutex; pthread_cond_t cond; - aio_request_t *volatile head; - aio_request_t *volatile *volatile tailp; + squidaio_request_t *volatile head; + squidaio_request_t *volatile *volatile tailp; unsigned long requests; unsigned long blocked; /* main failed to lock the queue */ -} aio_request_queue_t; +} squidaio_request_queue_t; -typedef struct aio_thread_t aio_thread_t; -struct aio_thread_t { - aio_thread_t *next; +typedef struct squidaio_thread_t squidaio_thread_t; +struct squidaio_thread_t { + squidaio_thread_t *next; pthread_t thread; - enum _aio_thread_status status; - struct aio_request_t *current_req; + enum _squidaio_thread_status status; + struct squidaio_request_t *current_req; unsigned long requests; }; -int aio_cancel(aio_result_t *); -int aio_open(const char *, int, mode_t, aio_result_t *); -int aio_read(int, char *, int, off_t, int, aio_result_t *); -int aio_write(int, char *, int, off_t, int, aio_result_t *); -int aio_close(int, aio_result_t *); -int aio_unlink(const char *, aio_result_t *); -int aio_truncate(const char *, off_t length, aio_result_t *); -int aio_opendir(const char *, aio_result_t *); -aio_result_t *aio_poll_done(); -int aio_sync(void); - -static void aio_init(void); -static void aio_queue_request(aio_request_t *); -static void aio_cleanup_request(aio_request_t *); -static void *aio_thread_loop(void *); -static void aio_do_open(aio_request_t *); -static void aio_do_read(aio_request_t *); -static void aio_do_write(aio_request_t *); -static void aio_do_close(aio_request_t *); -static void aio_do_stat(aio_request_t *); -static void aio_do_unlink(aio_request_t *); -static void aio_do_truncate(aio_request_t *); +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_close(int, squidaio_result_t *); +int squidaio_unlink(const char *, squidaio_result_t *); +int squidaio_truncate(const char *, off_t length, squidaio_result_t *); +int squidaio_opendir(const char *, squidaio_result_t *); +squidaio_result_t *squidaio_poll_done(); +int squidaio_sync(void); + +static void squidaio_init(void); +static void squidaio_queue_request(squidaio_request_t *); +static void squidaio_cleanup_request(squidaio_request_t *); +static void *squidaio_thread_loop(void *); +static void squidaio_do_open(squidaio_request_t *); +static void squidaio_do_read(squidaio_request_t *); +static void squidaio_do_write(squidaio_request_t *); +static void squidaio_do_close(squidaio_request_t *); +static void squidaio_do_stat(squidaio_request_t *); +static void squidaio_do_unlink(squidaio_request_t *); +static void squidaio_do_truncate(squidaio_request_t *); #if AIO_OPENDIR -static void *aio_do_opendir(aio_request_t *); +static void *squidaio_do_opendir(squidaio_request_t *); #endif -static void aio_debug(aio_request_t *); -static void aio_poll_queues(void); +static void squidaio_debug(squidaio_request_t *); +static void squidaio_poll_queues(void); -static aio_thread_t *threads = NULL; -static int aio_initialised = 0; +static squidaio_thread_t *threads = NULL; +static int squidaio_initialised = 0; #define AIO_LARGE_BUFS 16384 @@ -145,25 +145,25 @@ #define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3 #define AIO_MICRO_BUFS 128 -static MemPool *aio_large_bufs = NULL; /* 16K */ -static MemPool *aio_medium_bufs = NULL; /* 8K */ -static MemPool *aio_small_bufs = NULL; /* 4K */ -static MemPool *aio_tiny_bufs = NULL; /* 2K */ -static MemPool *aio_micro_bufs = NULL; /* 128K */ +static MemPool *squidaio_large_bufs = NULL; /* 16K */ +static MemPool *squidaio_medium_bufs = NULL; /* 8K */ +static MemPool *squidaio_small_bufs = NULL; /* 4K */ +static MemPool *squidaio_tiny_bufs = NULL; /* 2K */ +static MemPool *squidaio_micro_bufs = NULL; /* 128K */ static int request_queue_len = 0; -static MemPool *aio_request_pool = NULL; -static MemPool *aio_thread_pool = NULL; -static aio_request_queue_t request_queue; +static MemPool *squidaio_request_pool = NULL; +static MemPool *squidaio_thread_pool = NULL; +static squidaio_request_queue_t request_queue; static struct { - aio_request_t *head, **tailp; + squidaio_request_t *head, **tailp; } request_queue2 = { NULL, &request_queue2.head }; -static aio_request_queue_t done_queue; +static squidaio_request_queue_t done_queue; static struct { - aio_request_t *head, **tailp; + squidaio_request_t *head, **tailp; } done_requests = { NULL, &done_requests.head @@ -173,32 +173,32 @@ static pthread_t main_thread; static MemPool * -aio_get_pool(int size) +squidaio_get_pool(int size) { MemPool *p; if (size <= AIO_LARGE_BUFS) { if (size <= AIO_MICRO_BUFS) - p = aio_micro_bufs; + p = squidaio_micro_bufs; else if (size <= AIO_TINY_BUFS) - p = aio_tiny_bufs; + p = squidaio_tiny_bufs; else if (size <= AIO_SMALL_BUFS) - p = aio_small_bufs; + p = squidaio_small_bufs; else if (size <= AIO_MEDIUM_BUFS) - p = aio_medium_bufs; + p = squidaio_medium_bufs; else - p = aio_large_bufs; + p = squidaio_large_bufs; } else p = NULL; return p; } static void * -aio_xmalloc(int size) +squidaio_xmalloc(int size) { void *p; MemPool *pool; - if ((pool = aio_get_pool(size)) != NULL) { + if ((pool = squidaio_get_pool(size)) != NULL) { p = memPoolAlloc(pool); } else p = xmalloc(size); @@ -207,47 +207,47 @@ } static char * -aio_xstrdup(const char *str) +squidaio_xstrdup(const char *str) { char *p; int len = strlen(str) + 1; - p = aio_xmalloc(len); + p = squidaio_xmalloc(len); strncpy(p, str, len); return p; } static void -aio_xfree(void *p, int size) +squidaio_xfree(void *p, int size) { MemPool *pool; - if ((pool = aio_get_pool(size)) != NULL) { + if ((pool = squidaio_get_pool(size)) != NULL) { memPoolFree(pool, p); } else xfree(p); } static void -aio_xstrfree(char *str) +squidaio_xstrfree(char *str) { MemPool *pool; int len = strlen(str) + 1; - if ((pool = aio_get_pool(len)) != NULL) { + if ((pool = squidaio_get_pool(len)) != NULL) { memPoolFree(pool, str); } else xfree(str); } static void -aio_init(void) +squidaio_init(void) { int i; - aio_thread_t *threadp; + squidaio_thread_t *threadp; - if (aio_initialised) + if (squidaio_initialised) return; pthread_attr_init(&globattr); @@ -285,15 +285,15 @@ done_queue.blocked = 0; /* Create threads and get them to sit in their wait loop */ - aio_thread_pool = memPoolCreate("aio_thread", sizeof(aio_thread_t)); + squidaio_thread_pool = memPoolCreate("squidaio_thread", sizeof(squidaio_thread_t)); for (i = 0; i < NUMTHREADS; i++) { - threadp = memPoolAlloc(aio_thread_pool); + threadp = memPoolAlloc(squidaio_thread_pool); threadp->status = _THREAD_STARTING; threadp->current_req = NULL; threadp->requests = 0; threadp->next = threads; threads = threadp; - if (pthread_create(&threadp->thread, &globattr, aio_thread_loop, threadp)) { + if (pthread_create(&threadp->thread, &globattr, squidaio_thread_loop, threadp)) { fprintf(stderr, "Thread creation failed\n"); threadp->status = _THREAD_FAILED; continue; @@ -301,22 +301,22 @@ } /* Create request pool */ - aio_request_pool = memPoolCreate("aio_request", sizeof(aio_request_t)); - aio_large_bufs = memPoolCreate("aio_large_bufs", AIO_LARGE_BUFS); - aio_medium_bufs = memPoolCreate("aio_medium_bufs", AIO_MEDIUM_BUFS); - aio_small_bufs = memPoolCreate("aio_small_bufs", AIO_SMALL_BUFS); - aio_tiny_bufs = memPoolCreate("aio_tiny_bufs", AIO_TINY_BUFS); - aio_micro_bufs = memPoolCreate("aio_micro_bufs", AIO_MICRO_BUFS); + squidaio_request_pool = memPoolCreate("squidaio_request", sizeof(squidaio_request_t)); + squidaio_large_bufs = memPoolCreate("squidaio_large_bufs", AIO_LARGE_BUFS); + squidaio_medium_bufs = memPoolCreate("squidaio_medium_bufs", AIO_MEDIUM_BUFS); + squidaio_small_bufs = memPoolCreate("squidaio_small_bufs", AIO_SMALL_BUFS); + squidaio_tiny_bufs = memPoolCreate("squidaio_tiny_bufs", AIO_TINY_BUFS); + squidaio_micro_bufs = memPoolCreate("squidaio_micro_bufs", AIO_MICRO_BUFS); - aio_initialised = 1; + squidaio_initialised = 1; } static void * -aio_thread_loop(void *ptr) +squidaio_thread_loop(void *ptr) { - aio_thread_t *threadp = ptr; - aio_request_t *request; + squidaio_thread_t *threadp = ptr; + squidaio_request_t *request; sigset_t new; /* @@ -364,30 +364,30 @@ if (!request->cancelled) { switch (request->request_type) { case _AIO_OP_OPEN: - aio_do_open(request); + squidaio_do_open(request); break; case _AIO_OP_READ: - aio_do_read(request); + squidaio_do_read(request); break; case _AIO_OP_WRITE: - aio_do_write(request); + squidaio_do_write(request); break; case _AIO_OP_CLOSE: - aio_do_close(request); + squidaio_do_close(request); break; case _AIO_OP_UNLINK: - aio_do_unlink(request); + squidaio_do_unlink(request); break; case _AIO_OP_TRUNCATE: - aio_do_truncate(request); + squidaio_do_truncate(request); break; #if AIO_OPENDIR /* Opendir not implemented yet */ case _AIO_OP_OPENDIR: - aio_do_opendir(request); + squidaio_do_opendir(request); break; #endif case _AIO_OP_STAT: - aio_do_stat(request); + squidaio_do_stat(request); break; default: request->ret = -1; @@ -407,13 +407,13 @@ threadp->requests++; } /* while forever */ return NULL; -} /* aio_thread_loop */ +} /* squidaio_thread_loop */ static void -aio_queue_request(aio_request_t * request) +squidaio_queue_request(squidaio_request_t * request) { static int high_start = 0; - debug(41, 9) ("aio_queue_request: %p type=%d result=%p\n", + debug(41, 9) ("squidaio_queue_request: %p type=%d result=%p\n", request, request->request_type, request->resultp); /* Mark it as not executed (failing result, no error) */ request->ret = -1; @@ -458,7 +458,7 @@ if (++filter >= filter_limit) { filter_limit += filter; filter = 0; - debug(43, 1) ("aio_queue_request: WARNING - Queue congestion\n"); + debug(43, 1) ("squidaio_queue_request: WARNING - Queue congestion\n"); } } /* Warn if out of threads */ @@ -476,9 +476,9 @@ queue_low = request_queue_len; if (squid_curtime >= (last_warn + 15) && squid_curtime >= (high_start + 5)) { - debug(43, 1) ("aio_queue_request: WARNING - Disk I/O overloading\n"); + debug(43, 1) ("squidaio_queue_request: WARNING - Disk I/O overloading\n"); if (squid_curtime >= (high_start + 15)) - debug(43, 1) ("aio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%d\n", + debug(43, 1) ("squidaio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%d\n", request_queue_len, queue_high, queue_low, squid_curtime - high_start); last_warn = squid_curtime; } @@ -487,17 +487,17 @@ } /* Warn if seriously overloaded */ if (request_queue_len > RIDICULOUS_LENGTH) { - debug(43, 0) ("aio_queue_request: Async request queue growing uncontrollably!\n"); - debug(43, 0) ("aio_queue_request: Syncing pending I/O operations.. (blocking)\n"); - aio_sync(); - debug(43, 0) ("aio_queue_request: Synced\n"); + debug(43, 0) ("squidaio_queue_request: Async request queue growing uncontrollably!\n"); + debug(43, 0) ("squidaio_queue_request: Syncing pending I/O operations.. (blocking)\n"); + squidaio_sync(); + debug(43, 0) ("squidaio_queue_request: Synced\n"); } -} /* aio_queue_request */ +} /* squidaio_queue_request */ static void -aio_cleanup_request(aio_request_t * requestp) +squidaio_cleanup_request(squidaio_request_t * requestp) { - aio_result_t *resultp = requestp->resultp; + squidaio_result_t *resultp = requestp->resultp; int cancelled = requestp->cancelled; /* Free allocated structures and copy data back to user space if the */ @@ -506,14 +506,14 @@ case _AIO_OP_STAT: if (!cancelled && requestp->ret == 0) xmemcpy(requestp->statp, requestp->tmpstatp, sizeof(struct stat)); - aio_xfree(requestp->tmpstatp, sizeof(struct stat)); - aio_xstrfree(requestp->path); + squidaio_xfree(requestp->tmpstatp, sizeof(struct stat)); + squidaio_xstrfree(requestp->path); break; case _AIO_OP_OPEN: if (cancelled && requestp->ret >= 0) /* The open() was cancelled but completed */ close(requestp->ret); - aio_xstrfree(requestp->path); + squidaio_xstrfree(requestp->path); break; case _AIO_OP_CLOSE: if (cancelled && requestp->ret < 0) @@ -523,34 +523,34 @@ case _AIO_OP_UNLINK: case _AIO_OP_TRUNCATE: case _AIO_OP_OPENDIR: - aio_xstrfree(requestp->path); + squidaio_xstrfree(requestp->path); break; case _AIO_OP_READ: if (!cancelled && requestp->ret > 0) xmemcpy(requestp->bufferp, requestp->tmpbufp, requestp->ret); - aio_xfree(requestp->tmpbufp, requestp->buflen); + squidaio_xfree(requestp->tmpbufp, requestp->buflen); break; case _AIO_OP_WRITE: - aio_xfree(requestp->tmpbufp, requestp->buflen); + squidaio_xfree(requestp->tmpbufp, requestp->buflen); break; default: break; } if (resultp != NULL && !cancelled) { - resultp->aio_return = requestp->ret; - resultp->aio_errno = requestp->err; + resultp->squidaio_return = requestp->ret; + resultp->squidaio_errno = requestp->err; } - memPoolFree(aio_request_pool, requestp); -} /* aio_cleanup_request */ + memPoolFree(squidaio_request_pool, requestp); +} /* squidaio_cleanup_request */ int -aio_cancel(aio_result_t * resultp) +squidaio_cancel(squidaio_result_t * resultp) { - aio_request_t *request = resultp->_data; + squidaio_request_t *request = resultp->_data; if (request && request->resultp == resultp) { - debug(41, 9) ("aio_cancel: %p type=%d result=%p\n", + debug(41, 9) ("squidaio_cancel: %p type=%d result=%p\n", request, request->request_type, request->resultp); request->cancelled = 1; request->resultp = NULL; @@ -558,31 +558,31 @@ return 0; } return 1; -} /* aio_cancel */ +} /* squidaio_cancel */ int -aio_open(const char *path, int oflag, mode_t mode, aio_result_t * resultp) +squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); - requestp->path = (char *) aio_xstrdup(path); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); + requestp->path = (char *) squidaio_xstrdup(path); requestp->oflag = oflag; requestp->mode = mode; requestp->resultp = resultp; requestp->request_type = _AIO_OP_OPEN; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_open(aio_request_t * requestp) +squidaio_do_open(squidaio_request_t * requestp) { requestp->ret = open(requestp->path, requestp->oflag, requestp->mode); requestp->err = errno; @@ -590,16 +590,16 @@ int -aio_read(int fd, char *bufp, int bufs, off_t offset, int whence, aio_result_t * resultp) +squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); requestp->fd = fd; requestp->bufferp = bufp; - requestp->tmpbufp = (char *) aio_xmalloc(bufs); + requestp->tmpbufp = (char *) squidaio_xmalloc(bufs); requestp->buflen = bufs; requestp->offset = offset; requestp->whence = whence; @@ -607,13 +607,13 @@ requestp->request_type = _AIO_OP_READ; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_read(aio_request_t * requestp) +squidaio_do_read(squidaio_request_t * requestp) { lseek(requestp->fd, requestp->offset, requestp->whence); requestp->ret = read(requestp->fd, requestp->tmpbufp, requestp->buflen); @@ -622,15 +622,15 @@ int -aio_write(int fd, char *bufp, int bufs, off_t offset, int whence, aio_result_t * resultp) +squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); requestp->fd = fd; - requestp->tmpbufp = (char *) aio_xmalloc(bufs); + requestp->tmpbufp = (char *) squidaio_xmalloc(bufs); xmemcpy(requestp->tmpbufp, bufp, bufs); requestp->buflen = bufs; requestp->offset = offset; @@ -639,13 +639,13 @@ requestp->request_type = _AIO_OP_WRITE; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_write(aio_request_t * requestp) +squidaio_do_write(squidaio_request_t * requestp) { requestp->ret = write(requestp->fd, requestp->tmpbufp, requestp->buflen); requestp->err = errno; @@ -653,25 +653,25 @@ int -aio_close(int fd, aio_result_t * resultp) +squidaio_close(int fd, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); requestp->fd = fd; requestp->resultp = resultp; requestp->request_type = _AIO_OP_CLOSE; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_close(aio_request_t * requestp) +squidaio_do_close(squidaio_request_t * requestp) { requestp->ret = close(requestp->fd); requestp->err = errno; @@ -679,27 +679,27 @@ int -aio_stat(const char *path, struct stat *sb, aio_result_t * resultp) +squidaio_stat(const char *path, struct stat *sb, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); - requestp->path = (char *) aio_xstrdup(path); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); + requestp->path = (char *) squidaio_xstrdup(path); requestp->statp = sb; - requestp->tmpstatp = (struct stat *) aio_xmalloc(sizeof(struct stat)); + requestp->tmpstatp = (struct stat *) squidaio_xmalloc(sizeof(struct stat)); requestp->resultp = resultp; requestp->request_type = _AIO_OP_STAT; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_stat(aio_request_t * requestp) +squidaio_do_stat(squidaio_request_t * requestp) { requestp->ret = stat(requestp->path, requestp->tmpstatp); requestp->err = errno; @@ -707,51 +707,51 @@ int -aio_unlink(const char *path, aio_result_t * resultp) +squidaio_unlink(const char *path, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); - requestp->path = aio_xstrdup(path); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); + requestp->path = squidaio_xstrdup(path); requestp->resultp = resultp; requestp->request_type = _AIO_OP_UNLINK; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_unlink(aio_request_t * requestp) +squidaio_do_unlink(squidaio_request_t * requestp) { requestp->ret = unlink(requestp->path); requestp->err = errno; } int -aio_truncate(const char *path, off_t length, aio_result_t * resultp) +squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); - requestp->path = (char *) aio_xstrdup(path); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); + requestp->path = (char *) squidaio_xstrdup(path); requestp->offset = length; requestp->resultp = resultp; requestp->request_type = _AIO_OP_TRUNCATE; requestp->cancelled = 0; - aio_queue_request(requestp); + squidaio_queue_request(requestp); return 0; } static void -aio_do_truncate(aio_request_t * requestp) +squidaio_do_truncate(squidaio_request_t * requestp) { requestp->ret = truncate(requestp->path, requestp->offset); requestp->err = errno; @@ -759,22 +759,22 @@ #if AIO_OPENDIR -/* XXX aio_opendir NOT implemented yet.. */ +/* XXX squidaio_opendir NOT implemented yet.. */ int -aio_opendir(const char *path, aio_result_t * resultp) +squidaio_opendir(const char *path, squidaio_result_t * resultp) { - aio_request_t *requestp; + squidaio_request_t *requestp; int len; - if (!aio_initialised) - aio_init(); - requestp = memPoolAlloc(aio_request_pool); + if (!squidaio_initialised) + squidaio_init(); + requestp = memPoolAlloc(squidaio_request_pool); return -1; } static void -aio_do_opendir(aio_request_t * requestp) +squidaio_do_opendir(squidaio_request_t * requestp) { /* NOT IMPLEMENTED */ } @@ -782,7 +782,7 @@ #endif static void -aio_poll_queues(void) +squidaio_poll_queues(void) { /* kick "overflow" request queue */ if (request_queue2.head && @@ -796,7 +796,7 @@ } /* poll done queue */ if (done_queue.head && pthread_mutex_trylock(&done_queue.mutex) == 0) { - struct aio_request_t *requests = done_queue.head; + struct squidaio_request_t *requests = done_queue.head; done_queue.head = NULL; done_queue.tailp = &done_queue.head; pthread_mutex_unlock(&done_queue.mutex); @@ -821,63 +821,63 @@ #endif } -aio_result_t * -aio_poll_done(void) +squidaio_result_t * +squidaio_poll_done(void) { - aio_request_t *request; - aio_result_t *resultp; + squidaio_request_t *request; + squidaio_result_t *resultp; int cancelled; int polled = 0; AIO_REPOLL: request = done_requests.head; if (request == NULL && !polled) { - aio_poll_queues(); + squidaio_poll_queues(); polled = 1; request = done_requests.head; } if (!request) { return NULL; } - debug(41, 9) ("aio_poll_done: %p type=%d result=%p\n", + debug(41, 9) ("squidaio_poll_done: %p type=%d result=%p\n", request, request->request_type, request->resultp); done_requests.head = request->next; if (!done_requests.head) done_requests.tailp = &done_requests.head; resultp = request->resultp; cancelled = request->cancelled; - aio_debug(request); + squidaio_debug(request); debug(43, 5) ("DONE: %d -> %d\n", request->ret, request->err); - aio_cleanup_request(request); + squidaio_cleanup_request(request); if (cancelled) goto AIO_REPOLL; return resultp; -} /* aio_poll_done */ +} /* squidaio_poll_done */ int -aio_operations_pending(void) +squidaio_operations_pending(void) { return request_queue_len + (done_requests.head ? 1 : 0); } int -aio_sync(void) +squidaio_sync(void) { /* XXX This might take a while if the queue is large.. */ do { - aio_poll_queues(); + squidaio_poll_queues(); } while (request_queue_len > 0); - return aio_operations_pending(); + return squidaio_operations_pending(); } int -aio_get_queue_len(void) +squidaio_get_queue_len(void) { return request_queue_len; } static void -aio_debug(aio_request_t * request) +squidaio_debug(squidaio_request_t * request) { switch (request->request_type) { case _AIO_OP_OPEN: diff -rNu 0/squid-2.4.STABLE2/src/fs/aufs/async_io.c 1/squid-2.4.STABLE2/src/fs/aufs/async_io.c --- 0/squid-2.4.STABLE2/src/fs/aufs/async_io.c Fri Jan 12 02:52:00 2001 +++ 1/squid-2.4.STABLE2/src/fs/aufs/async_io.c Mon Sep 17 13:37:37 2001 @@ -46,17 +46,17 @@ #define _AIO_OPENDIR 5 #define _AIO_STAT 6 -typedef struct aio_ctrl_t { - struct aio_ctrl_t *next; +typedef struct squidaio_ctrl_t { + struct squidaio_ctrl_t *next; int fd; int operation; AIOCB *done_handler; void *done_handler_data; - aio_result_t result; + squidaio_result_t result; char *bufp; FREE *free_func; dlink_node node; -} aio_ctrl_t; +} squidaio_ctrl_t; struct { int open; @@ -67,93 +67,93 @@ int stat; int unlink; int check_callback; -} aio_counts; +} squidaio_counts; -typedef struct aio_unlinkq_t { +typedef struct squidaio_unlinkq_t { char *path; - struct aio_unlinkq_t *next; -} aio_unlinkq_t; + struct squidaio_unlinkq_t *next; +} squidaio_unlinkq_t; static dlink_list used_list; static int initialised = 0; -static OBJH aioStats; -static MemPool *aio_ctrl_pool; -static void aioFDWasClosed(int fd); +static OBJH squidaioStats; +static MemPool *squidaio_ctrl_pool; +static void squidaioFDWasClosed(int fd); static void -aioFDWasClosed(int fd) +squidaioFDWasClosed(int fd) { if (fd_table[fd].flags.closing) fd_close(fd); } void -aioInit(void) +squidaioInit(void) { if (initialised) return; - aio_ctrl_pool = memPoolCreate("aio_ctrl", sizeof(aio_ctrl_t)); - cachemgrRegister("aio_counts", "Async IO Function Counters", - aioStats, 0, 1); + squidaio_ctrl_pool = memPoolCreate("squidaio_ctrl", sizeof(squidaio_ctrl_t)); + cachemgrRegister("squidaio_counts", "Async IO Function Counters", + squidaioStats, 0, 1); initialised = 1; comm_quick_poll_required(); } void -aioDone(void) +squidaioDone(void) { - memPoolDestroy(aio_ctrl_pool); + memPoolDestroy(squidaio_ctrl_pool); initialised = 0; } void -aioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callback_data) +squidaioOpen(const char *path, int oflag, mode_t mode, AIOCB * callback, void *callback_data) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; assert(initialised); - aio_counts.open++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.open++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_OPEN; cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_open(path, oflag, mode, &ctrlp->result); + squidaio_open(path, oflag, mode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } void -aioClose(int fd) +squidaioClose(int fd) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; assert(initialised); - aio_counts.close++; - aioCancel(fd); - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.close++; + squidaioCancel(fd); + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = NULL; ctrlp->done_handler_data = NULL; ctrlp->operation = _AIO_CLOSE; ctrlp->result.data = ctrlp; - aio_close(fd, &ctrlp->result); + squidaio_close(fd, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; } void -aioCancel(int fd) +squidaioCancel(int fd) { - aio_ctrl_t *curr; + squidaio_ctrl_t *curr; AIOCB *done_handler; void *their_data; dlink_node *m, *next; assert(initialised); - aio_counts.cancel++; + squidaio_counts.cancel++; for (m = used_list.head; m; m = next) { while (m) { curr = m->data; @@ -164,33 +164,33 @@ if (m == NULL) break; - aio_cancel(&curr->result); + squidaio_cancel(&curr->result); if ((done_handler = curr->done_handler)) { their_data = curr->done_handler_data; curr->done_handler = NULL; curr->done_handler_data = NULL; - debug(0, 0) ("this be aioCancel\n"); + debug(0, 0) ("this be squidaioCancel\n"); if (cbdataValid(their_data)) done_handler(fd, their_data, -2, -2); cbdataUnlock(their_data); } next = m->next; dlinkDelete(m, &used_list); - memPoolFree(aio_ctrl_pool, curr); + memPoolFree(squidaio_ctrl_pool, curr); } } void -aioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func) +squidaioWrite(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data, FREE * free_func) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; int seekmode; assert(initialised); - aio_counts.write++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.write++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; @@ -205,20 +205,20 @@ } cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_write(fd, bufp, len, offset, seekmode, &ctrlp->result); + squidaio_write(fd, bufp, len, offset, seekmode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); -} /* aioWrite */ +} /* squidaioWrite */ void -aioRead(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data) +squidaioRead(int fd, int offset, char *bufp, int len, AIOCB * callback, void *callback_data) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; int seekmode; assert(initialised); - aio_counts.read++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.read++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = fd; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; @@ -231,80 +231,80 @@ } cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_read(fd, bufp, len, offset, seekmode, &ctrlp->result); + squidaio_read(fd, bufp, len, offset, seekmode, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; -} /* aioRead */ +} /* squidaioRead */ void -aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data) +squidaioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; assert(initialised); - aio_counts.stat++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.stat++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_STAT; cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_stat(path, sb, &ctrlp->result); + squidaio_stat(path, sb, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); return; -} /* aioStat */ +} /* squidaioStat */ void -aioUnlink(const char *path, AIOCB * callback, void *callback_data) +squidaioUnlink(const char *path, AIOCB * callback, void *callback_data) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; assert(initialised); - aio_counts.unlink++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.unlink++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_UNLINK; cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_unlink(path, &ctrlp->result); + squidaio_unlink(path, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); -} /* aioUnlink */ +} /* squidaioUnlink */ void -aioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_data) +squidaioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_data) { - aio_ctrl_t *ctrlp; + squidaio_ctrl_t *ctrlp; assert(initialised); - aio_counts.unlink++; - ctrlp = memPoolAlloc(aio_ctrl_pool); + squidaio_counts.unlink++; + ctrlp = memPoolAlloc(squidaio_ctrl_pool); ctrlp->fd = -2; ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_TRUNCATE; cbdataLock(callback_data); ctrlp->result.data = ctrlp; - aio_truncate(path, length, &ctrlp->result); + squidaio_truncate(path, length, &ctrlp->result); dlinkAdd(ctrlp, &ctrlp->node, &used_list); -} /* aioTruncate */ +} /* squidaioTruncate */ int -aioCheckCallbacks(SwapDir * SD) +squidaioCheckCallbacks(SwapDir * SD) { - aio_result_t *resultp; - aio_ctrl_t *ctrlp; + squidaio_result_t *resultp; + squidaio_ctrl_t *ctrlp; AIOCB *done_handler; void *their_data; int retval = 0; assert(initialised); - aio_counts.check_callback++; + squidaio_counts.check_callback++; for (;;) { - if ((resultp = aio_poll_done()) == NULL) + if ((resultp = squidaio_poll_done()) == NULL) break; - ctrlp = (aio_ctrl_t *) resultp->data; + ctrlp = (squidaio_ctrl_t *) resultp->data; if (ctrlp == NULL) continue; /* XXX Should not happen */ dlinkDelete(&ctrlp->node, &used_list); @@ -315,51 +315,51 @@ if (cbdataValid(their_data)) { retval = 1; /* Return that we've actually done some work */ done_handler(ctrlp->fd, their_data, - ctrlp->result.aio_return, ctrlp->result.aio_errno); + ctrlp->result.squidaio_return, ctrlp->result.squidaio_errno); } cbdataUnlock(their_data); } - /* free data if requested to aioWrite() */ + /* free data if requested to squidaioWrite() */ if (ctrlp->free_func) ctrlp->free_func(ctrlp->bufp); if (ctrlp->operation == _AIO_CLOSE) - aioFDWasClosed(ctrlp->fd); - memPoolFree(aio_ctrl_pool, ctrlp); + squidaioFDWasClosed(ctrlp->fd); + memPoolFree(squidaio_ctrl_pool, ctrlp); } return retval; } void -aioStats(StoreEntry * sentry) +squidaioStats(StoreEntry * sentry) { storeAppendPrintf(sentry, "ASYNC IO Counters:\n"); - storeAppendPrintf(sentry, "open\t%d\n", aio_counts.open); - storeAppendPrintf(sentry, "close\t%d\n", aio_counts.close); - storeAppendPrintf(sentry, "cancel\t%d\n", aio_counts.cancel); - storeAppendPrintf(sentry, "write\t%d\n", aio_counts.write); - storeAppendPrintf(sentry, "read\t%d\n", aio_counts.read); - storeAppendPrintf(sentry, "stat\t%d\n", aio_counts.stat); - storeAppendPrintf(sentry, "unlink\t%d\n", aio_counts.unlink); - storeAppendPrintf(sentry, "check_callback\t%d\n", aio_counts.check_callback); - storeAppendPrintf(sentry, "queue\t%d\n", aio_get_queue_len()); + 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()); } /* Flush all pending I/O */ void -aioSync(SwapDir * SD) +squidaioSync(SwapDir * SD) { if (!initialised) return; /* nothing to do then */ /* Flush all pending operations */ - debug(32, 1) ("aioSync: flushing pending I/O operations\n"); + debug(32, 1) ("squidaioSync: flushing pending I/O operations\n"); do { - aioCheckCallbacks(SD); - } while (aio_sync()); - debug(32, 1) ("aioSync: done\n"); + squidaioCheckCallbacks(SD); + } while (squidaio_sync()); + debug(32, 1) ("squidaioSync: done\n"); } int -aioQueueSize(void) +squidaioQueueSize(void) { - return memPoolInUseCount(aio_ctrl_pool); + return memPoolInUseCount(squidaio_ctrl_pool); } diff -rNu 0/squid-2.4.STABLE2/src/fs/aufs/store_asyncufs.h 1/squid-2.4.STABLE2/src/fs/aufs/store_asyncufs.h --- 0/squid-2.4.STABLE2/src/fs/aufs/store_asyncufs.h Fri Nov 10 23:42:03 2000 +++ 1/squid-2.4.STABLE2/src/fs/aufs/store_asyncufs.h Mon Sep 17 13:37:40 2001 @@ -25,46 +25,46 @@ #define ASYNC_WRITE 0 #define ASYNC_READ 1 -struct _aio_result_t { - int aio_return; - int aio_errno; +struct _squidaio_result_t { + int squidaio_return; + int squidaio_errno; void *_data; /* Internal housekeeping */ void *data; /* Available to the caller */ }; -typedef struct _aio_result_t aio_result_t; +typedef struct _squidaio_result_t squidaio_result_t; -typedef void AIOCB(int fd, void *, int aio_return, int aio_errno); +typedef void AIOCB(int fd, void *, int squidaio_return, int squidaio_errno); -int aio_cancel(aio_result_t *); -int aio_open(const char *, int, mode_t, aio_result_t *); -int aio_read(int, char *, int, off_t, int, aio_result_t *); -int aio_write(int, char *, int, off_t, int, aio_result_t *); -int aio_close(int, aio_result_t *); -int aio_stat(const char *, struct stat *, aio_result_t *); -int aio_unlink(const char *, aio_result_t *); -int aio_truncate(const char *, off_t length, aio_result_t *); -int aio_opendir(const char *, aio_result_t *); -aio_result_t *aio_poll_done(void); -int aio_operations_pending(void); -int aio_sync(void); -int aio_get_queue_len(void); - -void aioInit(void); -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, char *, int size, AIOCB *, void *); -void aioStat(char *, struct stat *, AIOCB *, void *); -void aioUnlink(const char *, AIOCB *, void *); -void aioTruncate(const char *, off_t length, AIOCB *, void *); -int aioCheckCallbacks(SwapDir *); -void aioSync(SwapDir *); -int aioQueueSize(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_close(int, squidaio_result_t *); +int squidaio_stat(const char *, struct stat *, squidaio_result_t *); +int squidaio_unlink(const char *, squidaio_result_t *); +int squidaio_truncate(const char *, off_t length, squidaio_result_t *); +int squidaio_opendir(const char *, squidaio_result_t *); +squidaio_result_t *squidaio_poll_done(void); +int squidaio_operations_pending(void); +int squidaio_sync(void); +int squidaio_get_queue_len(void); + +void squidaioInit(void); +void squidaioDone(void); +void squidaioCancel(int); +void squidaioOpen(const char *, int, mode_t, AIOCB *, void *); +void squidaioClose(int); +void squidaioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *); +void squidaioRead(int, int offset, char *, int size, AIOCB *, void *); +void squidaioStat(char *, struct stat *, AIOCB *, void *); +void squidaioUnlink(const char *, AIOCB *, void *); +void squidaioTruncate(const char *, off_t length, AIOCB *, void *); +int squidaioCheckCallbacks(SwapDir *); +void squidaioSync(SwapDir *); +int squidaioQueueSize(void); -struct _aioinfo_t { +struct _squidaioinfo_t { int swaplog_fd; int l1; int l2; @@ -72,7 +72,7 @@ int suggest; }; -struct _aiostate_t { +struct _squidaiostate_t { int fd; struct { unsigned int close_request:1; @@ -103,13 +103,13 @@ void *callback_data; }; -typedef struct _aioinfo_t aioinfo_t; -typedef struct _aiostate_t aiostate_t; +typedef struct _squidaioinfo_t squidaioinfo_t; +typedef struct _squidaiostate_t squidaiostate_t; -/* The aio_state memory pools */ -extern MemPool *aio_state_pool; -extern MemPool *aio_qread_pool; -extern MemPool *aio_qwrite_pool; +/* The squidaio_state memory pools */ +extern MemPool *squidaio_state_pool; +extern MemPool *squidaio_qread_pool; +extern MemPool *squidaio_qwrite_pool; extern void storeAufsDirMapBitReset(SwapDir *, sfileno); extern int storeAufsDirMapBitAllocate(SwapDir *); diff -rNu 0/squid-2.4.STABLE2/src/fs/aufs/store_dir_aufs.c 1/squid-2.4.STABLE2/src/fs/aufs/store_dir_aufs.c --- 0/squid-2.4.STABLE2/src/fs/aufs/store_dir_aufs.c Thu Jul 12 01:31:07 2001 +++ 1/squid-2.4.STABLE2/src/fs/aufs/store_dir_aufs.c Mon Sep 17 13:37:43 2001 @@ -66,9 +66,9 @@ static int n_asyncufs_dirs = 0; static int *asyncufs_dir_index = NULL; -MemPool *aio_state_pool = NULL; -MemPool *aio_qread_pool = NULL; -MemPool *aio_qwrite_pool = NULL; +MemPool *squidaio_state_pool = NULL; +MemPool *squidaio_qread_pool = NULL; +MemPool *squidaio_qwrite_pool = NULL; static int asyncufs_initialised = 0; static char *storeAufsDirSwapSubDir(SwapDir *, int subdirn); @@ -129,26 +129,26 @@ storeAufsDirMapBitTest(SwapDir * SD, int fn) { sfileno filn = fn; - aioinfo_t *aioinfo; - aioinfo = (aioinfo_t *) SD->fsdata; - return file_map_bit_test(aioinfo->map, filn); + squidaioinfo_t *squidaioinfo; + squidaioinfo = (squidaioinfo_t *) SD->fsdata; + return file_map_bit_test(squidaioinfo->map, filn); } void storeAufsDirMapBitSet(SwapDir * SD, int fn) { sfileno filn = fn; - aioinfo_t *aioinfo; - aioinfo = (aioinfo_t *) SD->fsdata; - file_map_bit_set(aioinfo->map, filn); + squidaioinfo_t *squidaioinfo; + squidaioinfo = (squidaioinfo_t *) SD->fsdata; + file_map_bit_set(squidaioinfo->map, filn); } void storeAufsDirMapBitReset(SwapDir * SD, int fn) { sfileno filn = fn; - aioinfo_t *aioinfo; - aioinfo = (aioinfo_t *) SD->fsdata; + squidaioinfo_t *squidaioinfo; + squidaioinfo = (squidaioinfo_t *) SD->fsdata; /* * We have to test the bit before calling file_map_bit_reset. * file_map_bit_reset doesn't do bounds checking. It assumes @@ -156,18 +156,18 @@ * the map is dynamic in size. Also clearing an already clear * bit puts the map counter of-of-whack. */ - if (file_map_bit_test(aioinfo->map, filn)) - file_map_bit_reset(aioinfo->map, filn); + if (file_map_bit_test(squidaioinfo->map, filn)) + file_map_bit_reset(squidaioinfo->map, filn); } int storeAufsDirMapBitAllocate(SwapDir * SD) { - aioinfo_t *aioinfo = (aioinfo_t *) SD->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) SD->fsdata; int fn; - fn = file_map_allocate(aioinfo->map, aioinfo->suggest); - file_map_bit_set(aioinfo->map, fn); - aioinfo->suggest = fn + 1; + fn = file_map_allocate(squidaioinfo->map, squidaioinfo->suggest); + file_map_bit_set(squidaioinfo->map, fn); + squidaioinfo->suggest = fn + 1; return fn; } @@ -180,12 +180,12 @@ static void storeAufsDirInitBitmap(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; - if (aioinfo->map == NULL) { + if (squidaioinfo->map == NULL) { /* First time */ - aioinfo->map = file_map_create(); - } else if (aioinfo->map->max_n_files) { + squidaioinfo->map = file_map_create(); + } else if (squidaioinfo->map->max_n_files) { /* it grew, need to expand */ /* XXX We don't need it anymore .. */ } @@ -195,10 +195,10 @@ static char * storeAufsDirSwapSubDir(SwapDir * sd, int subdirn) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; LOCAL_ARRAY(char, fullfilename, SQUID_MAXPATHLEN); - assert(0 <= subdirn && subdirn < aioinfo->l1); + assert(0 <= subdirn && subdirn < squidaioinfo->l1); snprintf(fullfilename, SQUID_MAXPATHLEN, "%s/%02X", sd->path, subdirn); return fullfilename; } @@ -248,13 +248,13 @@ static int storeAufsDirVerifyCacheDirs(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; int j; const char *path = sd->path; if (storeAufsDirVerifyDirectory(path) < 0) return -1; - for (j = 0; j < aioinfo->l1; j++) { + for (j = 0; j < squidaioinfo->l1; j++) { path = storeAufsDirSwapSubDir(sd, j); if (storeAufsDirVerifyDirectory(path) < 0) return -1; @@ -265,18 +265,18 @@ static void storeAufsDirCreateSwapSubDirs(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; int i, k; int should_exist; LOCAL_ARRAY(char, name, MAXPATHLEN); - for (i = 0; i < aioinfo->l1; i++) { + for (i = 0; i < squidaioinfo->l1; i++) { snprintf(name, MAXPATHLEN, "%s/%02X", sd->path, i); if (storeAufsDirCreateDirectory(name, 0)) should_exist = 0; else should_exist = 1; debug(47, 1) ("Making directories in %s\n", name); - for (k = 0; k < aioinfo->l2; k++) { + for (k = 0; k < squidaioinfo->l2; k++) { snprintf(name, MAXPATHLEN, "%s/%02X/%02X", sd->path, i, k); storeAufsDirCreateDirectory(name, should_exist); } @@ -316,7 +316,7 @@ static void storeAufsDirOpenSwapLog(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; char *path; int fd; path = storeAufsDirSwapLogFile(sd, NULL); @@ -326,7 +326,7 @@ fatal("storeAufsDirOpenSwapLog: Failed to open swap log."); } debug(47, 3) ("Cache Dir #%d log opened on FD %d\n", sd->index, fd); - aioinfo->swaplog_fd = fd; + squidaioinfo->swaplog_fd = fd; if (0 == n_asyncufs_dirs) assert(NULL == asyncufs_dir_index); n_asyncufs_dirs++; @@ -336,13 +336,13 @@ static void storeAufsDirCloseSwapLog(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; - if (aioinfo->swaplog_fd < 0) /* not open */ + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; + if (squidaioinfo->swaplog_fd < 0) /* not open */ return; - file_close(aioinfo->swaplog_fd); + file_close(squidaioinfo->swaplog_fd); debug(47, 3) ("Cache Dir #%d log closed on FD %d\n", - sd->index, aioinfo->swaplog_fd); - aioinfo->swaplog_fd = -1; + sd->index, squidaioinfo->swaplog_fd); + squidaioinfo->swaplog_fd = -1; n_asyncufs_dirs--; assert(n_asyncufs_dirs >= 0); if (0 == n_asyncufs_dirs) @@ -690,7 +690,7 @@ storeAufsDirGetNextFile(RebuildState * rb, int *sfileno, int *size) { SwapDir *SD = rb->sd; - aioinfo_t *aioinfo = (aioinfo_t *) SD->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) SD->fsdata; int fd = -1; int used = 0; int dirs_opened = 0; @@ -761,10 +761,10 @@ continue; } rb->in_dir = 0; - if (++rb->curlvl2 < aioinfo->l2) + if (++rb->curlvl2 < squidaioinfo->l2) continue; rb->curlvl2 = 0; - if (++rb->curlvl1 < aioinfo->l1) + if (++rb->curlvl1 < squidaioinfo->l1) continue; rb->curlvl1 = 0; rb->done = 1; @@ -854,11 +854,11 @@ static void storeAufsDirCloseTmpSwapLog(SwapDir * sd) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; char *swaplog_path = xstrdup(storeAufsDirSwapLogFile(sd, NULL)); char *new_path = xstrdup(storeAufsDirSwapLogFile(sd, ".new")); int fd; - file_close(aioinfo->swaplog_fd); + file_close(squidaioinfo->swaplog_fd); #ifdef _SQUID_OS2_ if (unlink(swaplog_path) < 0) { debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); @@ -875,14 +875,14 @@ } safe_free(swaplog_path); safe_free(new_path); - aioinfo->swaplog_fd = fd; + squidaioinfo->swaplog_fd = fd; debug(47, 3) ("Cache Dir #%d log opened on FD %d\n", sd->index, fd); } static FILE * storeAufsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; char *swaplog_path = xstrdup(storeAufsDirSwapLogFile(sd, NULL)); char *clean_path = xstrdup(storeAufsDirSwapLogFile(sd, ".last-clean")); char *new_path = xstrdup(storeAufsDirSwapLogFile(sd, ".new")); @@ -899,15 +899,15 @@ } *zero_flag = log_sb.st_size == 0 ? 1 : 0; /* close the existing write-only FD */ - if (aioinfo->swaplog_fd >= 0) - file_close(aioinfo->swaplog_fd); + if (squidaioinfo->swaplog_fd >= 0) + file_close(squidaioinfo->swaplog_fd); /* open a write-only FD for the new log */ fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC); if (fd < 0) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); } - aioinfo->swaplog_fd = fd; + squidaioinfo->swaplog_fd = fd; /* open a read-only stream of the old log */ fp = fopen(swaplog_path, "r"); if (fp == NULL) { @@ -1088,7 +1088,7 @@ static void storeAufsDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op) { - aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) sd->fsdata; storeSwapLogData *s = memAllocate(MEM_SWAP_LOG_DATA); s->op = (char) op; s->swap_filen = e->swap_filen; @@ -1100,7 +1100,7 @@ s->refcount = e->refcount; s->flags = e->flags; xmemcpy(s->key, e->hash.key, MD5_DIGEST_CHARS); - file_write(aioinfo->swaplog_fd, + file_write(squidaioinfo->swaplog_fd, -1, s, sizeof(storeSwapLogData), @@ -1143,14 +1143,14 @@ int N0, N1, N2; int D0, D1, D2; SwapDir *SD; - aioinfo_t *aioinfo; + squidaioinfo_t *squidaioinfo; N0 = n_asyncufs_dirs; D0 = asyncufs_dir_index[swap_index % N0]; SD = &Config.cacheSwap.swapDirs[D0]; - aioinfo = (aioinfo_t *) SD->fsdata; - N1 = aioinfo->l1; + squidaioinfo = (squidaioinfo_t *) SD->fsdata; + N1 = squidaioinfo->l1; D1 = (swap_index / N0) % N1; - N2 = aioinfo->l2; + N2 = squidaioinfo->l2; D2 = ((swap_index / N0) / N1) % N2; snprintf(p1, SQUID_MAXPATHLEN, "%s/%02X/%02X", Config.cacheSwap.swapDirs[D0].path, D1, D2); @@ -1215,7 +1215,7 @@ assert(n_asyncufs_dirs); if (NULL == asyncufs_dir_index) { SwapDir *sd; - aioinfo_t *aioinfo; + squidaioinfo_t *squidaioinfo; /* * Initialize the little array that translates AUFS cache_dir * number into the Config.cacheSwap.swapDirs array index. @@ -1226,8 +1226,8 @@ if (!storeAufsDirIs(sd)) continue; asyncufs_dir_index[n++] = i; - aioinfo = (aioinfo_t *) sd->fsdata; - j += (aioinfo->l1 * aioinfo->l2); + squidaioinfo = (squidaioinfo_t *) sd->fsdata; + j += (squidaioinfo->l1 * squidaioinfo->l2); } assert(n == n_asyncufs_dirs); /* @@ -1263,11 +1263,11 @@ int D1, D2; int L1, L2; int filn = fn; - aioinfo_t *aioinfo; + squidaioinfo_t *squidaioinfo; assert(F0 < Config.cacheSwap.n_configured); - aioinfo = (aioinfo_t *) Config.cacheSwap.swapDirs[F0].fsdata; - L1 = aioinfo->l1; - L2 = aioinfo->l2; + squidaioinfo = (squidaioinfo_t *) Config.cacheSwap.swapDirs[F0].fsdata; + L1 = squidaioinfo->l1; + L2 = squidaioinfo->l2; D1 = ((filn / L2) / L2) % L1; if (F1 != D1) return 0; @@ -1280,7 +1280,7 @@ int storeAufsDirValidFileno(SwapDir * SD, sfileno filn, int flag) { - aioinfo_t *aioinfo = (aioinfo_t *) SD->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) SD->fsdata; if (filn < 0) return 0; /* @@ -1288,7 +1288,7 @@ * be considered invalid. */ if (flag) - if (filn > aioinfo->map->max_n_files) + if (filn > squidaioinfo->map->max_n_files) return 0; return 1; } @@ -1354,7 +1354,7 @@ return -1; } #endif - ql = aioQueueSize(); + ql = squidaioQueueSize(); if (ql == 0) loadav = 0; loadav = ql * 1000 / MAGIC1; @@ -1404,9 +1404,9 @@ debug(79, 3) ("storeAufsDirUnlinkFile: unlinking fileno %08X\n", f); /* storeAufsDirMapBitReset(SD, f); */ #if USE_TRUNCATE_NOT_UNLINK - aioTruncate(storeAufsDirFullPath(SD, f, NULL), NULL, NULL); + squidaioTruncate(storeAufsDirFullPath(SD, f, NULL), NULL, NULL); #else - aioUnlink(storeAufsDirFullPath(SD, f, NULL), NULL, NULL); + squidaioUnlink(storeAufsDirFullPath(SD, f, NULL), NULL, NULL); #endif } @@ -1440,21 +1440,21 @@ void storeAufsDirStats(SwapDir * SD, StoreEntry * sentry) { - aioinfo_t *aioinfo = SD->fsdata; + squidaioinfo_t *squidaioinfo = SD->fsdata; int totl_kb = 0; int free_kb = 0; int totl_in = 0; int free_in = 0; int x; - storeAppendPrintf(sentry, "First level subdirectories: %d\n", aioinfo->l1); - storeAppendPrintf(sentry, "Second level subdirectories: %d\n", aioinfo->l2); + storeAppendPrintf(sentry, "First level subdirectories: %d\n", squidaioinfo->l1); + storeAppendPrintf(sentry, "Second level subdirectories: %d\n", squidaioinfo->l2); storeAppendPrintf(sentry, "Maximum Size: %d KB\n", SD->max_size); storeAppendPrintf(sentry, "Current Size: %d KB\n", SD->cur_size); storeAppendPrintf(sentry, "Percent Used: %0.2f%%\n", 100.0 * SD->cur_size / SD->max_size); storeAppendPrintf(sentry, "Filemap bits in use: %d of %d (%d%%)\n", - aioinfo->map->n_files_in_map, aioinfo->map->max_n_files, - percent(aioinfo->map->n_files_in_map, aioinfo->map->max_n_files)); + squidaioinfo->map->n_files_in_map, squidaioinfo->map->max_n_files, + percent(squidaioinfo->map->n_files_in_map, squidaioinfo->map->max_n_files)); x = storeDirGetUFSStats(SD->path, &totl_kb, &free_kb, &totl_in, &free_in); if (0 == x) { storeAppendPrintf(sentry, "Filesystem Space in use: %d/%d KB (%d%%)\n", @@ -1526,14 +1526,14 @@ void storeAufsDirDump(StoreEntry * entry, const char *name, SwapDir * s) { - aioinfo_t *aioinfo = (aioinfo_t *) s->fsdata; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) s->fsdata; storeAppendPrintf(entry, "%s %s %s %d %d %d\n", name, "aufs", s->path, s->max_size >> 10, - aioinfo->l1, - aioinfo->l2); + squidaioinfo->l1, + squidaioinfo->l2); } /* @@ -1542,13 +1542,13 @@ static void storeAufsDirFree(SwapDir * s) { - aioinfo_t *aioinfo = (aioinfo_t *) s->fsdata; - if (aioinfo->swaplog_fd > -1) { - file_close(aioinfo->swaplog_fd); - aioinfo->swaplog_fd = -1; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) s->fsdata; + if (squidaioinfo->swaplog_fd > -1) { + file_close(squidaioinfo->swaplog_fd); + squidaioinfo->swaplog_fd = -1; } - filemapFreeMemory(aioinfo->map); - xfree(aioinfo); + filemapFreeMemory(squidaioinfo->map); + xfree(squidaioinfo); s->fsdata = NULL; /* Will aid debugging... */ } @@ -1556,9 +1556,9 @@ storeAufsDirFullPath(SwapDir * SD, sfileno filn, char *fullpath) { LOCAL_ARRAY(char, fullfilename, SQUID_MAXPATHLEN); - aioinfo_t *aioinfo = (aioinfo_t *) SD->fsdata; - int L1 = aioinfo->l1; - int L2 = aioinfo->l2; + squidaioinfo_t *squidaioinfo = (squidaioinfo_t *) SD->fsdata; + int L1 = squidaioinfo->l1; + int L2 = squidaioinfo->l2; if (!fullpath) fullpath = fullfilename; fullpath[0] = '\0'; @@ -1613,7 +1613,7 @@ int size; int l1; int l2; - aioinfo_t *aioinfo; + squidaioinfo_t *squidaioinfo; i = GetInteger(); size = i << 10; /* Mbytes to kbytes */ @@ -1628,19 +1628,19 @@ if (l2 <= 0) fatal("storeAufsDirParse: invalid level 2 directories value"); - aioinfo = xmalloc(sizeof(aioinfo_t)); - if (aioinfo == NULL) - fatal("storeAufsDirParse: couldn't xmalloc() aioinfo_t!\n"); + squidaioinfo = xmalloc(sizeof(squidaioinfo_t)); + if (squidaioinfo == NULL) + fatal("storeAufsDirParse: couldn't xmalloc() squidaioinfo_t!\n"); sd->index = index; sd->path = xstrdup(path); sd->max_size = size; - sd->fsdata = aioinfo; - aioinfo->l1 = l1; - aioinfo->l2 = l2; - aioinfo->swaplog_fd = -1; - aioinfo->map = NULL; /* Debugging purposes */ - aioinfo->suggest = 0; + sd->fsdata = squidaioinfo; + squidaioinfo->l1 = l1; + squidaioinfo->l2 = l2; + squidaioinfo->swaplog_fd = -1; + squidaioinfo->map = NULL; /* Debugging purposes */ + squidaioinfo->suggest = 0; sd->init = storeAufsDirInit; sd->newfs = storeAufsDirNewfs; sd->dump = storeAufsDirDump; @@ -1651,8 +1651,8 @@ sd->checkobj = storeAufsDirCheckObj; sd->refobj = storeAufsDirRefObj; sd->unrefobj = storeAufsDirUnrefObj; - sd->callback = aioCheckCallbacks; - sd->sync = aioSync; + sd->callback = squidaioCheckCallbacks; + sd->sync = squidaioSync; sd->obj.create = storeAufsCreate; sd->obj.open = storeAufsOpen; sd->obj.close = storeAufsClose; @@ -1678,10 +1678,10 @@ void storeAufsDirDone(void) { - aioDone(); - memPoolDestroy(aio_state_pool); - memPoolDestroy(aio_qread_pool); - memPoolDestroy(aio_qwrite_pool); + squidaioDone(); + memPoolDestroy(squidaio_state_pool); + memPoolDestroy(squidaio_qread_pool); + memPoolDestroy(squidaio_qwrite_pool); asyncufs_initialised = 0; } @@ -1692,12 +1692,12 @@ storefs->parsefunc = storeAufsDirParse; storefs->reconfigurefunc = storeAufsDirReconfigure; storefs->donefunc = storeAufsDirDone; - aio_state_pool = memPoolCreate("AUFS IO State data", sizeof(aiostate_t)); - aio_qread_pool = memPoolCreate("AUFS Queued read data", + squidaio_state_pool = memPoolCreate("AUFS IO State data", sizeof(squidaiostate_t)); + squidaio_qread_pool = memPoolCreate("AUFS Queued read data", sizeof(queued_read)); - aio_qwrite_pool = memPoolCreate("AUFS Queued write data", + squidaio_qwrite_pool = memPoolCreate("AUFS Queued write data", sizeof(queued_write)); asyncufs_initialised = 1; - aioInit(); + squidaioInit(); } diff -rNu 0/squid-2.4.STABLE2/src/fs/aufs/store_io_aufs.c 1/squid-2.4.STABLE2/src/fs/aufs/store_io_aufs.c --- 0/squid-2.4.STABLE2/src/fs/aufs/store_io_aufs.c Fri Jan 5 02:30:39 2001 +++ 1/squid-2.4.STABLE2/src/fs/aufs/store_io_aufs.c Mon Sep 17 13:37:46 2001 @@ -41,7 +41,7 @@ * NULL here. */ #ifdef MAGIC2 - if (aioQueueSize() > MAGIC2) + if (squidaioQueueSize() > MAGIC2) return NULL; #endif #if !ASYNC_OPEN @@ -53,9 +53,9 @@ #endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); - sio->fsstate = memPoolAlloc(aio_state_pool); - ((aiostate_t *) (sio->fsstate))->fd = -1; - ((aiostate_t *) (sio->fsstate))->flags.opening = 1; + sio->fsstate = memPoolAlloc(squidaio_state_pool); + ((squidaiostate_t *) (sio->fsstate))->fd = -1; + ((squidaiostate_t *) (sio->fsstate))->flags.opening = 1; sio->swap_filen = f; sio->swap_dirn = SD->index; sio->mode = O_RDONLY; @@ -65,7 +65,7 @@ cbdataLock(callback_data); Opening_FD++; #if ASYNC_OPEN - aioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); + squidaioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); #else storeAufsOpenDone(fd, sio, fd, 0); #endif @@ -96,7 +96,7 @@ * NULL here. */ #ifdef MAGIC2 - if (aioQueueSize() > MAGIC2) + if (squidaioQueueSize() > MAGIC2) return NULL; #endif #if !ASYNC_CREATE @@ -108,9 +108,9 @@ #endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); - sio->fsstate = memPoolAlloc(aio_state_pool); - ((aiostate_t *) (sio->fsstate))->fd = -1; - ((aiostate_t *) (sio->fsstate))->flags.opening = 1; + sio->fsstate = memPoolAlloc(squidaio_state_pool); + ((squidaiostate_t *) (sio->fsstate))->fd = -1; + ((squidaiostate_t *) (sio->fsstate))->flags.opening = 1; sio->swap_filen = filn; sio->swap_dirn = dirn; sio->mode = O_WRONLY; @@ -120,7 +120,7 @@ cbdataLock(callback_data); Opening_FD++; #if ASYNC_CREATE - aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); + squidaioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); #else storeAufsOpenDone(fd, sio, fd, 0); #endif @@ -138,11 +138,11 @@ void storeAufsClose(SwapDir * SD, storeIOState * sio) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; debug(78, 3) ("storeAufsClose: dirno %d, fileno %08X, FD %d\n", - sio->swap_dirn, sio->swap_filen, aiostate->fd); + sio->swap_dirn, sio->swap_filen, squidaiostate->fd); if (storeAufsSomethingPending(sio)) { - aiostate->flags.close_request = 1; + squidaiostate->flags.close_request = 1; return; } storeAufsIOCallback(sio, DISK_OK); @@ -153,36 +153,36 @@ void storeAufsRead(SwapDir * SD, storeIOState * sio, char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; assert(sio->read.callback == NULL); assert(sio->read.callback_data == NULL); - assert(!aiostate->flags.reading); - if (aiostate->fd < 0) { + assert(!squidaiostate->flags.reading); + if (squidaiostate->fd < 0) { struct _queued_read *q; debug(78, 3) ("storeAufsRead: queueing read because FD < 0\n"); - assert(aiostate->flags.opening); - assert(aiostate->pending_reads == NULL); - q = memPoolAlloc(aio_qread_pool); + assert(squidaiostate->flags.opening); + assert(squidaiostate->pending_reads == NULL); + q = memPoolAlloc(squidaio_qread_pool); q->buf = buf; q->size = size; q->offset = offset; q->callback = callback; q->callback_data = callback_data; - linklistPush(&(aiostate->pending_reads), q); + linklistPush(&(squidaiostate->pending_reads), q); return; } sio->read.callback = callback; sio->read.callback_data = callback_data; - aiostate->read_buf = buf; + squidaiostate->read_buf = buf; cbdataLock(callback_data); debug(78, 3) ("storeAufsRead: dirno %d, fileno %08X, FD %d\n", - sio->swap_dirn, sio->swap_filen, aiostate->fd); + sio->swap_dirn, sio->swap_filen, squidaiostate->fd); sio->offset = offset; - aiostate->flags.reading = 1; + squidaiostate->flags.reading = 1; #if ASYNC_READ - aioRead(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); + squidaioRead(squidaiostate->fd, offset, buf, size, storeAufsReadDone, sio); #else - file_read(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); + file_read(squidaiostate->fd, offset, buf, size, storeAufsReadDone, sio); #endif } @@ -191,45 +191,45 @@ void storeAufsWrite(SwapDir * SD, storeIOState * sio, char *buf, size_t size, off_t offset, FREE * free_func) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; debug(78, 3) ("storeAufsWrite: dirno %d, fileno %08X, FD %d\n", - sio->swap_dirn, sio->swap_filen, aiostate->fd); - if (aiostate->fd < 0) { + sio->swap_dirn, sio->swap_filen, squidaiostate->fd); + if (squidaiostate->fd < 0) { /* disk file not opened yet */ struct _queued_write *q; - assert(aiostate->flags.opening); - q = memPoolAlloc(aio_qwrite_pool); + assert(squidaiostate->flags.opening); + q = memPoolAlloc(squidaio_qwrite_pool); q->buf = buf; q->size = size; q->offset = offset; q->free_func = free_func; - linklistPush(&(aiostate->pending_writes), q); + linklistPush(&(squidaiostate->pending_writes), q); return; } #if ASYNC_WRITE - if (aiostate->flags.writing) { + if (squidaiostate->flags.writing) { struct _queued_write *q; debug(78, 3) ("storeAufsWrite: queuing write\n"); - q = memPoolAlloc(aio_qwrite_pool); + q = memPoolAlloc(squidaio_qwrite_pool); q->buf = buf; q->size = size; q->offset = offset; q->free_func = free_func; - linklistPush(&(aiostate->pending_writes), q); + linklistPush(&(squidaiostate->pending_writes), q); return; } - aiostate->flags.writing = 1; + squidaiostate->flags.writing = 1; /* - * XXX it might be nice if aioWrite() gave is immediate + * XXX it might be nice if squidaioWrite() gave is immediate * feedback here about EWOULDBLOCK instead of in the * callback function * XXX Should never give EWOULDBLOCK under normal operations * if it does then the MAGIC1/2 tuning is wrong. */ - aioWrite(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, + squidaioWrite(squidaiostate->fd, offset, buf, size, storeAufsWriteDone, sio, free_func); #else - file_write(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, + file_write(squidaiostate->fd, offset, buf, size, storeAufsWriteDone, sio, free_func); #endif } @@ -249,28 +249,28 @@ static int storeAufsKickWriteQueue(storeIOState * sio) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; - struct _queued_write *q = linklistShift(&aiostate->pending_writes); + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; + struct _queued_write *q = linklistShift(&squidaiostate->pending_writes); if (NULL == q) return 0; debug(78, 3) ("storeAufsKickWriteQueue: writing queued chunk of %d bytes\n", q->size); storeAufsWrite(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->free_func); - memPoolFree(aio_qwrite_pool, q); + memPoolFree(squidaio_qwrite_pool, q); return 1; } static int storeAufsKickReadQueue(storeIOState * sio) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; - struct _queued_read *q = linklistShift(&(aiostate->pending_reads)); + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; + struct _queued_read *q = linklistShift(&(squidaiostate->pending_reads)); if (NULL == q) return 0; debug(78, 3) ("storeAufsKickReadQueue: reading queued request of %d bytes\n", q->size); storeAufsRead(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->callback, q->callback_data); - memPoolFree(aio_qread_pool, q); + memPoolFree(squidaio_qread_pool, q); return 1; } @@ -278,10 +278,10 @@ storeAufsOpenDone(int unused, void *my_data, int fd, int errflag) { storeIOState *sio = my_data; - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; debug(78, 3) ("storeAufsOpenDone: FD %d, errflag %d\n", fd, errflag); Opening_FD--; - aiostate->flags.opening = 0; + squidaiostate->flags.opening = 0; if (errflag || fd < 0) { errno = errflag; debug(78, 0) ("storeAufsOpenDone: %s\n", xstrerror()); @@ -289,7 +289,7 @@ storeAufsIOCallback(sio, DISK_ERROR); return; } - aiostate->fd = fd; + squidaiostate->fd = fd; commSetCloseOnExec(fd); fd_open(fd, FD_FILE, storeAufsDirFullPath(INDEXSD(sio->swap_dirn), sio->swap_filen, NULL)); if (sio->mode == O_WRONLY) @@ -315,14 +315,14 @@ #endif { storeIOState *sio = my_data; - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; STRCB *callback = sio->read.callback; void *their_data = sio->read.callback_data; ssize_t rlen; debug(78, 3) ("storeAufsReadDone: dirno %d, fileno %08X, FD %d, len %d\n", sio->swap_dirn, sio->swap_filen, fd, len); - aiostate->flags.inreaddone = 1; - aiostate->flags.reading = 0; + squidaiostate->flags.inreaddone = 1; + squidaiostate->flags.reading = 0; if (errflag) { debug(78, 3) ("storeAufsReadDone: got failure (%d)\n", errflag); rlen = -1; @@ -346,10 +346,10 @@ sio->read.callback = NULL; sio->read.callback_data = NULL; if (cbdataValid(their_data)) - callback(their_data, aiostate->read_buf, rlen); + callback(their_data, squidaiostate->read_buf, rlen); cbdataUnlock(their_data); - aiostate->flags.inreaddone = 0; - if (aiostate->flags.close_request) + squidaiostate->flags.inreaddone = 0; + if (squidaiostate->flags.close_request) storeAufsIOCallback(sio, errflag); } @@ -370,7 +370,7 @@ { static int loop_detect = 0; storeIOState *sio = my_data; - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; debug(78, 3) ("storeAufsWriteDone: dirno %d, fileno %08X, FD %d, len %d, err=%d\n", sio->swap_dirn, sio->swap_filen, fd, len, errflag); #if ASYNC_WRITE @@ -382,7 +382,7 @@ errflag = DISK_OK; #endif assert(++loop_detect < 10); - aiostate->flags.writing = 0; + squidaiostate->flags.writing = 0; if (errflag) { debug(78, 0) ("storeAufsWriteDone: got failure (%d)\n", errflag); storeAufsIOCallback(sio, errflag); @@ -393,15 +393,15 @@ #if ASYNC_WRITE if (!storeAufsKickWriteQueue(sio)) 0; - else if (aiostate->flags.close_request) + else if (squidaiostate->flags.close_request) storeAufsIOCallback(sio, errflag); #else - if (!aiostate->flags.write_kicking) { - aiostate->flags.write_kicking = 1; + if (!squidaiostate->flags.write_kicking) { + squidaiostate->flags.write_kicking = 1; while (storeAufsKickWriteQueue(sio)) (void) 0; - aiostate->flags.write_kicking = 0; - if (aiostate->flags.close_request) + squidaiostate->flags.write_kicking = 0; + if (squidaiostate->flags.close_request) storeAufsIOCallback(sio, errflag); } #endif @@ -413,8 +413,8 @@ { STIOCB *callback = sio->callback; void *their_data = sio->callback_data; - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; - int fd = aiostate->fd; + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; + int fd = squidaiostate->fd; debug(78, 3) ("storeAufsIOCallback: errflag=%d\n", errflag); sio->callback = NULL; sio->callback_data = NULL; @@ -424,12 +424,12 @@ callback(their_data, errflag, sio); debug(78, 3) ("%s:%d\n", __FILE__, __LINE__); cbdataUnlock(their_data); - aiostate->fd = -1; + squidaiostate->fd = -1; cbdataFree(sio); if (fd < 0) return; debug(78, 3) ("%s:%d\n", __FILE__, __LINE__); - aioClose(fd); + squidaioClose(fd); fd_close(fd); store_open_disk_fd--; debug(78, 3) ("%s:%d\n", __FILE__, __LINE__); @@ -439,14 +439,14 @@ static int storeAufsSomethingPending(storeIOState * sio) { - aiostate_t *aiostate = (aiostate_t *) sio->fsstate; - if (aiostate->flags.reading) + squidaiostate_t *squidaiostate = (squidaiostate_t *) sio->fsstate; + if (squidaiostate->flags.reading) return 1; - if (aiostate->flags.writing) + if (squidaiostate->flags.writing) return 1; - if (aiostate->flags.opening) + if (squidaiostate->flags.opening) return 1; - if (aiostate->flags.inreaddone) + if (squidaiostate->flags.inreaddone) return 1; return 0; } @@ -459,6 +459,6 @@ static void storeAufsIOFreeEntry(void *sio, int foo) { - memPoolFree(aio_state_pool, ((storeIOState *) sio)->fsstate); + memPoolFree(squidaio_state_pool, ((storeIOState *) sio)->fsstate); memFree(sio, MEM_STORE_IO); }