From 55fd220006e8e65b1a9abef2e30b36461c6b6ece Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Mon, 29 Jan 2024 22:15:53 +0200 Subject: [PATCH] Remove FileSystemCacheThreshold setting (#7983) --- builds/install/misc/firebird.conf | 26 ------------------------- src/common/config/config.cpp | 8 -------- src/common/config/config.h | 6 +----- src/jrd/pag.cpp | 32 +++++++++++-------------------- 4 files changed, 12 insertions(+), 60 deletions(-) diff --git a/builds/install/misc/firebird.conf b/builds/install/misc/firebird.conf index e75d1addc9..fbe52f96e2 100644 --- a/builds/install/misc/firebird.conf +++ b/builds/install/misc/firebird.conf @@ -287,32 +287,6 @@ #UseFileSystemCache = true -# ---------------------------- -# File system cache threshold -# -# The threshold value that determines if Firebird will use the file system -# cache. File system caching is used if database cache size in pages -# (configured explicitly in the database header or via DefaultDbCachePages setting) -# is less than the value of FileSystemCacheThreshold. -# -# To always use the file system cache, set FileSystemCacheThreshold to a large value. -# To bypass the file system cache for all databases, set FileSystemCacheThreshold to -# zero. -# -# CAUTION! -# This setting is deprecated and will be removed in future Firebird versions. -# Consider using UseFileSystemCache setting instead. -# If UseFileSystemCache is set, the value of FileSystemCacheThreshold is ignored. -# If UseFileSystemCache is not set, and FileSystemCacheThreshold is set, the value -# of FileSystemCacheThreshold is in use and accounted by the engine. -# -# Type: integer, measured in database pages -# -# Per-database configurable. -# -#FileSystemCacheThreshold = 64K - - # ---------------------------- # File system cache size # diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index 39a1c09da7..5f68d6d912 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -415,8 +415,6 @@ void Config::checkValues() values[KEY_SERVER_MODE] = defaults[KEY_SERVER_MODE]; } - checkIntForLoBound(KEY_FILESYSTEM_CACHE_THRESHOLD, 0, true); - checkIntForLoBound(KEY_SNAPSHOTS_MEM_SIZE, 1, true); checkIntForHiBound(KEY_SNAPSHOTS_MEM_SIZE, MAX_ULONG, true); @@ -726,12 +724,6 @@ int Config::getWireCrypt(WireCryptMode wcMode) const return wcMode == WC_CLIENT ? WIRE_CRYPT_ENABLED : WIRE_CRYPT_REQUIRED; } -bool Config::getUseFileSystemCache(bool* pPresent) const -{ - DECLARE_PER_DB_KEY(KEY_USE_FILESYSTEM_CACHE); - return getBool(key, pPresent); -} - /// class FirebirdConf diff --git a/src/common/config/config.h b/src/common/config/config.h index 5e92e20c05..16c7fdf789 100644 --- a/src/common/config/config.h +++ b/src/common/config/config.h @@ -152,7 +152,6 @@ enum ConfigKey KEY_GC_POLICY, KEY_REDIRECTION, KEY_DATABASE_GROWTH_INCREMENT, - KEY_FILESYSTEM_CACHE_THRESHOLD, KEY_TRACE_CONFIG, KEY_MAX_TRACELOG_SIZE, KEY_FILESYSTEM_CACHE_SIZE, @@ -256,7 +255,6 @@ constexpr ConfigEntry entries[MAX_CONFIG_KEY] = {TYPE_STRING, "GCPolicy", false, nullptr}, // garbage collection policy {TYPE_BOOLEAN, "Redirection", true, false}, {TYPE_INTEGER, "DatabaseGrowthIncrement", false, 128 * 1048576}, // bytes - {TYPE_INTEGER, "FileSystemCacheThreshold", false, 65536}, // page buffers {TYPE_STRING, "AuditTraceConfigFile", true, ""}, // location of audit trace configuration file {TYPE_INTEGER, "MaxUserTraceLogSize", true, 10}, // maximum size of user session trace log {TYPE_INTEGER, "FileSystemCacheSize", true, 0}, // percent @@ -572,8 +570,6 @@ public: CONFIG_GET_PER_DB_INT(getDatabaseGrowthIncrement, KEY_DATABASE_GROWTH_INCREMENT); - CONFIG_GET_PER_DB_INT(getFileSystemCacheThreshold, KEY_FILESYSTEM_CACHE_THRESHOLD); - CONFIG_GET_GLOBAL_KEY(FB_UINT64, getFileSystemCacheSize, KEY_FILESYSTEM_CACHE_SIZE, getInt); CONFIG_GET_GLOBAL_STR(getAuditTraceConfigFile, KEY_TRACE_CONFIG); @@ -619,7 +615,7 @@ public: CONFIG_GET_PER_DB_STR(getDataTypeCompatibility, KEY_DATA_TYPE_COMPATIBILITY); - bool getUseFileSystemCache(bool* pPresent = nullptr) const; + CONFIG_GET_PER_DB_BOOL(getUseFileSystemCache, KEY_USE_FILESYSTEM_CACHE); CONFIG_GET_PER_DB_KEY(ULONG, getInlineSortThreshold, KEY_INLINE_SORT_THRESHOLD, getInt); diff --git a/src/jrd/pag.cpp b/src/jrd/pag.cpp index d40df23d59..2c6163d142 100644 --- a/src/jrd/pag.cpp +++ b/src/jrd/pag.cpp @@ -1147,7 +1147,9 @@ void PAG_header(thread_db* tdbb, bool info) dbb->dbb_creation_date.utc_timestamp = *(ISC_TIMESTAMP*) header->hdr_creation_date; dbb->dbb_creation_date.time_zone = TimeZoneUtil::GMT_ZONE; - if (header->hdr_flags & hdr_read_only) + const bool readOnly = header->hdr_flags & hdr_read_only; + + if (readOnly) { // If Header Page flag says the database is ReadOnly, gladly accept it. dbb->dbb_flags &= ~DBB_being_opened_read_only; @@ -1155,7 +1157,7 @@ void PAG_header(thread_db* tdbb, bool info) } // If hdr_read_only is not set... - if (!(header->hdr_flags & hdr_read_only) && (dbb->dbb_flags & DBB_being_opened_read_only)) + if (!readOnly && (dbb->dbb_flags & DBB_being_opened_read_only)) { // Looks like the Header page says, it is NOT ReadOnly!! But the database // file system permission gives only ReadOnly access. Punt out with @@ -1166,34 +1168,22 @@ void PAG_header(thread_db* tdbb, bool info) } - bool present; - bool useFSCache = dbb->dbb_config->getUseFileSystemCache(&present); + const bool useFSCache = dbb->dbb_config->getUseFileSystemCache(); + const bool forceWrite = header->hdr_flags & hdr_force_write; - if (!present) + if (forceWrite || !useFSCache) { - useFSCache = dbb->dbb_bcb->bcb_count < - ULONG(dbb->dbb_config->getFileSystemCacheThreshold()); - } - - if ((header->hdr_flags & hdr_force_write) || !useFSCache) - { - dbb->dbb_flags |= - (header->hdr_flags & hdr_force_write ? DBB_force_write : 0) | - (useFSCache ? 0 : DBB_no_fs_cache); - - const bool forceWrite = dbb->dbb_flags & DBB_force_write; - const bool notUseFSCache = dbb->dbb_flags & DBB_no_fs_cache; + dbb->dbb_flags |= (forceWrite ? DBB_force_write : 0) | + (useFSCache ? 0 : DBB_no_fs_cache); PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); for (jrd_file* file = pageSpace->file; file; file = file->fil_next) { - PIO_force_write(file, - forceWrite && !(header->hdr_flags & hdr_read_only), - notUseFSCache); + PIO_force_write(file, forceWrite && !readOnly, !useFSCache); } if (dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_normal) - dbb->dbb_backup_manager->setForcedWrites(forceWrite, notUseFSCache); + dbb->dbb_backup_manager->setForcedWrites(forceWrite, !useFSCache); } if (header->hdr_flags & hdr_no_reserve)