You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2012/06/22 05:20:19 UTC
git commit: TS-1312 Allow to open cache disk without O_DIRECT,
for e.g. tmpfs "disk" cache
Updated Branches:
refs/heads/master bb48a363f -> 653ea0ccc
TS-1312 Allow to open cache disk without O_DIRECT, for e.g. tmpfs "disk" cache
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/653ea0cc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/653ea0cc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/653ea0cc
Branch: refs/heads/master
Commit: 653ea0ccc2f14235dee37ec1530bda0bbf09e3bf
Parents: bb48a36
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Jun 21 21:20:09 2012 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Jun 21 21:20:09 2012 -0600
----------------------------------------------------------------------
CHANGES | 3 +++
iocore/cache/Cache.cc | 11 +++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/653ea0cc/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ee5efc1..cf44c48 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 3.3.0
+ *) [TS-1312] Allow to open cache disk without O_DIRECT, for e.g. tmpfs
+ "disk" cache.
+
*) [TS-1289] stats codes mess up when disk fail
*) [TS-959] remove ae_ua filter
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/653ea0cc/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 36eb830..9cf90ce 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -504,6 +504,8 @@ CacheProcessor::start(int)
return start_internal(0);
}
+static const int DEFAULT_CACHE_OPTIONS = (O_RDWR | _O_ATTRIB_OVERLAPPED);
+
int
CacheProcessor::start_internal(int flags)
{
@@ -530,7 +532,8 @@ CacheProcessor::start_internal(int flags)
for (i = 0; i < theCacheStore.n_disks; i++) {
sd = theCacheStore.disk[i];
char path[PATH_NAME_MAX];
- int opts = O_RDWR;
+ int opts = DEFAULT_CACHE_OPTIONS;
+
ink_strlcpy(path, sd->pathname, sizeof(path));
if (!sd->file_pathname) {
if (config_volumes.num_http_volumes && config_volumes.num_stream_volumes) {
@@ -539,7 +542,7 @@ CacheProcessor::start_internal(int flags)
ink_strlcat(path, "/cache.db", sizeof(path));
opts |= O_CREAT;
}
- opts |= _O_ATTRIB_OVERLAPPED;
+
#ifdef O_DIRECT
opts |= O_DIRECT;
#endif
@@ -549,6 +552,10 @@ CacheProcessor::start_internal(int flags)
int fd = open(path, opts, 0644);
int blocks = sd->blocks;
+
+ if (fd < 0 && (opts & O_CREAT)) // Try without O_DIRECT if this is a file on filesystem, e.g. tmpfs.
+ fd = open(path, DEFAULT_CACHE_OPTIONS | O_CREAT, 0644);
+
if (fd > 0) {
if (!sd->file_pathname) {
if (ftruncate(fd, ((uint64_t) blocks) * STORE_BLOCK_SIZE) < 0) {