Index: src/fs/coss/store_coss.h =================================================================== RCS file: /squid/squid/src/fs/coss/store_coss.h,v retrieving revision 1.12 diff -u -p -r1.12 store_coss.h --- src/fs/coss/store_coss.h 16 Aug 2006 02:33:22 -0000 1.12 +++ src/fs/coss/store_coss.h 22 Sep 2006 11:59:02 -0000 @@ -166,6 +166,7 @@ struct _cossinfo { int nummemstripes; struct _cossstripe *memstripes; int curmemstripe; + const char *stripe_path; }; struct _cossindex { @@ -217,6 +218,7 @@ extern void storeCossStartMembuf(SwapDir extern void membufsDump(CossInfo * cs, StoreEntry * e); extern void storeCossFreeDeadMemBufs(CossInfo * cs); extern int storeCossFilenoToStripe(CossInfo * cs, sfileno filen); +extern char const *stripePath(SwapDir * sd); extern struct _coss_stats coss_stats; Index: src/fs/coss/store_dir_coss.c =================================================================== RCS file: /squid/squid/src/fs/coss/store_dir_coss.c,v retrieving revision 1.58 diff -u -p -r1.58 store_dir_coss.c --- src/fs/coss/store_dir_coss.c 17 Sep 2006 09:29:26 -0000 1.58 +++ src/fs/coss/store_dir_coss.c 22 Sep 2006 11:59:03 -0000 @@ -125,6 +125,24 @@ static struct cache_dir_option options[] struct _coss_stats coss_stats; +char const * +stripePath(SwapDir * sd) +{ + CossInfo *cs = (CossInfo *) sd->fsdata; + char pathtmp[SQUID_MAXPATHLEN]; + struct stat st; + + if (!cs->stripe_path) { + strcpy(pathtmp, sd->path); + if (stat(sd->path, &st) == 0) { + if (S_ISDIR(st.st_mode)) + strcat(pathtmp, "/stripe"); + } + cs->stripe_path = xstrdup(pathtmp); + } + return cs->stripe_path; +} + static char * storeCossDirSwapLogFile(SwapDir * sd, const char *ext) { @@ -198,9 +216,9 @@ storeCossDirInit(SwapDir * sd) #else a_file_setupqueue(&cs->aq); #endif - cs->fd = file_open(sd->path, O_RDWR | O_CREAT | O_BINARY); + cs->fd = file_open(stripePath(sd), O_RDWR | O_CREAT | O_BINARY); if (cs->fd < 0) { - debug(79, 1) ("%s: %s\n", sd->path, xstrerror()); + debug(79, 1) ("%s: %s\n", stripePath(sd), xstrerror()); fatal("storeCossDirInit: Failed to open a COSS file."); } storeCossDirOpenSwapLog(sd); @@ -263,7 +281,7 @@ storeCossRebuildComplete(void *data) store_dirs_rebuilding--; storeCossDirCloseTmpSwapLog(SD); storeRebuildComplete(&rb->counts); - debug(47, 1) ("COSS: %s: Rebuild Completed\n", SD->path); + debug(47, 1) ("COSS: %s: Rebuild Completed\n", stripePath(SD)); cs->rebuild.rebuilding = 0; 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); @@ -284,7 +302,7 @@ storeCossDirRebuild(SwapDir * sd) rb->flags.clean = (unsigned int) clean; fp = storeCossDirOpenTmpSwapLog(sd, &clean, &zero); fclose(fp); - debug(20, 1) ("Rebuilding COSS storage in %s (DIRTY)\n", sd->path); + debug(20, 1) ("Rebuilding COSS storage in %s (DIRTY)\n", stripePath(sd)); store_dirs_rebuilding++; storeDirCoss_StartDiskRebuild(rb); } @@ -547,7 +565,7 @@ storeCossDirSwapLog(const SwapDir * sd, static void storeCossDirNewfs(SwapDir * sd) { - debug(47, 3) ("Creating swap space in %s\n", sd->path); + debug(47, 3) ("Creating swap space in %s\n", stripePath(sd)); } /* we are shutting down, flush all membufs to disk */ @@ -555,7 +573,7 @@ static void storeCossDirShutdown(SwapDir * SD) { CossInfo *cs = (CossInfo *) SD->fsdata; - debug(47, 1) ("COSS: %s: syncing\n", SD->path); + debug(47, 1) ("COSS: %s: syncing\n", stripePath(SD)); #if USE_AUFSOPS aioSync(SD); @@ -566,6 +584,7 @@ storeCossDirShutdown(SwapDir * SD) #endif file_close(cs->fd); cs->fd = -1; + xfree((void *)cs->stripe_path); if (cs->swaplog_fd > -1) { file_close(cs->swaplog_fd); @@ -1112,10 +1131,10 @@ storeDirCoss_ReadStripeComplete(int fd, xmemcpy(cs->rebuild.buf, buf, r_len); #endif - debug(47, 2) ("COSS: %s: stripe %d, read %d bytes, status %d\n", SD->path, cs->rebuild.curstripe, r_len, r_errflag); + 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; if (r_errflag != DISK_OK) { - debug(47, 2) ("COSS: %s: stripe %d: error! Ignoring objects in this stripe.\n", SD->path, cs->rebuild.curstripe); + debug(47, 2) ("COSS: %s: stripe %d: error! Ignoring objects in this stripe.\n", stripePath(SD), cs->rebuild.curstripe); goto nextstripe; } cs->rebuild.buflen = r_len; @@ -1132,7 +1151,7 @@ storeDirCoss_ReadStripeComplete(int fd, cs->rebuild.curstripe++; if (cs->rebuild.curstripe >= cs->numstripes) { /* Completed the rebuild - move onto the next phase */ - debug(47, 2) ("COSS: %s: completed reading the stripes.\n", SD->path); + debug(47, 2) ("COSS: %s: completed reading the stripes.\n", stripePath(SD)); storeCossRebuildComplete(rb); return; } else { @@ -1150,9 +1169,9 @@ storeDirCoss_ReadStripe(RebuildState * r assert(cs->rebuild.reading == 0); cs->rebuild.reading = 1; /* Use POSIX AIO for now */ - debug(47, 2) ("COSS: %s: reading stripe %d\n", SD->path, cs->rebuild.curstripe); + debug(47, 2) ("COSS: %s: reading stripe %d\n", stripePath(SD), cs->rebuild.curstripe); if (cs->rebuild.curstripe > rb->report_current) { - debug(47, 1) ("COSS: %s: Rebuilding (%d %% completed - %d/%d stripes)\n", SD->path, + debug(47, 1) ("COSS: %s: Rebuilding (%d %% completed - %d/%d stripes)\n", stripePath(SD), cs->rebuild.curstripe * 100 / cs->numstripes, cs->rebuild.curstripe, cs->numstripes); rb->report_current += rb->report_interval; } @@ -1178,7 +1197,7 @@ storeDirCoss_StartDiskRebuild(RebuildSta cs->rebuild.buf = xmalloc(COSS_MEMBUF_SZ); rb->report_interval = cs->numstripes / COSS_REPORT_INTERVAL; rb->report_current = 0; - debug(47, 2) ("COSS: %s: Beginning disk rebuild.\n", SD->path); + debug(47, 2) ("COSS: %s: Beginning disk rebuild.\n", stripePath(SD)); storeDirCoss_ReadStripe(rb); } @@ -1205,7 +1224,7 @@ storeDirCoss_ParseStripeBuffer(RebuildSt assert(cs->rebuild.buf != NULL); if (cs->rebuild.buflen == 0) { - debug(47, 3) ("COSS: %s: stripe %d: read 0 bytes, skipping stripe\n", SD->path, cs->rebuild.curstripe); + debug(47, 3) ("COSS: %s: stripe %d: read 0 bytes, skipping stripe\n", stripePath(SD), cs->rebuild.curstripe); return; } while (j < cs->rebuild.buflen) { @@ -1214,11 +1233,11 @@ storeDirCoss_ParseStripeBuffer(RebuildSt /* XXX there's no bounds checking on the buffer being passed into storeSwapMetaUnpack! */ tlv_list = storeSwapMetaUnpack(cs->rebuild.buf + j, &bl); if (tlv_list == NULL) { - debug(47, 3) ("COSS: %s: stripe %d: offset %d gives NULL swapmeta data; end of stripe\n", SD->path, cs->rebuild.curstripe, j); + debug(47, 3) ("COSS: %s: stripe %d: offset %d gives NULL swapmeta data; end of stripe\n", stripePath(SD), cs->rebuild.curstripe, j); return; } filen = (off_t) j / (off_t) blocksize + (off_t) ((off_t) cs->rebuild.curstripe * (off_t) COSS_MEMBUF_SZ / (off_t) blocksize); - debug(47, 3) ("COSS: %s: stripe %d: filen %d: header size %d\n", SD->path, cs->rebuild.curstripe, filen, bl); + debug(47, 3) ("COSS: %s: stripe %d: filen %d: header size %d\n", stripePath(SD), cs->rebuild.curstripe, filen, bl); /* COSS objects will have an object size written into the metadata */ memset(&tmpe, 0, sizeof(tmpe)); @@ -1273,7 +1292,7 @@ storeDirCoss_ParseStripeBuffer(RebuildSt } /* Make sure we have an object; if we don't then it may be an indication of trouble */ if (l == NULL) { - debug(47, 3) ("COSS: %s: stripe %d: Object with no size; end of stripe\n", SD->path, cs->rebuild.curstripe); + debug(47, 3) ("COSS: %s: stripe %d: Object with no size; end of stripe\n", stripePath(SD), cs->rebuild.curstripe); storeSwapTLVFree(tlv_list); return; } @@ -1282,13 +1301,13 @@ storeDirCoss_ParseStripeBuffer(RebuildSt * we've just been informed about */ if ((cs->rebuild.buflen - j) < (len + bl)) { - debug(47, 3) ("COSS: %s: stripe %d: Not enough data in this stripe for this object, bye bye.\n", SD->path, cs->rebuild.curstripe); + debug(47, 3) ("COSS: %s: stripe %d: Not enough data in this stripe for this object, bye bye.\n", stripePath(SD), cs->rebuild.curstripe); storeSwapTLVFree(tlv_list); return; } /* Houston, we have an object */ if (storeKeyNull(key)) { - debug(47, 3) ("COSS: %s: stripe %d: null data, next!\n", SD->path, cs->rebuild.curstripe); + debug(47, 3) ("COSS: %s: stripe %d: null data, next!\n", stripePath(SD), cs->rebuild.curstripe); goto nextobject; } rb->counts.scancount++; @@ -1298,11 +1317,11 @@ storeDirCoss_ParseStripeBuffer(RebuildSt tmpe.swap_file_sz = len + bl; } if (tmpe.swap_file_sz != (len + bl)) { - debug(47, 3) ("COSS: %s: stripe %d: file size mismatch (%" PRINTF_OFF_T " != %" PRINTF_OFF_T ")\n", SD->path, cs->rebuild.curstripe, tmpe.swap_file_sz, len); + debug(47, 3) ("COSS: %s: stripe %d: file size mismatch (%" PRINTF_OFF_T " != %" PRINTF_OFF_T ")\n", stripePath(SD), cs->rebuild.curstripe, tmpe.swap_file_sz, len); goto nextobject; } if (EBIT_TEST(tmpe.flags, KEY_PRIVATE)) { - debug(47, 3) ("COSS: %s: stripe %d: private key flag set, ignoring.\n", SD->path, cs->rebuild.curstripe); + debug(47, 3) ("COSS: %s: stripe %d: private key flag set, ignoring.\n", stripePath(SD), cs->rebuild.curstripe); rb->counts.badflags++; goto nextobject; } @@ -1310,7 +1329,7 @@ storeDirCoss_ParseStripeBuffer(RebuildSt tmpe.swap_filen = filen; tmpe.swap_dirn = SD->index; - debug(47, 3) ("COSS: %s Considering filneumber %d\n", SD->path, tmpe.swap_filen); + debug(47, 3) ("COSS: %s Considering filneumber %d\n", stripePath(SD), tmpe.swap_filen); storeCoss_ConsiderStoreEntry(rb, key, &tmpe); nextobject: Index: src/fs/coss/store_io_coss.c =================================================================== RCS file: /squid/squid/src/fs/coss/store_io_coss.c,v retrieving revision 1.33 diff -u -p -r1.33 store_io_coss.c --- src/fs/coss/store_io_coss.c 16 Sep 2006 20:29:58 -0000 1.33 +++ src/fs/coss/store_io_coss.c 22 Sep 2006 11:59:03 -0000 @@ -191,7 +191,7 @@ storeCossAllocate(SwapDir * SD, const St storeCossMaybeWriteMemBuf(SD, cs->current_membuf); /* cs->current_membuf may be invalid at this point */ cs->current_offset = 0; /* wrap back to beginning */ - debug(79, 2) ("storeCossAllocate: %s: wrap to 0\n", SD->path); + debug(79, 2) ("storeCossAllocate: %s: wrap to 0\n", stripePath(SD)); newmb = storeCossCreateMemBuf(SD, 0, checkf, &coll); cs->current_membuf = newmb; @@ -210,7 +210,7 @@ storeCossAllocate(SwapDir * SD, const St cs->current_offset = cs->current_membuf->diskend; storeCossMaybeWriteMemBuf(SD, cs->current_membuf); /* cs->current_membuf may be invalid at this point */ - debug(79, 3) ("storeCossAllocate: %s: New offset - %" PRId64 "\n", SD->path, + debug(79, 3) ("storeCossAllocate: %s: New offset - %" PRId64 "\n", stripePath(SD), (int64_t) cs->current_offset); assert(cs->curstripe < (cs->numstripes - 1)); newmb = storeCossCreateMemBuf(SD, cs->curstripe + 1, checkf, &coll); @@ -245,7 +245,7 @@ storeCossAllocate(SwapDir * SD, const St cs->sizerange_max = SD->max_objsize; coss_stats.alloc.collisions++; - debug(79, 3) ("storeCossAllocate: %s: Collision\n", SD->path); + debug(79, 3) ("storeCossAllocate: %s: Collision\n", stripePath(SD)); return -1; } } @@ -253,7 +253,7 @@ storeCossAllocate(SwapDir * SD, const St void storeCossUnlink(SwapDir * SD, StoreEntry * e) { - debug(79, 3) ("storeCossUnlink: %s: offset %d\n", SD->path, e->swap_filen); + debug(79, 3) ("storeCossUnlink: %s: offset %d\n", stripePath(SD), e->swap_filen); coss_stats.unlink.ops++; coss_stats.unlink.success++; storeCossRemove(SD, e); @@ -262,7 +262,7 @@ storeCossUnlink(SwapDir * SD, StoreEntry void storeCossRecycle(SwapDir * SD, StoreEntry * e) { - debug(79, 3) ("storeCossRecycle: %s: offset %d\n", SD->path, e->swap_filen); + debug(79, 3) ("storeCossRecycle: %s: offset %d\n", stripePath(SD), e->swap_filen); /* Expire the object */ storeExpireNow(e); @@ -391,7 +391,7 @@ storeCossOpen(SwapDir * SD, StoreEntry * // This seems to cause a crash: either the membuf pointer is set wrong or the membuf // is deallocated from underneath us. storeCossMemBufLock(SD, sio); - debug(79, 3) ("storeCossOpen: %s: memory hit!\n", SD->path); + debug(79, 3) ("storeCossOpen: %s: memory hit!\n", stripePath(SD)); } else { /* Do the allocation */ /* this is the first time we've been called on a new sio @@ -409,13 +409,13 @@ storeCossOpen(SwapDir * SD, StoreEntry * /* If the object is allocated too recently, make a memory-only copy */ if (storeCossRelocateRequired(cs, sio->swap_filen)) { - debug(79, 3) ("storeCossOpen: %s: memory miss - doing reallocation (Current stripe : %d Object in stripe : %d)\n", SD->path, cs->curstripe, storeCossFilenoToStripe(cs, sio->swap_filen)); + debug(79, 3) ("storeCossOpen: %s: memory miss - doing reallocation (Current stripe : %d Object in stripe : %d)\n", stripePath(SD), cs->curstripe, storeCossFilenoToStripe(cs, sio->swap_filen)); nf = storeCossAllocate(SD, e, COSS_ALLOC_REALLOC); } else { - debug(79, 3) ("storeCossOpen: %s memory miss - not reallocating (Current stripe : %d Object in stripe : %d)\n", SD->path, cs->curstripe, storeCossFilenoToStripe(cs, sio->swap_filen)); + debug(79, 3) ("storeCossOpen: %s memory miss - not reallocating (Current stripe : %d Object in stripe : %d)\n", stripePath(SD), cs->curstripe, storeCossFilenoToStripe(cs, sio->swap_filen)); nf = storeCossMemOnlyAllocate(SD, e); if (nf == -1) { - debug(79, 3) ("storeCossOpen: %s memory miss - reallocating because all membufs are in use\n", SD->path); + debug(79, 3) ("storeCossOpen: %s memory miss - reallocating because all membufs are in use\n", stripePath(SD)); nf = storeCossAllocate(SD, e, COSS_ALLOC_REALLOC); } } @@ -494,7 +494,7 @@ storeCossRead(SwapDir * SD, storeIOState assert(sio->read.callback_data == NULL); sio->read.callback = callback; sio->read.callback_data = callback_data; - debug(79, 3) ("storeCossRead: %s: file number %d offset %ld\n", SD->path, sio->swap_filen, (long int) offset); + debug(79, 3) ("storeCossRead: %s: file number %d offset %ld\n", stripePath(SD), sio->swap_filen, (long int) offset); sio->offset = offset; cstate->flags.reading = 1; if ((offset + size) > sio->st_size) @@ -525,7 +525,7 @@ storeCossWrite(SwapDir * SD, storeIOStat if (sio->offset != offset) { debug(79, 1) ("storeCossWrite: Possible data corruption on fileno %d, offsets do not match (Current:%" PRINTF_OFF_T " Want:%" PRINTF_OFF_T ")\n", sio->swap_filen, sio->offset, offset); } - debug(79, 3) ("storeCossWrite: %s: offset %ld, len %lu\n", SD->path, + debug(79, 3) ("storeCossWrite: %s: offset %ld, len %lu\n", stripePath(SD), (long int) sio->offset, (unsigned long int) size); diskoffset = storeCossFilenoToDiskOffset(sio->swap_filen, SD->fsdata) + sio->offset; dest = storeCossMemPointerFromDiskOffset(SD->fsdata, diskoffset, &membuf); @@ -724,7 +724,7 @@ storeCossWriteMemBuf(SwapDir * SD, CossM coss_stats.stripe_write.ops++; assert(t->stripe < cs->numstripes); if (cs->stripes[t->stripe].pending_relocs > 0) { - debug(79, 1) ("WARNING: %s: One or more pending relocate (reads) from stripe %d are queued - and I'm now writing over that part of the disk. This may result in object data corruption!\n", SD->path, t->stripe); + debug(79, 1) ("WARNING: %s: One or more pending relocate (reads) from stripe %d are queued - and I'm now writing over that part of the disk. This may result in object data corruption!\n", stripePath(SD), t->stripe); } /* Update load stats */ cs->loadcalc[cur_load_interval] += 1; @@ -843,7 +843,7 @@ storeCossWriteMemBufDone(int fd, int r_e coss_stats.stripe_write.success++; } assert(cs->stripes[t->stripe].membuf == t); - debug(79, 2) ("storeCossWriteMemBufDone: %s: stripe %d: numobjs written: %d, lockcount %d\n", t->SD->path, t->stripe, t->numobjs, t->lockcount); + debug(79, 2) ("storeCossWriteMemBufDone: %s: stripe %d: numobjs written: %d, lockcount %d\n", stripePath(t->SD), t->stripe, t->numobjs, t->lockcount); cs->stripes[t->stripe].numdiskobjs = t->numobjs; cs->stripes[t->stripe].membuf = NULL; t->flags.written = 1; @@ -867,7 +867,7 @@ storeCossCreateMemOnlyBuf(SwapDir * SD) } if (stripe >= cs->nummemstripes) { if (last_warn + 15 < squid_curtime) { - debug(79, 1) ("storeCossCreateMemOnlyBuf: no free membufs. You may need to increase the value of membufs on the %s cache_dir\n", SD->path); + debug(79, 1) ("storeCossCreateMemOnlyBuf: no free membufs. You may need to increase the value of membufs on the %s cache_dir\n", stripePath(SD)); last_warn = squid_curtime; } return NULL; @@ -914,7 +914,7 @@ storeCossCreateMemBuf(SwapDir * SD, int if (cs->numfullstripes >= cs->maxfullstripes) { if (last_warn + 15 < squid_curtime) { - debug(79, 1) ("storeCossCreateMemBuf: Maximum number of full buffers reached on %s. You may need to increase the maxfullbuffers option for this cache_dir\n", SD->path); + debug(79, 1) ("storeCossCreateMemBuf: Maximum number of full buffers reached on %s. You may need to increase the maxfullbuffers option for this cache_dir\n", stripePath(SD)); last_warn = squid_curtime; } return NULL; @@ -928,7 +928,7 @@ storeCossCreateMemBuf(SwapDir * SD, int cs->stripes[stripe].membuf = newmb; newmb->diskstart = start; newmb->stripe = stripe; - debug(79, 2) ("storeCossCreateMemBuf: %s: creating new membuf at stripe %d, %" PRId64 " (%p)\n", SD->path, stripe, (int64_t) newmb->diskstart, newmb); + debug(79, 2) ("storeCossCreateMemBuf: %s: creating new membuf at stripe %d, %" PRId64 " (%p)\n", stripePath(SD), stripe, (int64_t) newmb->diskstart, newmb); newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ; newmb->flags.full = 0; newmb->flags.writing = 0; @@ -941,7 +941,7 @@ storeCossCreateMemBuf(SwapDir * SD, int assert(newmb->diskend >= 0); /* Print out the list of membufs */ - debug(79, 3) ("storeCossCreateMemBuf: %s: membuflist:\n", SD->path); + debug(79, 3) ("storeCossCreateMemBuf: %s: membuflist:\n", stripePath(SD)); for (m = cs->membufs.head; m; m = m->next) { t = m->data; membuf_describe(t, 3, __LINE__); @@ -958,7 +958,7 @@ storeCossCreateMemBuf(SwapDir * SD, int if (curfn > -1 && curfn == e->swap_filen) *collision = 1; /* Mark an object alloc collision */ assert((o >= newmb->diskstart) && (o < newmb->diskend)); - debug(79, 3) ("COSS: %s: stripe %d, releasing filen %d (offset %" PRINTF_OFF_T ")\n", SD->path, stripe, e->swap_filen, (squid_off_t) o); + debug(79, 3) ("COSS: %s: stripe %d, releasing filen %d (offset %" PRINTF_OFF_T ")\n", stripePath(SD), stripe, e->swap_filen, (squid_off_t) o); storeRelease(e); numreleased++; m = n;