Revision: 14248
Author: adrian.chadd
Date: Sun Jul 26 20:14:38 2009
Log: Address issue 47 - teach COSS to begin at the last written stripe  
after startup

Introduce some very simple logic to track the most recent object written to  
disk
based on timestamp and start the stripe writing process roughly there.

The logic doesn't correctly identify the last written stripe (as stripes  
aren't
necessarily written out in order, nor are object timestamps written into the
store in order!) but these changes do properly initialise the initial  
current
fields - stripe, membuf and disk position. The particular logic used to  
determine
the current stripe can thus change at a later date.

Also make certain all coss allocations fail until the current stripe field
is initialised - just to be on the safe side.


http://code.google.com/p/lusca-cache/source/detail?r=14248

Modified:
  /branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c
  /branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c
  /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.c
  /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.h

=======================================
--- /branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c   Wed May 20 23:46:21  
2009
+++ /branches/LUSCA_HEAD/src/fs/coss/store_dir_coss.c   Sun Jul 26 20:14:38  
2009
@@ -357,6 +357,7 @@
        storeAppendPrintf(sentry, " READ-ONLY");
      storeAppendPrintf(sentry, "\n");
      storeAppendPrintf(sentry, "Pending Relocations: %d\n",  
cs->pending_reloc_count);
+    storeAppendPrintf(sentry, "Current Stripe: %d\n", cs->curstripe);
      membufsDump(cs, sentry);
  }

@@ -416,7 +417,7 @@
      sd->log.clean.nextentry = NULL;
      sd->log.clean.done = NULL;

-    cs->current_offset = 0;
+    cs->current_offset = -1;
      cs->fd = -1;
      cs->swaplog_fd = -1;
      cs->numcollisions = 0;
=======================================
--- /branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c    Fri Jul 17 17:05:17  
2009
+++ /branches/LUSCA_HEAD/src/fs/coss/store_io_coss.c    Sun Jul 26 20:14:38  
2009
@@ -134,6 +134,10 @@
      sfileno f;
      sfileno checkf;

+    /* This needs to be explicitly set to something after rebuilding has  
finished */
+    if (cs->current_offset < 0)
+        return -1;
+
      /* Make sure we chcek collisions if reallocating */
      if (which == COSS_ALLOC_REALLOC) {
        checkf = e->swap_filen;
@@ -946,9 +950,10 @@
       * The rebuild logic doesn't 'know' to pad out the current
       * offset to make it a multiple of COSS_MEMBUF_SZ.
       */
-    newmb = storeCossCreateMemBuf(sd, 0, -1, NULL);
+    newmb = storeCossCreateMemBuf(sd, cs->curstripe, -1, NULL);
      assert(!cs->current_membuf);
      cs->current_membuf = newmb;
+    cs->current_offset = cs->current_membuf->diskstart;

      newmb = storeCossCreateMemOnlyBuf(sd);
      assert(!cs->current_memonly_membuf);
=======================================
--- /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.c       Wed Jul 22  
07:37:20 2009
+++ /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.c       Sun Jul 26  
20:14:38 2009
@@ -48,7 +48,6 @@
      RebuildState *rb = data;
      SwapDir *SD = rb->sd;
      CossInfo *cs = SD->fsdata;
-    storeCossStartMembuf(SD);
      store_dirs_rebuilding--;
      storeRebuildComplete(&rb->counts);
      debug(47, 1) ("COSS: %s: Rebuild Completed\n", stripePath(SD));
@@ -58,8 +57,22 @@
      safe_free(rb->rbuf.buf);
      debug(47, 1) ("  %d objects scanned, %d objects relocated, %d objects  
fresher, %d objects ignored\n",
          rb->counts.scancount, rb->cosscounts.reloc,  
rb->cosscounts.fresher, rb->cosscounts.unknown);
+    if (rb->recent.timestamp > -1 && rb->recent.swap_filen > -1) {
+       cs->curstripe = storeCossFilenoToStripe(cs, rb->recent.swap_filen);
+        debug(47, 1) ("  Current stripe set to %d\n", cs->curstripe);
+    }
+    storeCossStartMembuf(SD);
      cbdataFree(rb);
  }
+
+static void
+storeCoss_updateRecent(RebuildState *rb, storeSwapLogData *d)
+{
+       if (d->timestamp < rb->recent.timestamp)
+               return;
+       rb->recent.timestamp = d->timestamp;
+       rb->recent.swap_filen = d->swap_filen;
+}

  static void
  storeCoss_AddStoreEntry(RebuildState * rb, const cache_key * key,  
storeSwapLogData *d)
@@ -133,6 +146,7 @@
        rb->cosscounts.new++;
        debug(47, 3) ("COSS: Adding filen %d\n", d->swap_filen);
        /* no clash! woo, can add and forget */
+       storeCoss_updateRecent(rb, d);
        storeCoss_AddStoreEntry(rb, key, d);
        return;
      }
@@ -148,6 +162,7 @@
        rb->cosscounts.fresher++;
        storeCoss_DeleteStoreEntry(rb, key, oe);
        oe = NULL;
+       storeCoss_updateRecent(rb, d);
        storeCoss_AddStoreEntry(rb, key, d);
        return;
      }
@@ -160,6 +175,7 @@
        rb->cosscounts.reloc++;
        storeCoss_DeleteStoreEntry(rb, key, oe);
        oe = NULL;
+       storeCoss_updateRecent(rb, d);
        storeCoss_AddStoreEntry(rb, key, d);
        return;
      }
@@ -284,6 +300,8 @@
      rb = cbdataAlloc(RebuildState);
      rb->sd = sd;
      rb->flags.clean = (unsigned int) clean;
+    rb->recent.swap_filen = -1;
+    rb->recent.timestamp = -1;
      debug(20, 1) ("Rebuilding COSS storage in %s (DIRTY)\n",  
stripePath(sd));
      store_dirs_rebuilding++;
      storeDirCoss_StartDiskRebuild(rb);
=======================================
--- /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.h       Wed Jul 22  
07:37:20 2009
+++ /branches/LUSCA_HEAD/src/fs/coss/store_rebuild_coss.h       Sun Jul 26  
20:14:38 2009
@@ -10,6 +10,10 @@
          unsigned int clean:1;
      } flags;
      struct _store_rebuild_data counts;
+    struct {
+       sfileno swap_filen;
+       time_t timestamp;
+    } recent;
      struct {
          int new;
          int reloc;

--~--~---------~--~----~------------~-------~--~----~
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