diff --git a/db/db_test.cc b/db/db_test.cc index 5c076ce5b..d126bb530 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2057,8 +2057,7 @@ TEST(DBTest, NumImmutableMemTable) { class SleepingBackgroundTask { public: - explicit SleepingBackgroundTask(Env* env) - : env_(env), bg_cv_(&mutex_), should_sleep_(true) {} + SleepingBackgroundTask() : bg_cv_(&mutex_), should_sleep_(true) {} void DoSleep() { MutexLock l(&mutex_); while (should_sleep_) { @@ -2076,7 +2075,6 @@ class SleepingBackgroundTask { } private: - const Env* env_; port::Mutex mutex_; port::CondVar bg_cv_; // Signalled when background work finishes bool should_sleep_; @@ -2086,10 +2084,10 @@ TEST(DBTest, GetProperty) { // Set sizes to both background thread pool to be 1 and block them. env_->SetBackgroundThreads(1, Env::HIGH); env_->SetBackgroundThreads(1, Env::LOW); - SleepingBackgroundTask sleeping_task_low(env_); + SleepingBackgroundTask sleeping_task_low; env_->Schedule(&SleepingBackgroundTask::DoSleepTask, &sleeping_task_low, Env::Priority::LOW); - SleepingBackgroundTask sleeping_task_high(env_); + SleepingBackgroundTask sleeping_task_high; env_->Schedule(&SleepingBackgroundTask::DoSleepTask, &sleeping_task_high, Env::Priority::HIGH); diff --git a/util/env_posix.cc b/util/env_posix.cc index c610c1546..856d49250 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -356,7 +356,9 @@ class PosixMmapFile : public WritableFile { uint64_t file_offset_; // Offset of base_ in file // Have we done an munmap of unsynced data? bool pending_sync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif // Roundup x to a multiple of y static size_t Roundup(size_t x, size_t y) { @@ -441,8 +443,10 @@ class PosixMmapFile : public WritableFile { dst_(nullptr), last_sync_(nullptr), file_offset_(0), - pending_sync_(false), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + pending_sync_(false) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert((page_size & (page_size - 1)) == 0); assert(options.use_mmap_writes); } @@ -614,7 +618,9 @@ class PosixWritableFile : public WritableFile { bool pending_fsync_; uint64_t last_sync_size_; uint64_t bytes_per_sync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif public: PosixWritableFile(const std::string& fname, int fd, size_t capacity, @@ -628,8 +634,10 @@ class PosixWritableFile : public WritableFile { pending_sync_(false), pending_fsync_(false), last_sync_size_(0), - bytes_per_sync_(options.bytes_per_sync), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + bytes_per_sync_(options.bytes_per_sync) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert(!options.use_mmap_writes); } @@ -809,15 +817,19 @@ class PosixRandomRWFile : public RandomRWFile { int fd_; bool pending_sync_; bool pending_fsync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif public: PosixRandomRWFile(const std::string& fname, int fd, const EnvOptions& options) : filename_(fname), fd_(fd), pending_sync_(false), - pending_fsync_(false), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + pending_fsync_(false) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert(!options.use_mmap_writes && !options.use_mmap_reads); }