Skip to content

Commit

Permalink
The --enable-truncate and USE_TRUNCATE code has been removed.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wessels committed Apr 13, 2007
1 parent 415b556 commit b3fb907
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 230 deletions.
16 changes: 2 additions & 14 deletions 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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions include/autoconf.h.in
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions 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
Expand Down Expand Up @@ -60,11 +60,7 @@ BlockingIOStrategy::unlinkFile(char const *path)
{
#if USE_UNLINKD
unlinkdUnlink(path);
#elif USE_TRUNCATE

truncate(path, 0);
#else

::unlink(path);
#endif
}
5 changes: 1 addition & 4 deletions 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
Expand Down Expand Up @@ -112,9 +112,6 @@ DiskdIOStrategy::unlinkFile(char const *path)
#if USE_UNLINKD

unlinkdUnlink(path);
#elif USE_TRUNCATE

truncate(path, 0);
#else

unlink(path);
Expand Down
19 changes: 2 additions & 17 deletions 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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/DiskIO/DiskThreads/DiskThreads.h
Expand Up @@ -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
};
Expand Down Expand Up @@ -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);
Expand All @@ -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"
Expand Down
10 changes: 1 addition & 9 deletions 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
Expand Down Expand Up @@ -102,8 +102,6 @@ DiskThreadsIOStrategy::callback()

case _AIO_OP_NONE:

case _AIO_OP_TRUNCATE:

case _AIO_OP_OPENDIR:
break;

Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions 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
Expand Down Expand Up @@ -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"
Expand Down
58 changes: 1 addition & 57 deletions 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 <slf@connect.com.au>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -930,8 +880,6 @@ squidaio_do_unlink(squidaio_request_t * requestp)
requestp->err = errno;
}

#endif

#if AIO_OPENDIR
/* XXX squidaio_opendir NOT implemented yet.. */

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b3fb907

Please sign in to comment.