From b3fb907032613d7151410eceb4622bb43f5af6bc Mon Sep 17 00:00:00 2001 From: wessels <> Date: Fri, 13 Apr 2007 05:51:55 +0000 Subject: [PATCH] The --enable-truncate and USE_TRUNCATE code has been removed. 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. --- configure.in | 16 +---- include/autoconf.h.in | 3 - src/DiskIO/Blocking/BlockingIOStrategy.cc | 6 +- src/DiskIO/DiskDaemon/DiskdIOStrategy.cc | 5 +- src/DiskIO/DiskDaemon/diskd.cc | 19 +----- src/DiskIO/DiskThreads/DiskThreads.h | 3 - .../DiskThreads/DiskThreadsIOStrategy.cc | 10 +--- .../DiskThreads/DiskThreadsIOStrategy.h | 3 +- src/DiskIO/DiskThreads/aiops.cc | 58 +------------------ src/DiskIO/DiskThreads/aiops_win32.cc | 58 +------------------ src/DiskIO/DiskThreads/async_io.cc | 22 +------ src/fs/ufs/store_dir_ufs.cc | 21 +------ src/fs/ufs/ufscommon.cc | 8 +-- src/unlinkd.cc | 12 +--- 14 files changed, 14 insertions(+), 230 deletions(-) diff --git a/configure.in b/configure.in index abdecd74aaf..899e960a34f 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/include/autoconf.h.in b/include/autoconf.h.in index 48df8bdffa3..1b8ae14aa6c 100644 --- a/include/autoconf.h.in +++ b/include/autoconf.h.in @@ -935,9 +935,6 @@ /* 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 diff --git a/src/DiskIO/Blocking/BlockingIOStrategy.cc b/src/DiskIO/Blocking/BlockingIOStrategy.cc index ae0f7fec907..2b5b2549a8b 100644 --- a/src/DiskIO/Blocking/BlockingIOStrategy.cc +++ b/src/DiskIO/Blocking/BlockingIOStrategy.cc @@ -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 } diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index 6e73855a48e..2f620217b71 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -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); diff --git a/src/DiskIO/DiskDaemon/diskd.cc b/src/DiskIO/DiskDaemon/diskd.cc index 1c77bec63ca..6a8e37b86ee 100644 --- a/src/DiskIO/DiskDaemon/diskd.cc +++ b/src/DiskIO/DiskDaemon/diskd.cc @@ -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; diff --git a/src/DiskIO/DiskThreads/DiskThreads.h b/src/DiskIO/DiskThreads/DiskThreads.h index 0f944ba074a..59933127a0f 100644 --- a/src/DiskIO/DiskThreads/DiskThreads.h +++ b/src/DiskIO/DiskThreads/DiskThreads.h @@ -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" diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index a0137c4fdfa..d69cefec48f 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -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 } diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h index 1bea5092b8a..2526f638812 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h @@ -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" diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index baeb3e2935b..55d111b2a55 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -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 @@ -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; } diff --git a/src/DiskIO/DiskThreads/aiops_win32.cc b/src/DiskIO/DiskThreads/aiops_win32.cc index dd4e4c3b677..6b70f009bd2 100755 --- a/src/DiskIO/DiskThreads/aiops_win32.cc +++ b/src/DiskIO/DiskThreads/aiops_win32.cc @@ -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 @@ -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; } diff --git a/src/DiskIO/DiskThreads/async_io.cc b/src/DiskIO/DiskThreads/async_io.cc index b4b7532e581..e504327838b 100644 --- a/src/DiskIO/DiskThreads/async_io.cc +++ b/src/DiskIO/DiskThreads/async_io.cc @@ -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 @@ -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) { diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 51140139a7b..7f271e2448d 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -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++; } diff --git a/src/fs/ufs/ufscommon.cc b/src/fs/ufs/ufscommon.cc index 381511e758e..df7aef487d6 100644 --- a/src/fs/ufs/ufscommon.cc +++ b/src/fs/ufs/ufscommon.cc @@ -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); diff --git a/src/unlinkd.cc b/src/unlinkd.cc index c027d8c091f..b6ac21ab28a 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -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