Author: adrian.chadd
Date: Thu Jul  9 22:57:32 2009
New Revision: 14175

Modified:
    playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.c
    playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.h

Log:
Remove the old unused rebuild code.



Modified: playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.c
==============================================================================
--- playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.c       
(original)
+++ playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.c       Thu Jul 
  
9 22:57:32 2009
@@ -83,95 +83,6 @@
      cbdataFree(rb);
  }

-#if 0
-static int
-storeAufsDirGetNextFile(RebuildState * rb, sfileno * filn_p, int *size)
-{
-    SwapDir *SD = rb->sd;
-    squidaioinfo_t *aioinfo = (squidaioinfo_t *) SD->fsdata;
-    int fd = -1;
-    int used = 0;
-    int dirs_opened = 0;
-    debug(47, 3) ("storeAufsDirGetNextFile: flag=%d, %d: /%02X/%02X\n",
-       rb->flags.init,
-       rb->sd->index,
-       rb->curlvl1,
-       rb->curlvl2);
-    if (rb->done)
-       return -2;
-    while (fd < 0 && rb->done == 0) {
-       fd = -1;
-       if (0 == rb->flags.init) {      /* initialize, open first file */
-           rb->done = 0;
-           rb->curlvl1 = 0;
-           rb->curlvl2 = 0;
-           rb->in_dir = 0;
-           rb->flags.init = 1;
-           assert(Config.cacheSwap.n_configured > 0);
-       }
-       if (0 == rb->in_dir) {  /* we need to read in a new directory */
-           snprintf(rb->fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X",
-               rb->sd->path,
-               rb->curlvl1, rb->curlvl2);
-           if (dirs_opened)
-               return -1;
-           rb->td = opendir(rb->fullpath);
-           dirs_opened++;
-           if (rb->td == NULL) {
-               debug(47, 1) ("storeAufsDirGetNextFile: opendir: %s: %s\n",
-                   rb->fullpath, xstrerror());
-           } else {
-               rb->entry = readdir(rb->td);    /* skip . and .. */
-               rb->entry = readdir(rb->td);
-               if (rb->entry == NULL && errno == ENOENT)
-                   debug(47, 1) ("storeAufsDirGetNextFile: directory does not  
exist!.\n");
-               debug(47, 3) ("storeAufsDirGetNextFile: Directory %s\n", 
rb->fullpath);
-           }
-       }
-       if (rb->td != NULL && (rb->entry = readdir(rb->td)) != NULL) {
-           rb->in_dir++;
-           if (sscanf(rb->entry->d_name, "%x", &rb->fn) != 1) {
-               debug(47, 3) ("storeAufsDirGetNextFile: invalid %s\n",
-                   rb->entry->d_name);
-               continue;
-           }
-           if (!storeAufsFilenoBelongsHere(rb->fn, rb->sd->index, rb->curlvl1, 
 
rb->curlvl2)) {
-               debug(47, 3) ("storeAufsDirGetNextFile: %08X does not belong  
in %d/%d/%d\n",
-                   rb->fn, rb->sd->index, rb->curlvl1, rb->curlvl2);
-               continue;
-           }
-           used = storeAufsDirMapBitTest(SD, rb->fn);
-           if (used) {
-               debug(47, 3) ("storeAufsDirGetNextFile: Locked, continuing with 
 
next.\n");
-               continue;
-           }
-           snprintf(rb->fullfilename, SQUID_MAXPATHLEN, "%s/%s",
-               rb->fullpath, rb->entry->d_name);
-           debug(47, 3) ("storeAufsDirGetNextFile: Opening %s\n",  
rb->fullfilename);
-           fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY);
-           if (fd < 0)
-               debug(47, 1) ("storeAufsDirGetNextFile: %s: %s\n", 
rb->fullfilename,  
xstrerror());
-           else
-               store_open_disk_fd++;
-           continue;
-       }
-       if (rb->td != NULL)
-           closedir(rb->td);
-       rb->td = NULL;
-       rb->in_dir = 0;
-       if (++rb->curlvl2 < aioinfo->l2)
-           continue;
-       rb->curlvl2 = 0;
-       if (++rb->curlvl1 < aioinfo->l1)
-           continue;
-       rb->curlvl1 = 0;
-       rb->done = 1;
-    }
-    *filn_p = rb->fn;
-    return fd;
-}
-#endif
-
  /* Add a new object to the cache with empty memory copy and pointer to disk
   * use to rebuild store from disk. */
  static StoreEntry *
@@ -215,173 +126,6 @@
      return e;
  }

-#if 0
-static void
-storeAufsDirRebuildFromDirectory(void *data)
-{
-    RebuildState *rb = data;
-    SwapDir *SD = rb->sd;
-    LOCAL_ARRAY(char, hdr_buf, SM_PAGE_SIZE);
-    StoreEntry *e = NULL;
-    StoreEntry tmpe;
-    cache_key key[SQUID_MD5_DIGEST_LENGTH];
-    sfileno filn = 0;
-    int count;
-    int size;
-    struct stat sb;
-    int swap_hdr_len;
-    int fd = -1;
-    tlv *tlv_list;
-    tlv *t;
-    assert(rb != NULL);
-    debug(47, 3) ("storeAufsDirRebuildFromDirectory: DIR #%d\n",  
rb->sd->index);
-    for (count = 0; count < rb->speed; count++) {
-       assert(fd == -1);
-       fd = storeAufsDirGetNextFile(rb, &filn, &size);
-       if (fd == -2) {
-           storeAufsDirRebuildComplete(rb);
-           return;
-       } else if (fd < 0) {
-           continue;
-       }
-       assert(fd > -1);
-       /* lets get file stats here */
-       if (fstat(fd, &sb) < 0) {
-           debug(47, 1) ("storeAufsDirRebuildFromDirectory: fstat(FD %d): 
%s\n",
-               fd, xstrerror());
-           file_close(fd);
-           store_open_disk_fd--;
-           fd = -1;
-           continue;
-       }
-       if ((++rb->counts.scancount & 0xFFFF) == 0)
-           debug(47, 3) ("  %s %7d files opened so far.\n",
-               rb->sd->path, rb->counts.scancount);
-       debug(47, 9) ("file_in: fd=%d %08X\n", fd, filn);
-       CommStats.syscalls.disk.reads++;
-       if (FD_READ_METHOD(fd, hdr_buf, SM_PAGE_SIZE) < 0) {
-           debug(47, 1) ("storeAufsDirRebuildFromDirectory: read(FD %d): %s\n",
-               fd, xstrerror());
-           file_close(fd);
-           store_open_disk_fd--;
-           fd = -1;
-           continue;
-       }
-       file_close(fd);
-       store_open_disk_fd--;
-       fd = -1;
-       swap_hdr_len = 0;
-#if USE_TRUNCATE
-       if (sb.st_size == 0)
-           continue;
-#endif
-       tlv_list = storeSwapMetaUnpack(hdr_buf, &swap_hdr_len);
-       if (tlv_list == NULL) {
-           debug(47, 1) ("storeAufsDirRebuildFromDirectory: failed to get meta 
 
data\n");
-           /* XXX shouldn't this be a call to storeAufsUnlink ? */
-           storeAufsDirUnlinkFile(SD, filn);
-           continue;
-       }
-       debug(47, 3) ("storeAufsDirRebuildFromDirectory: successful swap meta  
unpacking\n");
-       memset(key, '\0', SQUID_MD5_DIGEST_LENGTH);
-       memset(&tmpe, '\0', sizeof(StoreEntry));
-       for (t = tlv_list; t; t = t->next) {
-           switch (t->type) {
-           case STORE_META_KEY:
-               assert(t->length == SQUID_MD5_DIGEST_LENGTH);
-               xmemcpy(key, t->value, SQUID_MD5_DIGEST_LENGTH);
-               break;
-#if SIZEOF_SQUID_FILE_SZ == SIZEOF_SIZE_T
-           case STORE_META_STD:
-               assert(t->length == STORE_HDR_METASIZE);
-               xmemcpy(&tmpe.timestamp, t->value, STORE_HDR_METASIZE);
-               break;
-#else
-           case STORE_META_STD_LFS:
-               assert(t->length == STORE_HDR_METASIZE);
-               xmemcpy(&tmpe.timestamp, t->value, STORE_HDR_METASIZE);
-               break;
-           case STORE_META_STD:
-               assert(t->length == STORE_HDR_METASIZE_OLD);
-               {
-                   struct {
-                       time_t timestamp;
-                       time_t lastref;
-                       time_t expires;
-                       time_t lastmod;
-                       size_t swap_file_sz;
-                       u_short refcount;
-                       u_short flags;
-                   }     *tmp = t->value;
-                   assert(sizeof(*tmp) == STORE_HDR_METASIZE_OLD);
-                   tmpe.timestamp = tmp->timestamp;
-                   tmpe.lastref = tmp->lastref;
-                   tmpe.expires = tmp->expires;
-                   tmpe.lastmod = tmp->lastmod;
-                   tmpe.swap_file_sz = tmp->swap_file_sz;
-                   tmpe.refcount = tmp->refcount;
-                   tmpe.flags = tmp->flags;
-               }
-               break;
-#endif
-           default:
-               break;
-           }
-       }
-       storeSwapTLVFree(tlv_list);
-       tlv_list = NULL;
-       if (storeKeyNull(key)) {
-           debug(47, 1) ("storeAufsDirRebuildFromDirectory: NULL key\n");
-           storeAufsDirUnlinkFile(SD, filn);
-           continue;
-       }
-       tmpe.hash.key = key;
-       /* check sizes */
-       if (tmpe.swap_file_sz == 0) {
-           tmpe.swap_file_sz = sb.st_size;
-       } else if (tmpe.swap_file_sz == sb.st_size - swap_hdr_len) {
-           tmpe.swap_file_sz = sb.st_size;
-       } else if (tmpe.swap_file_sz != sb.st_size) {
-           debug(47, 1) ("storeAufsDirRebuildFromDirectory: SIZE  
MISMATCH %ld!=%ld\n",
-               (long int) tmpe.swap_file_sz, (long int) sb.st_size);
-           storeAufsDirUnlinkFile(SD, filn);
-           continue;
-       }
-       if (EBIT_TEST(tmpe.flags, KEY_PRIVATE)) {
-           storeAufsDirUnlinkFile(SD, filn);
-           rb->counts.badflags++;
-           continue;
-       }
-       e = storeGet(key);
-       if (e && e->lastref >= tmpe.lastref) {
-           /* key already exists, current entry is newer */
-           /* keep old, ignore new */
-           rb->counts.dupcount++;
-           continue;
-       } else if (NULL != e) {
-           /* URL already exists, this swapfile not being used */
-           /* junk old, load new */
-           storeRelease(e);    /* release old entry */
-           rb->counts.dupcount++;
-       }
-       rb->counts.objcount++;
-       storeEntryDump(&tmpe, 5);
-       e = storeAufsDirAddDiskRestore(SD, key,
-           filn,
-           tmpe.swap_file_sz,
-           tmpe.expires,
-           tmpe.timestamp,
-           tmpe.lastref,
-           tmpe.lastmod,
-           tmpe.refcount,      /* refcount */
-           tmpe.flags,         /* flags */
-           (int) rb->flags.clean);
-       storeDirSwapLog(e, SWAP_LOG_ADD);
-    }
-    eventAdd("storeRebuild", storeAufsDirRebuildFromDirectory, rb, 0.0, 1);
-}
-#endif
-
  static int
  storeAufsDirRebuildFromSwapLogObject(RebuildState *rb, storeSwapLogData s)
  {
@@ -511,97 +255,6 @@
  }

  static void
-storeAufsDirRebuildFromSwapLog(void *data)
-{
-    RebuildState *rb = data;
-    char buf[256];
-    storeSwapLogData s;
-    int count;
-    size_t ss;
-
-    assert(rb != NULL);
-    if (rb->flags.old_swaplog_entry_size)
-       ss = sizeof(storeSwapLogDataOld);
-    else
-       ss = sizeof(storeSwapLogData);
-    assert(ss < sizeof(buf));
-
-    /* load a number of objects per invocation */
-    for (count = 0; count < rb->speed; count++) {
-       /* Read the swaplog entry, new or old */
-       /* XXX this will be slow - one read() per entry .. */
-       /* XXX so obviously it needs to be changed and quickly .. */
-       if (read(rb->log_fd, buf, ss) != ss) {
-           storeAufsDirRebuildComplete(rb);
-           return;
-       }
-       rb->n_read++;
-
-       /* Is it an old-style entry? convert it if needed */
-       if (rb->flags.old_swaplog_entry_size) {
-               (void) storeSwapLogUpgradeEntry(&s, (storeSwapLogDataOld *) 
buf);
-       } else {
-               memcpy(&s, buf, sizeof(s));
-       }
-       storeAufsDirRebuildFromSwapLogObject(rb, s);
-
-       if ((++rb->counts.scancount & 0xFFF) == 0) {
-           struct stat sb;
-           if (0 == fstat(rb->log_fd, &sb))
-               storeRebuildProgress(rb->sd->index, (int) sb.st_size / ss, 
rb->n_read);
-       }
-    }
-    eventAdd("storeRebuild", storeAufsDirRebuildFromSwapLog, rb, 0.0, 1);
-}
-
-#if 0
-static void
-storeAufsDirRebuildFromSwapLogCheckVersion(void *data)
-{
-    RebuildState *rb = data;
-    storeSwapLogHeader hdr;
-
-    /* XXX should be aioRead() with a callback.. */
-    if (read(rb->log_fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
-       storeAufsDirRebuildComplete(rb);
-       return;
-    }
-    if (hdr.op == SWAP_LOG_VERSION) {
-       if (lseek(rb->log_fd, hdr.record_size, SEEK_SET) < 0) {
-           storeAufsDirRebuildComplete(rb);
-           return;
-       }
-       if (hdr.version == 1 && hdr.record_size == sizeof(storeSwapLogData)) {
-           rb->flags.old_swaplog_entry_size = 0;
-           eventAdd("storeRebuild", storeAufsDirRebuildFromSwapLog, rb, 0.0, 
1);
-           return;
-       }
-#if SIZEOF_SQUID_FILE_SZ != SIZEOF_SIZE_T
-       if (hdr.version == 1 && hdr.record_size == sizeof(storeSwapLogDataOld)) 
{
-           debug(47, 1) ("storeAufsDirRebuildFromSwapLog: Found current 
version  
but without large file support. Upgrading\n");
-           rb->flags.old_swaplog_entry_size = 1;
-           eventAdd("storeRebuild", storeAufsDirRebuildFromSwapLog, rb, 0.0, 
1);
-           return;
-       }
-#endif
-       debug(47, 1) ("storeAufsDirRebuildFromSwapLog: Unsupported swap.state  
version %d size %d\n",
-           hdr.version, hdr.record_size);
-       storeAufsDirRebuildComplete(rb);
-       return;
-    }
-    lseek(rb->log_fd, SEEK_SET, 0);
-    debug(47, 1) ("storeAufsDirRebuildFromSwapLog: Old version detected.  
Upgrading\n");
-#if SIZEOF_SQUID_FILE_SZ == SIZEOF_SIZE_T
-    rb->flags.old_swaplog_entry_size = 0;
-    eventAdd("storeRebuild", storeAufsDirRebuildFromSwapLog, rb, 0.0, 1);
-#else
-    rb->flags.old_swaplog_entry_size = 1;
-    eventAdd("storeRebuild", storeAufsDirRebuildFromSwapLog, rb, 0.0, 1);
-#endif
-}
-#endif
-
-static void
  storeAufsRebuildHelperRead(int fd, void *data)
  {
        RebuildState *rb = data;
@@ -676,9 +329,6 @@
      int clean = 0;
      int zero = 0;
      int log_fd;
-#if 0
-    EVH *func = NULL;
-#endif
      CBDATA_INIT_TYPE(RebuildState);
      rb = cbdataAlloc(RebuildState);
      rb->sd = sd;
@@ -714,29 +364,6 @@
      /* aaand we begin */
      log_fd = storeAufsDirOpenTmpSwapLog(sd, &clean, &zero);
      file_close(log_fd);       /* We don't need this open anyway..? */
-
-#if 0
-
-    rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
-    /*
-     * If the swap.state file exists in the cache_dir, then
-     * we'll use storeAufsDirRebuildFromSwapLog(), otherwise we'll
-     * use storeAufsDirRebuildFromDirectory() to open up each file
-     * and suck in the meta data.
-     */
-    if (! log_fd || zero) {
-       if (log_fd)
-           file_close(log_fd);
-       func = storeAufsDirRebuildFromDirectory;
-    } else {
-       func = storeAufsDirRebuildFromSwapLogCheckVersion;
-       rb->log_fd = log_fd;
-       rb->flags.clean = (unsigned int) clean;
-    }
-#endif
      debug(47, 1) ("Rebuilding storage in %s (%s)\n", sd->path,  
clean ? "CLEAN" : "DIRTY");
      store_dirs_rebuilding++;
-#if 0
-    eventAdd("storeRebuild", func, rb, 0.0, 1);
-#endif
  }

Modified: playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.h
==============================================================================
--- playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.h       
(original)
+++ playpen/LUSCA_HEAD_storework/src/fs/aufs/store_rebuild_aufs.h       Thu Jul 
  
9 22:57:32 2009
@@ -6,23 +6,11 @@
      SwapDir *sd;
      int n_read;
      int log_fd;
-    int speed;
-    int curlvl1;
-    int curlvl2;
      struct {
          unsigned int clean:1;
          unsigned int init:1;
-        unsigned int old_swaplog_entry_size:1;
      } flags;
-    int done;
-    int in_dir;
-    int fn;
-    struct dirent *entry;
-    DIR *td;
-    char fullpath[SQUID_MAXPATHLEN];
-    char fullfilename[SQUID_MAXPATHLEN];
      struct _store_rebuild_data counts;
-
      struct {
        int r_fd, w_fd;
        pid_t pid;

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