]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
The --enable-truncate and USE_TRUNCATE code has been removed.
authorwessels <>
Fri, 13 Apr 2007 05:51:55 +0000 (05:51 +0000)
committerwessels <>
Fri, 13 Apr 2007 05:51:55 +0000 (05:51 +0000)
As discussed in Bug 1371, the truncate feature is dangerous on
async disk I/O storage schemes and more troublesome than any
possible performance benefits.

14 files changed:
configure.in
include/autoconf.h.in
src/DiskIO/Blocking/BlockingIOStrategy.cc
src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
src/DiskIO/DiskDaemon/diskd.cc
src/DiskIO/DiskThreads/DiskThreads.h
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h
src/DiskIO/DiskThreads/aiops.cc
src/DiskIO/DiskThreads/aiops_win32.cc
src/DiskIO/DiskThreads/async_io.cc
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/ufscommon.cc
src/unlinkd.cc

index abdecd74aafe0a9181288c9211eb923d9df6fbfa..899e960a34f63879336eae8fd6bde651bacc9f52 100644 (file)
@@ -1,7 +1,7 @@
 
 dnl  Configuration input file for Squid
 dnl
-dnl  $Id: configure.in,v 1.448 2007/04/07 09:35:37 serassio Exp $
+dnl  $Id: configure.in,v 1.449 2007/04/12 23:51:55 wessels Exp $
 dnl
 dnl
 dnl
@@ -11,7 +11,7 @@ AM_CONFIG_HEADER(include/autoconf.h)
 AC_CONFIG_AUX_DIR(cfgaux)
 AC_CONFIG_SRCDIR([src/main.cc])
 AM_INIT_AUTOMAKE([tar-ustar])
-AC_REVISION($Revision: 1.448 $)dnl
+AC_REVISION($Revision: 1.449 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AM_MAINTAINER_MODE
 
@@ -1324,18 +1324,6 @@ if test "$use_dnsserver" = "yes"; then
     AM_CONDITIONAL(USE_DNSSERVER, true)
 fi
 
-AC_ARG_ENABLE(truncate,
-[  --enable-truncate       This uses truncate() instead of unlink() when
-                          removing cache files.  Truncate gives a little
-                          performance improvement, but may cause problems
-                          when used with async I/O.  Truncate uses more
-                          filesystem inodes than unlink..],
-[ if test "$enableval" = "yes" ; then
-    echo "Enabling truncate instead of unlink"
-    AC_DEFINE(USE_TRUNCATE,1,[Do we want to use truncate(2) or unlink(2)?])
-  fi
-])
-
 dnl Select Default hosts file location
 AC_ARG_ENABLE(default-hostsfile,
 [  --enable-default-hostsfile=path
index 48df8bdffa3abc3210aa8319e9a9c7fc7ebd10fb..1b8ae14aa6c6fd51ae4c6e32b909756f4fe4c095 100644 (file)
 /* Define this to include code for SSL encryption. */
 #undef USE_SSL
 
-/* Do we want to use truncate(2) or unlink(2)? */
-#undef USE_TRUNCATE
-
 /* Define this if unlinkd is required (strongly recommended for ufs storage
    type) */
 #undef USE_UNLINKD
index ae0f7fec907c60bfbd993adfdb8f94dca2969ecd..2b5b2549a8b80f427a71d8b322d4a54c14085f8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: BlockingIOStrategy.cc,v 1.1 2004/12/20 16:30:38 robertc Exp $
+ * $Id: BlockingIOStrategy.cc,v 1.2 2007/04/12 23:51:56 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Robert Collins
@@ -60,11 +60,7 @@ BlockingIOStrategy::unlinkFile(char const *path)
 {
 #if USE_UNLINKD
     unlinkdUnlink(path);
-#elif USE_TRUNCATE
-
-    truncate(path, 0);
 #else
-
     ::unlink(path);
 #endif
 }
index 6e73855a48e07d2f6932509e85761c9374fdb4c4..2f620217b7155a02aa8175fe21b8962749fda79e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskdIOStrategy.cc,v 1.8 2007/04/12 17:56:39 rousskov Exp $
+ * $Id: DiskdIOStrategy.cc,v 1.9 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 79    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -112,9 +112,6 @@ DiskdIOStrategy::unlinkFile(char const *path)
 #if USE_UNLINKD
 
         unlinkdUnlink(path);
-#elif USE_TRUNCATE
-
-        truncate(path, 0);
 #else
 
         unlink(path);
index 1c77bec63ca7f02bbe4e84dc37bab09d7612ded8..6a8e37b86ee615a05de643e1fc25cb21bcdbef25 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: diskd.cc,v 1.5 2007/04/07 16:29:06 serassio Exp $
+ * $Id: diskd.cc,v 1.6 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section --    External DISKD process implementation.
  * AUTHOR: Harvest Derived
@@ -226,25 +226,10 @@ do_write(diomsg * r, int len, const char *buf)
 static int
 do_unlink(diomsg * r, int len, const char *buf)
 {
-#if USE_TRUNCATE
-
-    if (truncate(buf, 0) < 0)
-#else
-
-    if (unlink(buf) < 0)
-#endif
-
-    {
+    if (unlink(buf) < 0) {
         DEBUG(1) {
             fprintf(stderr, "%d UNLNK id %d %s: ", (int) mypid, r->id, buf);
-#if USE_TRUNCATE
-
-            perror("truncate");
-#else
-
             perror("unlink");
-#endif
-
         }
 
         return -errno;
index 0f944ba074a8df5387e2baeccc504c31e0663317..59933127a0f5b846d924770f6dff8faa3c890b7a 100644 (file)
@@ -32,7 +32,6 @@ enum _squidaio_request_type {
     _AIO_OP_WRITE,
     _AIO_OP_CLOSE,
     _AIO_OP_UNLINK,
-    _AIO_OP_TRUNCATE,
     _AIO_OP_OPENDIR,
     _AIO_OP_STAT
 };
@@ -74,7 +73,6 @@ int squidaio_close(int, squidaio_result_t *);
 
 int squidaio_stat(const char *, struct stat *, squidaio_result_t *);
 int squidaio_unlink(const char *, squidaio_result_t *);
-int squidaio_truncate(const char *, off_t length, squidaio_result_t *);
 int squidaio_opendir(const char *, squidaio_result_t *);
 squidaio_result_t *squidaio_poll_done(void);
 int squidaio_operations_pending(void);
@@ -94,7 +92,6 @@ void aioRead(int, int offset, int size, AIOCB *, void *);
 
 void aioStat(char *, struct stat *, AIOCB *, void *);
 void aioUnlink(const char *, AIOCB *, void *);
-void aioTruncate(const char *, off_t length, AIOCB *, void *);
 int aioQueueSize(void);
 
 #include "DiskIO/DiskFile.h"
index a0137c4fdfaa9857e05e1e3dc8cceb286e1efbef..d69cefec48f4c9658273884a58ebed0b22ecfb3c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskThreadsIOStrategy.cc,v 1.10 2006/11/25 20:12:38 serassio Exp $
+ * $Id: DiskThreadsIOStrategy.cc,v 1.11 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 79    Squid-side Disk I/O functions.
  * AUTHOR: Robert Collins
@@ -102,8 +102,6 @@ DiskThreadsIOStrategy::callback()
 
         case _AIO_OP_NONE:
 
-        case _AIO_OP_TRUNCATE:
-
         case _AIO_OP_OPENDIR:
             break;
 
@@ -257,11 +255,5 @@ void
 DiskThreadsIOStrategy::unlinkFile(char const *path)
 {
     statCounter.syscalls.disk.unlinks++;
-#if USE_TRUNCATE
-
-    aioTruncate(path, 0, NULL, NULL);
-#else
-
     aioUnlink(path, NULL, NULL);
-#endif
 }
index 1bea5092b8aa666a67301b42a8497bfcbef7d1c8..2526f63881267437680576dc25b61ee2d706165e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskThreadsIOStrategy.h,v 1.4 2006/09/03 04:12:00 hno Exp $
+ * $Id: DiskThreadsIOStrategy.h,v 1.5 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 79    Squid-side Disk I/O functions.
  * AUTHOR: Robert Collins
@@ -42,7 +42,6 @@
 #define _AIO_WRITE     2
 #define _AIO_CLOSE     3
 #define _AIO_UNLINK    4
-#define _AIO_TRUNCATE  4
 #define _AIO_OPENDIR   5
 #define _AIO_STAT      6
 #include "DiskIO/DiskIOStrategy.h"
index baeb3e2935b614c636ccd86d05d99ef54f23af78..55d111b2a551a803f45065f70ff04e3ff4f646a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.12 2006/09/03 21:05:20 hno Exp $
+ * $Id: aiops.cc,v 1.13 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -122,11 +122,7 @@ static void squidaio_do_read(squidaio_request_t *);
 static void squidaio_do_write(squidaio_request_t *);
 static void squidaio_do_close(squidaio_request_t *);
 static void squidaio_do_stat(squidaio_request_t *);
-#if USE_TRUNCATE
-static void squidaio_do_truncate(squidaio_request_t *);
-#else
 static void squidaio_do_unlink(squidaio_request_t *);
-#endif
 #if AIO_OPENDIR
 static void *squidaio_do_opendir(squidaio_request_t *);
 #endif
@@ -455,18 +451,10 @@ squidaio_thread_loop(void *ptr)
                 squidaio_do_close(request);
                 break;
 
-#if USE_TRUNCATE
-
-            case _AIO_OP_TRUNCATE:
-                squidaio_do_truncate(request);
-                break;
-#else
-
             case _AIO_OP_UNLINK:
                 squidaio_do_unlink(request);
                 break;
 
-#endif
 #if AIO_OPENDIR                        /* Opendir not implemented yet */
 
             case _AIO_OP_OPENDIR:
@@ -635,8 +623,6 @@ squidaio_cleanup_request(squidaio_request_t * requestp)
 
     case _AIO_OP_UNLINK:
 
-    case _AIO_OP_TRUNCATE:
-
     case _AIO_OP_OPENDIR:
         squidaio_xstrfree(requestp->path);
 
@@ -863,42 +849,6 @@ squidaio_do_stat(squidaio_request_t * requestp)
 }
 
 
-#if USE_TRUNCATE
-int
-squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp)
-{
-    squidaio_init();
-    squidaio_request_t *requestp;
-
-    requestp = (squidaio_request_t *)squidaio_request_pool->alloc();
-
-    requestp->path = (char *) squidaio_xstrdup(path);
-
-    requestp->offset = length;
-
-    requestp->resultp = resultp;
-
-    requestp->request_type = _AIO_OP_TRUNCATE;
-
-    requestp->cancelled = 0;
-
-    resultp->result_type = _AIO_OP_TRUNCATE;
-
-    squidaio_queue_request(requestp);
-
-    return 0;
-}
-
-
-static void
-squidaio_do_truncate(squidaio_request_t * requestp)
-{
-    requestp->ret = truncate(requestp->path, requestp->offset);
-    requestp->err = errno;
-}
-
-
-#else
 int
 squidaio_unlink(const char *path, squidaio_result_t * resultp)
 {
@@ -930,8 +880,6 @@ squidaio_do_unlink(squidaio_request_t * requestp)
     requestp->err = errno;
 }
 
-#endif
-
 #if AIO_OPENDIR
 /* XXX squidaio_opendir NOT implemented yet.. */
 
@@ -1084,10 +1032,6 @@ squidaio_debug(squidaio_request_t * request)
         debug(43, 5) ("UNLINK of %s\n", request->path);
         break;
 
-    case _AIO_OP_TRUNCATE:
-        debug(43, 5) ("UNLINK of %s\n", request->path);
-        break;
-
     default:
         break;
     }
index dd4e4c3b677611f45f64757d421723390c158a63..6b70f009bd2d66c0d6e7e235bd6e2239f0e7a366 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops_win32.cc,v 1.2 2006/09/09 15:29:59 serassio Exp $
+ * $Id: aiops_win32.cc,v 1.3 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 43    Windows AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -120,11 +120,7 @@ static void squidaio_do_read(squidaio_request_t *);
 static void squidaio_do_write(squidaio_request_t *);
 static void squidaio_do_close(squidaio_request_t *);
 static void squidaio_do_stat(squidaio_request_t *);
-#if USE_TRUNCATE
-static void squidaio_do_truncate(squidaio_request_t *);
-#else
 static void squidaio_do_unlink(squidaio_request_t *);
-#endif
 #if AIO_OPENDIR
 static void *squidaio_do_opendir(squidaio_request_t *);
 #endif
@@ -520,18 +516,10 @@ squidaio_thread_loop(LPVOID lpParam)
                 squidaio_do_close(request);
                 break;
 
-#if USE_TRUNCATE
-
-            case _AIO_OP_TRUNCATE:
-                squidaio_do_truncate(request);
-                break;
-#else
-
             case _AIO_OP_UNLINK:
                 squidaio_do_unlink(request);
                 break;
 
-#endif
 #if AIO_OPENDIR                        /* Opendir not implemented yet */
 
             case _AIO_OP_OPENDIR:
@@ -720,8 +708,6 @@ squidaio_cleanup_request(squidaio_request_t * requestp)
 
     case _AIO_OP_UNLINK:
 
-    case _AIO_OP_TRUNCATE:
-
     case _AIO_OP_OPENDIR:
         squidaio_xstrfree(requestp->path);
 
@@ -963,42 +949,6 @@ squidaio_do_stat(squidaio_request_t * requestp)
 }
 
 
-#if USE_TRUNCATE
-int
-squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp)
-{
-    squidaio_init();
-    squidaio_request_t *requestp;
-
-    requestp = (squidaio_request_t *)squidaio_request_pool->alloc();
-
-    requestp->path = (char *) squidaio_xstrdup(path);
-
-    requestp->offset = length;
-
-    requestp->resultp = resultp;
-
-    requestp->request_type = _AIO_OP_TRUNCATE;
-
-    requestp->cancelled = 0;
-
-    resultp->result_type = _AIO_OP_TRUNCATE;
-
-    squidaio_queue_request(requestp);
-
-    return 0;
-}
-
-
-static void
-squidaio_do_truncate(squidaio_request_t * requestp)
-{
-    requestp->ret = truncate(requestp->path, requestp->offset);
-    requestp->err = errno;
-}
-
-
-#else
 int
 squidaio_unlink(const char *path, squidaio_result_t * resultp)
 {
@@ -1030,8 +980,6 @@ squidaio_do_unlink(squidaio_request_t * requestp)
     requestp->err = errno;
 }
 
-#endif
-
 #if AIO_OPENDIR
 /* XXX squidaio_opendir NOT implemented yet.. */
 
@@ -1197,10 +1145,6 @@ squidaio_debug(squidaio_request_t * request)
         debug(43, 5) ("UNLINK of %s\n", request->path);
         break;
 
-    case _AIO_OP_TRUNCATE:
-        debug(43, 5) ("UNLINK of %s\n", request->path);
-        break;
-
     default:
         break;
     }
index b4b7532e5811bba5a92aa5f0a29be2e1357901e3..e504327838b45c69a94a6f0128053fb02646799f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: async_io.cc,v 1.2 2005/07/10 15:43:30 serassio Exp $
+ * $Id: async_io.cc,v 1.3 2007/04/12 23:51:57 wessels Exp $
  *
  * DEBUG: section 32    Asynchronous Disk I/O
  * AUTHOR: Pete Bentley <pete@demon.net>
@@ -210,24 +210,6 @@ aioStat(char *path, struct stat *sb, AIOCB * callback, void *callback_data)
     return;
 }                              /* aioStat */
 
-#if USE_TRUNCATE
-void
-aioTruncate(const char *path, off_t length, AIOCB * callback, void *callback_data)
-{
-    squidaio_ctrl_t *ctrlp;
-    assert(DiskThreadsIOStrategy::Instance.initialised);
-    squidaio_counts.unlink_start++;
-    ctrlp = (squidaio_ctrl_t *)DiskThreadsIOStrategy::Instance.squidaio_ctrl_pool->alloc();
-    ctrlp->fd = -2;
-    ctrlp->done_handler = callback;
-    ctrlp->done_handler_data = cbdataReference(callback_data);
-    ctrlp->operation = _AIO_TRUNCATE;
-    ctrlp->result.data = ctrlp;
-    squidaio_truncate(path, length, &ctrlp->result);
-    dlinkAdd(ctrlp, &ctrlp->node, &used_list);
-}                              /* aioTruncate */
-
-#else
 void
 aioUnlink(const char *path, AIOCB * callback, void *callback_data)
 {
@@ -244,8 +226,6 @@ aioUnlink(const char *path, AIOCB * callback, void *callback_data)
     dlinkAdd(ctrlp, &ctrlp->node, &used_list);
 }                              /* aioUnlink */
 
-#endif
-
 int
 aioQueueSize(void)
 {
index 51140139a7bc814b605813608720ea7b2995b7b6..7f271e2448da36575332f4333860d498c019c111 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.78 2007/04/11 21:22:27 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.79 2007/04/12 23:51:58 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -1061,10 +1061,6 @@ UFSSwapDir::DirClean(int swap_index)
     struct dirent *de = NULL;
     LOCAL_ARRAY(char, p1, MAXPATHLEN + 1);
     LOCAL_ARRAY(char, p2, MAXPATHLEN + 1);
-#if USE_TRUNCATE
-
-    struct stat sb;
-#endif
 
     int files[20];
     int swapfileno;
@@ -1117,14 +1113,6 @@ UFSSwapDir::DirClean(int swap_index)
                 if (UFSSwapDir::FilenoBelongsHere(fn, D0, D1, D2))
                     continue;
 
-#if USE_TRUNCATE
-
-        if (!::stat(de->d_name, &sb))
-            if (sb.st_size == 0)
-                continue;
-
-#endif
-
         files[k++] = swapfileno;
     }
 
@@ -1141,14 +1129,7 @@ UFSSwapDir::DirClean(int swap_index)
     for (n = 0; n < k; n++) {
         debug(36, 3) ("storeDirClean: Cleaning file %08X\n", files[n]);
         snprintf(p2, MAXPATHLEN + 1, "%s/%08X", p1, files[n]);
-#if USE_TRUNCATE
-
-        truncate(p2, 0);
-#else
-
         safeunlink(p2, 0);
-#endif
-
         statCounter.swap.files_cleaned++;
     }
 
index 381511e758e2e1aeb7f428a9583b70629e703aac..df7aef487d61b11a7671179e51ce63dd8409d103 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ufscommon.cc,v 1.7 2007/03/01 07:25:15 wessels Exp $
+ * $Id: ufscommon.cc,v 1.8 2007/04/12 23:51:58 wessels Exp $
  * vim: set et : 
  *
  * DEBUG: section 47    Store Directory Routines
@@ -198,12 +198,6 @@ RebuildState::rebuildFromDirectory()
         store_open_disk_fd--;
         fd = -1;
         swap_hdr_len = 0;
-#if USE_TRUNCATE
-
-        if (sb.st_size == 0)
-            continue;
-
-#endif
 
         StoreMetaUnpacker aBuilder(hdr_buf, len, &swap_hdr_len);
 
index c027d8c091ffedd82593f419b1cdee828579ec87..b6ac21ab28a7674c73a93f76690643d0f00a4be2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: unlinkd.cc,v 1.58 2006/09/10 03:49:05 adrian Exp $
+ * $Id: unlinkd.cc,v 1.59 2007/04/12 23:51:56 wessels Exp $
  *
  * DEBUG: section 2     Unlink Daemon
  * AUTHOR: Duane Wessels
@@ -55,17 +55,7 @@ main(int argc, char *argv[])
     while (fgets(buf, UNLINK_BUF_LEN, stdin)) {
         if ((t = strchr(buf, '\n')))
             *t = '\0';
-
-#if USE_TRUNCATE
-
-        x = truncate(buf, 0);
-
-#else
-
         x = unlink(buf);
-
-#endif
-
         if (x < 0)
             printf("ERR\n");
         else