]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
swap space accounting used to assume 1K block size. This patch uses
authorwessels <>
Tue, 2 Jan 2001 08:41:30 +0000 (08:41 +0000)
committerwessels <>
Tue, 2 Jan 2001 08:41:30 +0000 (08:41 +0000)
statvfs/statfs to get the actual block size and use it when accounting
for filesystem overheads.

src/cache_cf.cc
src/fs/aufs/store_dir_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/ufs/store_dir_ufs.cc
src/protos.h
src/store_dir.cc
src/structs.h

index f5e04afb5f003dc0767c2ca0f382c3c23b67c01d..151790cbb86388a6ef28cbd35fc5a39a7da70e2d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.361 2000/12/09 04:16:07 wessels Exp $
+ * $Id: cache_cf.cc,v 1.362 2001/01/02 01:41:30 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -947,6 +947,9 @@ parse_cachedir(cacheSwap * swap)
     /* XXX should we dupe the string here, in case it gets trodden on? */
     sd->type = storefs_list[fs].typestr;
     sd->max_objsize = maxobjsize;
+    /* defaults in case fs implementation fails to set these */
+    sd->fs.blksize = 1024;
+    sd->fs.kperblk = 1;
     swap->n_configured++;
     /* Update the max object size */
     update_maxobjsize();
index a0c4cc1cee1c450f9b54c9c6c7d084c202337fdd..4f7eb6779ffa1806c4f5ab50b1fa87fa01c0d540 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_aufs.cc,v 1.22 2000/12/09 01:47:22 wessels Exp $
+ * $Id: store_dir_aufs.cc,v 1.23 2001/01/02 01:41:33 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -370,6 +370,8 @@ storeAufsDirInit(SwapDir * sd)
        eventAdd("storeDirClean", storeAufsDirCleanEvent, NULL, 15.0, 1);
        started_clean_event = 1;
     }
+    if (0 == storeDirGetBlkSize(sd->path, &sd->fs.blksize))
+       sd->fs.kperblk = sd->fs.blksize >> 10;
 }
 
 static void
index 142be65d87649cf5c356758e0be23348021083db..72e7f58c63b27bb0fa2a1a72b0f4e7ebb32dd762 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.12 2000/12/09 00:35:04 wessels Exp $
+ * $Id: store_dir_coss.cc,v 1.13 2001/01/02 01:41:34 wessels Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -153,6 +153,8 @@ storeCossDirInit(SwapDir * sd)
     storeCossDirRebuild(sd);
     cs->fd = file_open(sd->path, O_RDWR | O_CREAT);
     n_coss_dirs++;
+    if (0 == storeDirGetBlkSize(sd->path, &sd->fs.blksize))
+       sd->fs.kperblk = sd->fs.blksize >> 10;
 }
 
 void
index 6d6bec4a747d87d83d83586c6916477eee1e3207..a4f62295c304554b28215afd99e6e430d85c3a2b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_diskd.cc,v 1.29 2000/12/09 01:47:22 wessels Exp $
+ * $Id: store_dir_diskd.cc,v 1.30 2001/01/02 01:41:34 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -441,6 +441,8 @@ storeDiskdDirInit(SwapDir * sd)
        eventAdd("storeDirClean", storeDiskdDirCleanEvent, NULL, 15.0, 1);
        started_clean_event = 1;
     }
+    if (0 == storeDirGetBlkSize(sd->path, &sd->fs.blksize))
+       sd->fs.kperblk = sd->fs.blksize >> 10;
 }
 
 
index 25806688d8c2d7b0c15910ac12f3f14aca422212..04b2ecf62e5b28a54e272f841a38b1da1f18ad8e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.20 2001/01/02 00:11:55 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.21 2001/01/02 01:41:35 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -368,6 +368,8 @@ storeUfsDirInit(SwapDir * sd)
        eventAdd("storeDirClean", storeUfsDirCleanEvent, NULL, 15.0, 1);
        started_clean_event = 1;
     }
+    if (0 == storeDirGetBlkSize(sd->path, &sd->fs.blksize))
+       sd->fs.kperblk = sd->fs.blksize >> 10;
 }
 
 static void
index 5762122f1e1adbbe06f441c7373927fa824b2674..167d11f98b83db8c4ce976cdcb219a9dd3e161b6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.389 2000/12/30 23:29:07 wessels Exp $
+ * $Id: protos.h,v 1.390 2001/01/02 01:41:30 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -939,6 +939,7 @@ extern void storeDirSync(void);
 extern void storeDirCallback(void);
 extern void storeDirLRUDelete(StoreEntry *);
 extern void storeDirLRUAdd(StoreEntry *);
+int storeDirGetBlkSize(const char *path, int *blksize);
 
 /*
  * store_swapmeta.c
index 0cce350b4a0f4ca5b19940ae5846635efd9b1b80..d338feb81f5327fe813e504746578338ca1507b5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.117 2000/12/05 09:11:24 wessels Exp $
+ * $Id: store_dir.cc,v 1.118 2001/01/02 01:41:31 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -248,7 +248,8 @@ storeDirSwapLog(const StoreEntry * e, int op)
 void
 storeDirUpdateSwapSize(SwapDir * SD, size_t size, int sign)
 {
-    int k = ((size + 1023) >> 10) * sign;
+    int blks = (size + SD->fs.blksize - 1) / SD->fs.blksize;
+    int k = blks * SD->fs.kperblk * sign;
     SD->cur_size += k;
     store_swap_size += k;
     if (sign > 0)
@@ -280,6 +281,8 @@ storeDirStats(StoreEntry * sentry)
        SD = &(Config.cacheSwap.swapDirs[i]);
        storeAppendPrintf(sentry, "Store Directory #%d (%s): %s\n", i, SD->type,
            storeSwapDir(i));
+       storeAppendPrintf(sentry, "FS Block Size %d KB\n",
+           SD->fs.kperblk);
        SD->statfs(SD, sentry);
     }
 }
@@ -452,3 +455,23 @@ storeDirCallback(void)
     } while (j > 0);
     ndir++;
 }
+
+int
+storeDirGetBlkSize(const char *path, int *blksize)
+{
+#if HAVE_STATVFS
+    struct statvfs sfs;
+    if (statvfs(path, &sfs)) {
+       debug(0, 0) ("%s: %s\n", path, xstrerror());
+       return 1;
+    }
+#else
+    struct statfs sfs;
+    if (statfs(path, &sfs)) {
+       debug(0, 0) ("%s: %s\n", path, xstrerror());
+       return 1;
+    }
+#endif
+    *blksize = (int) sfs.f_bsize;
+    return 0;
+}
index c8dbbe10af0d95858f0db87adbfa63147984ae76..7f326f8f9da68d482bb9b8bdafe12ca4ca5b6c21 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.369 2001/01/01 23:09:59 wessels Exp $
+ * $Id: structs.h,v 1.370 2001/01/02 01:41:31 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1388,6 +1388,10 @@ struct _SwapDir {
        } clean;
        int writes_since_clean;
     } log;
+    struct {
+       int blksize;
+       int kperblk;
+    } fs;
     void *fsdata;
 };