From: wessels <> Date: Fri, 22 Jan 1999 04:10:32 +0000 (+0000) Subject: changed open_disk_fd to store_open_disk_fd. X-Git-Tag: SQUID_3_0_PRE1~2367 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83a29c953f6826820b803b57919e2aab07feee20;p=thirdparty%2Fsquid.git changed open_disk_fd to store_open_disk_fd. 1) we want to track only STORE files, not necessarily log files. Log files don't contribute much to disk load. 2) this accounting belongs in the "store filesystem" layer, not the "fd layer". Mostly motivated by Henrik's addition of Opening_FD counter in the async code. --- diff --git a/src/fd.cc b/src/fd.cc index dbf82fcc56..b1890f0bc2 100644 --- a/src/fd.cc +++ b/src/fd.cc @@ -1,6 +1,6 @@ /* - * $Id: fd.cc,v 1.33 1999/01/19 17:41:02 wessels Exp $ + * $Id: fd.cc,v 1.34 1999/01/21 21:10:32 wessels Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -84,8 +84,6 @@ fd_close(int fd) F->flags.open = 0; fdUpdateBiggest(fd, 0); Number_FD--; - if (F->type == FD_FILE) - open_disk_fd--; commUpdateReadBits(fd, NULL); commUpdateWriteBits(fd, NULL); memset(F, '\0', sizeof(fde)); @@ -109,8 +107,6 @@ fd_open(int fd, unsigned int type, const char *desc) if (desc) xstrncpy(F->desc, desc, FD_DESC_SZ); Number_FD++; - if (type == FD_FILE) - open_disk_fd++; } void diff --git a/src/globals.h b/src/globals.h index 24faabdc68..2f6f3d1c0c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.75 1999/01/19 20:26:32 wessels Exp $ + * $Id: globals.h,v 1.76 1999/01/21 21:10:33 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -142,4 +142,4 @@ extern icpUdpData *IcpQueueHead; /* NULL */ extern int refresh_nocache_hack; /* 0 */ #endif extern request_flags null_request_flags; -extern int open_disk_fd; /* 0 */ +extern int store_open_disk_fd; /* 0 */ diff --git a/src/stat.cc b/src/stat.cc index 4b9d08e2aa..9889424427 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.310 1999/01/19 17:41:05 wessels Exp $ + * $Id: stat.cc,v 1.311 1999/01/21 21:10:34 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -588,11 +588,11 @@ info_get(StoreEntry * sentry) storeAppendPrintf(sentry, "\tNumber of file desc currently in use: %4d\n", Number_FD); storeAppendPrintf(sentry, "\tAvailable number of file descriptors: %4d\n", - Squid_MaxFD - Number_FD); + fdNFree()); storeAppendPrintf(sentry, "\tReserved number of file descriptors: %4d\n", RESERVED_FD); - storeAppendPrintf(sentry, "\tDisk files open: %4d\n", - open_disk_fd); + storeAppendPrintf(sentry, "\tStore Disk files open: %4d\n", + store_open_disk_fd); storeAppendPrintf(sentry, "Internal Data Structures:\n"); storeAppendPrintf(sentry, "\t%6d StoreEntries\n", diff --git a/src/store.cc b/src/store.cc index e66625652f..a742cb4b55 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.484 1999/01/19 02:24:33 wessels Exp $ + * $Id: store.cc,v 1.485 1999/01/21 21:10:36 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -478,7 +478,7 @@ storeTooManyDiskFilesOpen(void) { if (Config.max_open_disk_fds == 0) return 0; - if (open_disk_fd > Config.max_open_disk_fds) + if (store_open_disk_fd > Config.max_open_disk_fds) return 1; return 0; } @@ -511,11 +511,18 @@ storeCheckCachable(StoreEntry * e) } else if (EBIT_TEST(e->flags, KEY_PRIVATE)) { debug(20, 3) ("storeCheckCachable: NO: private key\n"); store_check_cachable_hist.no.private_key++; + } else if (e->swap_status != SWAPOUT_NONE) { + /* + * here we checked the swap_status because the remaining + * cases are only relevant only if we haven't started swapping + * out the object yet. + */ + return 1; } else if (storeTooManyDiskFilesOpen()) { debug(20, 2) ("storeCheckCachable: NO: too many disk files open\n"); store_check_cachable_hist.no.too_many_open_files++; } else if (fdNFree() < RESERVED_FD) { - debug(20, 2) ("storeCheckCachable: NO: too FD's open\n"); + debug(20, 2) ("storeCheckCachable: NO: too many FD's open\n"); store_check_cachable_hist.no.too_many_open_fds++; } else if (storeExpiredReferenceAge() < 300) { debug(20, 2) ("storeCheckCachable: NO: LRU Age = %d\n", diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 2d509d9a3f..835e950a41 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -1,6 +1,6 @@ /* - * $Id: store_rebuild.cc,v 1.54 1999/01/12 23:38:39 wessels Exp $ + * $Id: store_rebuild.cc,v 1.55 1999/01/21 21:10:37 wessels Exp $ * * DEBUG: section 20 Store Rebuild Routines * AUTHOR: Duane Wessels @@ -137,6 +137,7 @@ storeRebuildFromDirectory(rebuild_dir * d) debug(20, 1) ("storeRebuildFromDirectory: fstat(FD %d): %s\n", fd, xstrerror()); file_close(fd); + store_open_disk_fd--; fd = -1; continue; } @@ -149,10 +150,12 @@ storeRebuildFromDirectory(rebuild_dir * d) debug(20, 1) ("storeRebuildFromDirectory: 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_NOT_UNLINK @@ -522,6 +525,7 @@ storeGetNextFile(rebuild_dir * d, int *sfileno, int *size) if (fd < 0) debug(50, 1) ("storeGetNextFile: %s: %s\n", d->fullfilename, xstrerror()); continue; + store_open_disk_fd++; } d->in_dir = 0; if (++d->curlvl2 < Config.cacheSwap.swapDirs[d->dirn].l2) diff --git a/src/store_swapin.cc b/src/store_swapin.cc index 416a45c6a9..c1500375ad 100644 --- a/src/store_swapin.cc +++ b/src/store_swapin.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapin.cc,v 1.16 1999/01/19 17:41:07 wessels Exp $ + * $Id: store_swapin.cc,v 1.17 1999/01/21 21:10:38 wessels Exp $ * * DEBUG: section 20 Storage Manager Swapin Functions * AUTHOR: Duane Wessels @@ -89,6 +89,7 @@ storeSwapInValidateComplete(void *data, int retcode, int errcode) } ctrlp->path = xstrdup(storeSwapFullPath(e->swap_file_number, NULL)); debug(20, 3) ("storeSwapInValidateComplete: Opening %s\n", ctrlp->path); + store_open_disk_fd++; file_open(ctrlp->path, O_RDONLY, storeSwapInFileOpened, @@ -106,6 +107,7 @@ storeSwapInFileOpened(void *data, int fd, int errcode) if (fd == -2 && errcode == -2) { xfree(ctrlp->path); xfree(ctrlp); + store_open_disk_fd--; return; } assert(mem != NULL); @@ -116,15 +118,18 @@ storeSwapInFileOpened(void *data, int fd, int errcode) "\tFile:\t'%s'\n\t URL:\t'%s'\n", ctrlp->path, storeUrl(e)); storeEntryDump(e, 3); + store_open_disk_fd--; } else if (e->swap_status != SWAPOUT_DONE) { (void) 0; } else if (fstat(fd, &sb) < 0) { debug(20, 1) ("storeSwapInFileOpened: fstat() FD %d: %s\n", fd, xstrerror()); file_close(fd); + store_open_disk_fd--; fd = -1; } else if (sb.st_size == 0 || sb.st_size != e->swap_file_sz) { debug(20, 1) ("storeSwapInFileOpened: %s: Size mismatch: %d(fstat) != %d(object)\n", ctrlp->path, (int) sb.st_size, e->swap_file_sz); file_close(fd); + store_open_disk_fd--; fd = -1; } if (fd < 0) { diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 1d3aaa49cf..9484083263 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.44 1999/01/19 17:41:08 wessels Exp $ + * $Id: store_swapout.cc,v 1.45 1999/01/21 21:10:39 wessels Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -60,6 +60,7 @@ storeSwapOutStart(StoreEntry * e) ctrlp->oldswapstatus = e->swap_status; e->swap_status = SWAPOUT_OPENING; e->mem_obj->swapout.ctrl = ctrlp; + store_open_disk_fd++; file_open(ctrlp->swapfilename, O_WRONLY | O_CREAT | O_TRUNC, storeSwapOutFileOpened, @@ -272,6 +273,7 @@ storeSwapOutFileClose(StoreEntry * e) } ctrlp = mem->swapout.ctrl; file_close(mem->swapout.fd); + store_open_disk_fd--; mem->swapout.fd = -1; xfree(ctrlp->swapfilename); cbdataFree(ctrlp); @@ -292,6 +294,7 @@ storeSwapOutFileOpened(void *data, int fd, int errcode) xfree(ctrlp->swapfilename); cbdataFree(ctrlp); mem->swapout.ctrl = NULL; + store_open_disk_fd--; return; } assert(e->swap_status == SWAPOUT_OPENING); @@ -304,6 +307,7 @@ storeSwapOutFileOpened(void *data, int fd, int errcode) xfree(ctrlp->swapfilename); cbdataFree(ctrlp); mem->swapout.ctrl = NULL; + store_open_disk_fd--; return; } mem->swapout.fd = (short) fd;