Commit c5b87288 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

User opt-in for the readonly kludge. Add 3 booleans to the IOContext. Don't hook up yet.

parent 445dce8b
......@@ -57,6 +57,9 @@ SeismicStoreIOContext::SeismicStoreIOContext()
legaltag(Environment::getStringEnv("OPENZGY_LEGALTAG"));
writeid(Environment::getStringEnv("OPENZGY_WRITEID"));
seismicmeta(Environment::getStringEnv("OPENZGY_SEISMICMETA"));
setRoAfterWrite(Environment::getNumericEnv("OPENZGY_RO_AFTER_WRITE", 0) > 0);
forceRoBeforeRead(Environment::getNumericEnv("OPENZGY_RO_BEFORE_READ", 0) > 0);
forceRwBeforeWrite(Environment::getNumericEnv("OPENZGY_RW_BEFORE_WRITE", 0) > 0);
}
std::string
......@@ -75,7 +78,12 @@ SeismicStoreIOContext::toString() const
<< " threads: " << _iothreads << " I/O, " << _cputhreads << " CPU.\n"
<< " legaltag: \"" << _legaltag << "\"\n"
<< " writeid: \"" << _writeid << "\"\n"
<< " seismeta: \"" << _seismicmeta << "\"\n";
<< " seismeta: \"" << _seismicmeta << "\"\n"
<< " romode: "
<< (_set_ro_after_write? "ro_after_write":" ")
<< (_force_ro_before_read? "ro_before_read":" ")
<< (_force_rw_before_write? "rw_before_write":" ")
<< "\n";
return ss.str();
}
......
......@@ -117,6 +117,9 @@ private:
tokencb_t _sdtokencb;
debugtrace_t _debug_trace;
logger_t _logger;
bool _set_ro_after_write;
bool _force_ro_before_read;
bool _force_rw_before_write;
private: // really private. Keep off.
std::int64_t _real_segsize;
......@@ -482,6 +485,67 @@ public:
{
return this->_logger;
}
/**
* Set the ZGY file to read-only when done writing it. Has no effect
* on files opened for read. Defaults to off. Most applications will
* want to turn in this on because most applications do not expect
* to update ZGY files in place.
*
* \internal
* It is not clear whether this belongs in IOContext next to the two
* "force" options or if it should be a new finalize tag
* BuildFullAndSetReadOnly.
*
* IOContext
* - Not available for files.
* - Cannot default to "on" because it depends on the finalise mode
* what makes sense.
*
* FinalizeAction:
* - The flag cannot be set inside finalize, it needs to
* be deferred until the last flush. So it doesn't really
* belong here either.
* - It isn't just BuildFull which needs an ...AndSetReadOnly variant
* although the others are less likely to be used.
*/
SeismicStoreIOContext& setRoAfterWrite(bool value)
{
this->_set_ro_after_write = value;
return *this;
}
/**
* Sneak past the mandatory locking in SDAPI by forcing the
* read-only flag to true on the ZGY file, if needed, on each open
* for read. This allows for less overhead, more caching, and use of
* the altUrl feature. This option is useful if the file is
* logically immutable but was not flagged as such. E.g. the creator
* forgot to call setRoCloseWrite(true), or the ZGY file was not
* created by OpenZGY. The option has no effect on files opened for
* create or update. Caveat: Allowing a read-only open to have a
* permanent effect of the file being opened is not ideal.
*/
SeismicStoreIOContext& forceRoBeforeRead(bool value)
{
this->_force_ro_before_read = value;
return *this;
}
/**
* Dangerous option. Sneak past the mandatory locking in SDAPI by
* forcing the read-only flag to false on the ZGY file, if needed,
* that is about to be opened for update. The application must know
* that the file is not open for read by somebody else. There is
* also a risk that data might exists in cache even for a closed
* file. The application assumes all responsibility.
*/
SeismicStoreIOContext& forceRwBeforeWrite(bool value)
{
this->_force_rw_before_write = value;
return *this;
}
};
/** \endcond */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment