Skip to content

Commit

Permalink
Remove FileSystemCacheThreshold setting (#7983)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvlad committed Jan 29, 2024
1 parent 6cae9e5 commit 55fd220
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 60 deletions.
26 changes: 0 additions & 26 deletions builds/install/misc/firebird.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
8 changes: 0 additions & 8 deletions src/common/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions src/common/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -572,8 +570,6 @@ class Config : public RefCounted, public GlobalStorage

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);
Expand Down Expand Up @@ -619,7 +615,7 @@ class Config : public RefCounted, public GlobalStorage

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);

Expand Down
32 changes: 11 additions & 21 deletions src/jrd/pag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,15 +1147,17 @@ 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;
dbb->dbb_flags |= DBB_read_only;
}

// 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
Expand All @@ -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)
Expand Down

0 comments on commit 55fd220

Please sign in to comment.