From 760bd0f19c4400a40b22862710a7e531a7f4a009 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 3 Dec 2018 14:28:49 -0800 Subject: [PATCH] ircd::db: Workaround allow_fallocate options issue. --- ircd/db.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ircd/db.cc b/ircd/db.cc index 623f7f640..b095ba68f 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -4426,6 +4426,15 @@ try name }; #endif + + // Workaround a RocksDB bug which doesn't propagate EnvOptions properly + // on some constructions of WritableFile early on during db open. We'll + // get an env_opts.allow_fallocate==true here while it should be false + // from the DBOptions at d->opts. We use &= so it's not set to true when + // the caller specifically wants it false just for them. + assert(d && d->opts); + this->env_opts.allow_fallocate &= d->opts->allow_fallocate; + //assert(env_opts.allow_fallocate == d->opts->allow_fallocate); } catch(const std::exception &e) { @@ -4954,6 +4963,9 @@ noexcept try }; #endif + if(!env_opts.allow_fallocate) + return Status::NotSupported(); + _allocate(offset, length); return Status::OK(); } @@ -5073,6 +5085,10 @@ ircd::db::database::env::writable_file::_allocate(const size_t &offset, }; #endif + assert(env_opts.allow_fallocate); + assert(bool(d.opts)); + assert(d.opts->allow_fallocate); + fs::allocate(fd, allocate_length, wopts); this->preallocation_last_block = last_block; }