[
https://issues.apache.org/jira/browse/TS-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13398179#comment-13398179
]
Leif Hedstrom commented on TS-1312:
-----------------------------------
I'm proposing something like this, allowing for a "retry" on the open without
O_DIRECT:
{code}
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index f8d7a07..22033b8 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) {
{code}
If that's undesirable, we could add a flag to storage.config, e.g.
{code}
/mnt/tmpfs 64G no-direct
{code}
I'm not sure this has a lot of value though, it seems reasonable to allow it to
retry without O_DIRECT. In benchmarks, performance on a system with RAM cache,
and one with just a cache on tmpfs is minor (less than 10%).
> Allow to open cache disk without O_DIRECT, for e.g. tmpfs "disk" cache
> ----------------------------------------------------------------------
>
> Key: TS-1312
> URL: https://issues.apache.org/jira/browse/TS-1312
> Project: Traffic Server
> Issue Type: Improvement
> Components: Cache
> Reporter: Leif Hedstrom
> Assignee: Leif Hedstrom
> Fix For: 3.3.0
>
>
> Allowing us to now require O_DIRECT when opening a cache file could allow
> someone to run the cache on tmpfs, and avoid all disk I/O completely.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira