Author: adrian.chadd
Date: Fri Mar 27 17:17:28 2009
New Revision: 13875

Modified:
    branches/LUSCA_HEAD/src/fs/Makefile.am
    branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c
    branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c

Log:
Remove the COSS posix AIO code - although it has the potential to scale  
better,
having two APIs for this right now makes no sense and the existing code  
basically
bites.



Modified: branches/LUSCA_HEAD/src/fs/Makefile.am
==============================================================================
--- branches/LUSCA_HEAD/src/fs/Makefile.am      (original)
+++ branches/LUSCA_HEAD/src/fs/Makefile.am      Fri Mar 27 17:17:28 2009
@@ -5,21 +5,13 @@

  AUTOMAKE_OPTIONS = subdir-objects

-if USE_AIOPS_WIN32
-AIOPS_SOURCE = aufs/aiops_win32.c
-else
-AIOPS_SOURCE = aufs/aiops.c
-endif
-
  EXTRA_LIBRARIES = libaufs.a libcoss.a libdiskd.a libnull.a libufs.a
  noinst_LIBRARIES = @STORE_LIBS@

  EXTRA_libaufs_a_SOURCES = aufs/aiops.c aufs/aiops_win32.c

-libaufs_a_SOURCES = $(AIOPS_SOURCE) aufs/async_io.c aufs/store_asyncufs.h \
-       aufs/store_dir_aufs.c aufs/store_io_aufs.c aufs/async_io.h
-libcoss_a_SOURCES = coss/store_coss.h   coss/store_io_coss.c  
coss/store_dir_coss.c \
-       coss/async_io.c coss/async_io.h
+libaufs_a_SOURCES = aufs/store_asyncufs.h aufs/store_dir_aufs.c  
aufs/store_io_aufs.c
+libcoss_a_SOURCES = coss/store_coss.h   coss/store_io_coss.c  
coss/store_dir_coss.c
  libdiskd_a_SOURCES = diskd/diskd.c diskd/store_dir_diskd.c  
diskd/store_diskd.h \
        diskd/store_io_diskd.c
  libnull_a_SOURCES = null/store_null.c

Modified: branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c
==============================================================================
--- branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c    (original)
+++ branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c    Fri Mar 27 17:17:28  
2009
@@ -39,11 +39,7 @@
  #endif


-#if USE_AUFSOPS
  #include "../../libasyncio/async_io.h"
-#else
-#include "async_io.h"
-#endif
  #include "store_coss.h"

  #define STORE_META_BUFSZ 4096
@@ -143,14 +139,10 @@
      if (sizeof(off_t) < 8) {
        fatalf("COSS will not function without large file support (off_t is %d  
bytes long. Please reconsider recompiling squid with --with-large-files\n",  
(int) sizeof(off_t));
      }
-#if USE_AUFSOPS
      aioInit();
      if (Config.aiops.n_aiops_threads > -1)
          squidaio_nthreads = Config.aiops.n_aiops_threads;
      squidaio_init();
-#else
-    a_file_setupqueue(&cs->aq);
-#endif
      cs->fd = file_open(stripePath(sd), O_RDWR | O_CREAT | O_BINARY);
      if (cs->fd < 0) {
        debug(79, 1) ("%s: %s\n", stripePath(sd), xstrerror());
@@ -298,9 +290,7 @@
      debug(47, 1) ("COSS: %s: syncing\n", stripePath(SD));

      storeCossSync(SD);                /* This'll call a_file_syncqueue() or a 
aioSync()  
*/
-#if !USE_AUFSOPS
-    a_file_closequeue(&cs->aq);
-#endif
+    /* XXX how should one close the pending ops on a given asyncio fd? */
      file_close(cs->fd);
      cs->fd = -1;
      xfree((void *) cs->stripe_path);
@@ -341,15 +331,12 @@
  storeCossDirCheckLoadAv(SwapDir * SD, store_op_t op)
  {
      CossInfo *cs = (CossInfo *) SD->fsdata;
-#if USE_AUFSOPS
      float disk_size_weight, current_write_weight;
      int cur_load_interval = (squid_curtime / cs->load_interval) % 2;
      int ql = 0;
-#endif
      int loadav;

      /* Return load, cs->aq.aq_numpending out of MAX_ASYNCOP */
-#if USE_AUFSOPS
      ql = aioQueueSize();
      if (ql == 0)
        loadav = COSS_LOAD_BASE;
@@ -381,10 +368,6 @@

      debug(47, 9) ("storeAufsDirCheckObj: load=%d\n", loadav);
      return loadav;
-#else
-    loadav = cs->aq.aq_numpending * MAX_LOAD_VALUE / MAX_ASYNCOP;
-    return loadav;
-#endif
  }


@@ -396,12 +379,8 @@
  {
      CossInfo *cs = (CossInfo *) SD->fsdata;
      storeCossFreeDeadMemBufs(cs);
-#if USE_AUFSOPS
      /* There's no need to call aioCheckCallbacks() - this will happen  
through the aio notification pipe */
      return 0;
-#else
-    return a_file_callback(&cs->aq);
-#endif
  }

  /* ========== LOCAL FUNCTIONS ABOVE, GLOBAL FUNCTIONS BELOW ========== */
@@ -424,9 +403,6 @@
        SD->map->n_files_in_map, SD->map->max_n_files,
        percent(SD->map->n_files_in_map, SD->map->max_n_files));
  #endif
-#if !USE_AUFSOPS
-    storeAppendPrintf(sentry, "Pending operations: %d out of %d\n",  
cs->aq.aq_numpending, MAX_ASYNCOP);
-#endif
      storeAppendPrintf(sentry, "Flags:");
      if (SD->flags.selected)
        storeAppendPrintf(sentry, " SELECTED");
@@ -822,18 +798,12 @@
  static void storeDirCoss_ParseStripeBuffer(RebuildState * rb);
  static void storeCoss_ConsiderStoreEntry(RebuildState * rb, const  
cache_key * key, StoreEntry * e);

-#if USE_AUFSOPS
  static void
  storeDirCoss_ReadStripeComplete(int fd, void *my_data, const char *buf,  
int aio_return, int aio_errno)
-#else
-static void
-storeDirCoss_ReadStripeComplete(int fd, const char *buf, int r_len, int  
r_errflag, void *my_data)
-#endif
  {
      RebuildState *rb = my_data;
      SwapDir *SD = rb->sd;
      CossInfo *cs = SD->fsdata;
-#if USE_AUFSOPS
      int r_errflag;
      int r_len;
      r_len = aio_return;
@@ -842,7 +812,6 @@
      else
        r_errflag = DISK_OK;
      xmemcpy(cs->rebuild.buf, buf, r_len);
-#endif

      debug(47, 2) ("COSS: %s: stripe %d, read %d bytes, status %d\n",  
stripePath(SD), cs->rebuild.curstripe, r_len, r_errflag);
      cs->rebuild.reading = 0;
@@ -888,12 +857,8 @@
            cs->rebuild.curstripe * 100 / cs->numstripes, 
cs->rebuild.curstripe,  
cs->numstripes);
        rb->report_current += rb->report_interval;
      }
-#if USE_AUFSOPS
      /* XXX this should be a prime candidate to use a modified aioRead  
which doesn't malloc a damned buffer */
      aioRead(cs->fd, (off_t) cs->rebuild.curstripe * COSS_MEMBUF_SZ,  
COSS_MEMBUF_SZ, storeDirCoss_ReadStripeComplete, rb);
-#else
-    a_file_read(&cs->aq, cs->fd, cs->rebuild.buf, COSS_MEMBUF_SZ, (off_t)  
cs->rebuild.curstripe * COSS_MEMBUF_SZ, storeDirCoss_ReadStripeComplete,  
rb);
-#endif
  }

  static void

Modified: branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c
==============================================================================
--- branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c     (original)
+++ branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c     Fri Mar 27 17:17:28 2009
@@ -34,21 +34,11 @@
   */

  #include "squid.h"
-#if HAVE_AIO_H
-#include <aio.h>
-#endif
-#if USE_AUFSOPS
+
  #include "../../libasyncio/async_io.h"
-#else
-#include "async_io.h"
-#endif
  #include "store_coss.h"

-#if USE_AUFSOPS
  static AIOCB storeCossWriteMemBufDone;
-#else
-static DWCB storeCossWriteMemBufDone;
-#endif
  static void storeCossIOCallback(storeIOState * sio, int errflag);
  static char *storeCossMemPointerFromDiskOffset(CossInfo * cs, off_t  
offset, CossMemBuf ** mb);
  static void storeCossMemBufLock(SwapDir * SD, storeIOState * e);
@@ -68,11 +58,7 @@
  /* Handle relocates - temporary routines until readops have been fleshed  
out */
  void storeCossNewPendingRelocate(CossInfo * cs, storeIOState * sio,  
sfileno original_filen, sfileno new_filen);
  CossPendingReloc *storeCossGetPendingReloc(CossInfo * cs, sfileno  
new_filen);
-#if USE_AUFSOPS
  AIOCB storeCossCompletePendingReloc;
-#else
-DRCB storeCossCompletePendingReloc;
-#endif

  /* Read operation code */
  CossReadOp *storeCossCreateReadOp(CossInfo * cs, storeIOState * sio);
@@ -676,11 +662,7 @@
      off_t end;

      /* First, flush pending IO ops */
-#if USE_AUFSOPS
      aioSync();
-#else
-    a_file_syncqueue(&cs->aq);
-#endif

      /* Then, flush any in-memory partial membufs */
      if (!cs->membufs.head)
@@ -731,16 +713,11 @@
         * attached itself somehow. This is why there's a distinction  
between "written"
         * and "writing". Read the rest of the code for more details.
         */
-#if USE_AUFSOPS
        /* XXX The last stripe, for now, ain't the coss stripe size for some  
reason */
        /* XXX This may cause problems later on; worry about figuring it out  
later on */
        //assert(t->diskend - t->diskstart == COSS_MEMBUF_SZ);
        debug(79, 3) ("aioWrite: FD %d: disk start: %" PRIu64 ", size %"  
PRIu64 "\n", cs->fd, (uint64_t) t->diskstart, (uint64_t) t->diskend -  
t->diskstart);
        aioWrite(cs->fd, t->diskstart, &(t->buffer[0]), COSS_MEMBUF_SZ,  
storeCossWriteMemBufDone, t, NULL);
-#else
-       a_file_write(&cs->aq, cs->fd, t->diskstart, &t->buffer,
-           COSS_MEMBUF_SZ, storeCossWriteMemBufDone, t, NULL);
-#endif
      } else {
        /* No need to write, just mark as written and free */
        t->flags.written = 1;
@@ -806,28 +783,18 @@
   * locked for read between the initial membuf write and the completion of  
the disk
   * write.
   */
-#if USE_AUFSOPS
  static void
  storeCossWriteMemBufDone(int fd, void *my_data, const char *buf, int  
aio_return, int aio_errno)
-#else
-static void
-storeCossWriteMemBufDone(int fd, int r_errflag, size_t r_len, void  
*my_data)
-#endif
  {
      CossMemBuf *t = my_data;
      CossInfo *cs = (CossInfo *) t->SD->fsdata;
      int errflag;
      int len;
-#if USE_AUFSOPS
      len = aio_return;
      if (aio_errno)
        errflag = aio_errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
      else
        errflag = DISK_OK;
-#else
-    len = r_len;
-    errflag = r_errflag;
-#endif

      debug(79, 3) ("storeCossWriteMemBufDone: stripe %d, buf %p,  
len %ld\n", t->stripe, t, (long int) len);
      if (errflag) {
@@ -1081,18 +1048,9 @@

      disk_offset = storeCossFilenoToDiskOffset(original_filen, cs);
      debug(79, 3) ("COSS Pending Relocate: size %" PRINTF_OFF_T ",  
disk_offset %" PRIu64 "\n", (squid_off_t) sio->e->swap_file_sz, (int64_t)  
disk_offset);
-#if USE_AUFSOPS
      /* NOTE: the damned buffer isn't passed into aioRead! */
      debug(79, 3) ("COSS: aioRead: FD %d, from %d -> %d, offset %"  
PRIu64 ", len: %ld\n", cs->fd, pr->original_filen, pr->new_filen, (int64_t)  
disk_offset, (long int) pr->len);
      aioRead(cs->fd, (off_t) disk_offset, pr->len,  
storeCossCompletePendingReloc, pr);
-#else
-    a_file_read(&cs->aq, cs->fd,
-       p,
-       pr->len,
-       disk_offset,
-       storeCossCompletePendingReloc,
-       pr);
-#endif
  }

  CossPendingReloc *
@@ -1111,33 +1069,21 @@
      }
      return NULL;
  }
-#if USE_AUFSOPS
  void
  storeCossCompletePendingReloc(int fd, void *my_data, const char *buf, int  
aio_return, int aio_errno)
-#else
-void
-storeCossCompletePendingReloc(int fd, const char *buf, int r_len, int  
r_errflag, void *my_data)
-#endif
  {
      CossPendingReloc *pr = my_data;
      CossReadOp *op;
      CossInfo *cs = pr->cs;
      int stripe;
      int errflag, len;
-#if USE_AUFSOPS
      char *p;
-#endif

-#if USE_AUFSOPS
      len = aio_return;
      if (aio_errno)
        errflag = aio_errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
      else
        errflag = DISK_OK;
-#else
-    errflag = r_errflag;
-    len = r_len;
-#endif

      debug(79, 3) ("storeCossCompletePendingReloc: %p\n", pr);
      assert(cbdataValid(pr));
@@ -1154,12 +1100,10 @@
        coss_stats.read.success++;
      }
      /* aufs aioRead() doesn't take a buffer, it reads into its own. Grr */
-#if USE_AUFSOPS
      p = storeCossMemPointerFromDiskOffset(cs,  
storeCossFilenoToDiskOffset(pr->new_filen, cs), NULL);
      assert(p != NULL);
      assert(p == pr->p);
      xmemcpy(p, buf, len);
-#endif

      /* Nope, we're not a pending relocate anymore! */
      dlinkDelete(&pr->node, &cs->pending_relocs);

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to