/*
- * $Id$
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 79 Disk IO Routines */
+
/**
- * Author: Adrian Chadd <adrian@squid-cache.org>
- *
- \par
+ * \par
* These routines are simple plugin replacements for the file_* routines
* in disk.c . They back-end into the POSIX AIO routines to provide
* a nice and simple async IO framework for COSS.
*
- \par
+ * \par
* AIO is suitable for COSS - the only sync operations that the standard
* supports are read/write, and since COSS works on a single file
* per storedir it should work just fine.
*/
#include "squid.h"
-#include "AIODiskFile.h"
-#include "AIODiskIOStrategy.h"
+#include "Debug.h"
+#include "DiskIO/AIO/AIODiskFile.h"
+#include "DiskIO/AIO/AIODiskIOStrategy.h"
#include "DiskIO/IORequestor.h"
#include "DiskIO/ReadRequest.h"
#include "DiskIO/WriteRequest.h"
+#include "fs_io.h"
+#include "globals.h"
-CBDATA_CLASS_INIT(AIODiskFile);
-void *
-AIODiskFile::operator new(size_t unused)
-{
- CBDATA_INIT_TYPE(AIODiskFile);
- return cbdataAlloc(AIODiskFile);
-}
+#include <cerrno>
-void
-AIODiskFile::operator delete(void *address)
-{
- cbdataFree(address);
-}
+CBDATA_CLASS_INIT(AIODiskFile);
AIODiskFile::AIODiskFile(char const *aPath, AIODiskIOStrategy *aStrategy) : fd(-1), closed(true), error_(false)
{
}
void
-AIODiskFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
+AIODiskFile::open(int flags, mode_t, RefCount<IORequestor> callback)
{
/* Simulate async calls */
-#ifdef _SQUID_WIN32_
+#if _SQUID_WINDOWS_
fd = aio_open(path.termedBuf(), flags);
#else
fd = file_open(path.termedBuf() , flags);
error(true);
} else {
closed = false;
- store_open_disk_fd++;
+ ++store_open_disk_fd;
debugs(79, 3, HERE << ": opened FD " << fd);
}
if (slot < 0) {
/* No free slot? Callback error, and return */
fatal("Aiee! out of aiocb slots! - FIXME and wrap file_read\n");
- debugs(79, 1, "WARNING: out of aiocb slots!");
+ debugs(79, DBG_IMPORTANT, "WARNING: out of aiocb slots!");
/* fall back to blocking method */
// file_read(fd, request->buf, request->len, request->offset, callback, data);
return;
qe->aq_e_aiocb.aio_buf = request->buf;
/* Account */
- strategy->aq.aq_numpending++;
+ ++ strategy->aq.aq_numpending;
/* Initiate aio */
if (aio_read(&qe->aq_e_aiocb) < 0) {
- fatalf("Aiee! aio_read() returned error (%d) FIXME and wrap file_read !\n", errno);
- debugs(79, 1, "WARNING: aio_read() returned error: " << xstrerror());
+ int xerrno = errno;
+ fatalf("Aiee! aio_read() returned error (%d) FIXME and wrap file_read !\n", xerrno);
+ debugs(79, DBG_IMPORTANT, "WARNING: aio_read() returned error: " << xstrerr(xerrno));
/* fall back to blocking method */
// file_read(fd, request->buf, request->len, request->offset, callback, data);
}
if (slot < 0) {
/* No free slot? Callback error, and return */
fatal("Aiee! out of aiocb slots FIXME and wrap file_write !\n");
- debugs(79, 1, "WARNING: out of aiocb slots!");
+ debugs(79, DBG_IMPORTANT, "WARNING: out of aiocb slots!");
/* fall back to blocking method */
// file_write(fd, offset, buf, len, callback, data, freefunc);
return;
/* Initiate aio */
if (aio_write(&qe->aq_e_aiocb) < 0) {
- fatalf("Aiee! aio_write() returned error (%d) FIXME and wrap file_write !\n", errno);
- debugs(79, 1, "WARNING: aio_write() returned error: " << xstrerror());
+ int xerrno = errno;
+ fatalf("Aiee! aio_write() returned error (%d) FIXME and wrap file_write !\n", xerrno);
+ debugs(79, DBG_IMPORTANT, "WARNING: aio_write() returned error: " << xstrerr(xerrno));
/* fall back to blocking method */
// file_write(fd, offset, buf, len, callback, data, freefunc);
}
AIODiskFile::close ()
{
assert (!closed);
-#ifdef _SQUID_WIN32_
-
+#if _SQUID_WINDOWS_
aio_close(fd);
#else
-
file_close(fd);
#endif
{
return false;
}
+