Skip to content

Commit

Permalink
dird-conf: remove optimize_for_*
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsura authored and BareosBot committed Dec 12, 2023
1 parent 7a65a1e commit 9a4c62e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 84 deletions.
4 changes: 1 addition & 3 deletions core/src/benchmarks/restore_browser_stress_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2021-2022 Bareos GmbH & Co. KG
Copyright (C) 2021-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -84,8 +84,6 @@ int FakeMarkCmd(UaContext* ua, TreeContext* tree, std::string path)
void PopulateTree(int quantity, TreeContext* tree)
{
me = new DirectorResource;
me->optimize_for_size = true;
me->optimize_for_speed = false;
InitContexts(&ua, tree);

char* filename = GetPoolMemory(PM_FNAME);
Expand Down
2 changes: 0 additions & 2 deletions core/src/dird/dird_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ static ResourceItem dir_items[] = {
{ "StatisticsRetention", CFG_TYPE_TIME, ITEM(res_dir, stats_retention), 0, CFG_ITEM_DEPRECATED | CFG_ITEM_DEFAULT, "160704000" /* 5 years */, NULL, NULL },
{ "StatisticsCollectInterval", CFG_TYPE_PINT32, ITEM(res_dir, stats_collect_interval), 0, CFG_ITEM_DEPRECATED | CFG_ITEM_DEFAULT, "0", "14.2.0-", NULL },
{ "VerId", CFG_TYPE_STR, ITEM(res_dir, verid), 0, 0, NULL, NULL, NULL },
{ "OptimizeForSize", CFG_TYPE_BOOL, ITEM(res_dir, optimize_for_size), 0, CFG_ITEM_DEPRECATED | CFG_ITEM_DEFAULT, "false", NULL, NULL },
{ "OptimizeForSpeed", CFG_TYPE_BOOL, ITEM(res_dir, optimize_for_speed), 0, CFG_ITEM_DEPRECATED | CFG_ITEM_DEFAULT, "false", NULL, NULL },
{ "KeyEncryptionKey", CFG_TYPE_AUTOPASSWORD, ITEM(res_dir, keyencrkey), 1, 0, NULL, NULL, NULL },
{ "NdmpSnooping", CFG_TYPE_BOOL, ITEM(res_dir, ndmp_snooping), 0, 0, NULL, "13.2.0-", NULL },
{ "NdmpLogLevel", CFG_TYPE_PINT32, ITEM(res_dir, ndmp_loglevel), 0, CFG_ITEM_DEFAULT, "4", "13.2.0-", NULL },
Expand Down
7 changes: 2 additions & 5 deletions core/src/dird/dird_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,8 @@ class DirectorResource
utime_t FDConnectTimeout = {0}; /* Timeout for connect in seconds */
utime_t SDConnectTimeout = {0}; /* Timeout for connect in seconds */
utime_t heartbeat_interval = {0}; /* Interval to send heartbeats */
utime_t stats_retention = {0}; /* Statistics retention period in seconds */
bool optimize_for_size = false; /* Optimize daemon for minimum memory size */
bool optimize_for_speed = false; /* Optimize daemon for speed which may need
more memory */
bool ndmp_snooping = false; /* NDMP Protocol specific snooping enabled */
utime_t stats_retention = {0}; /* Statistics retention period in seconds */
bool ndmp_snooping = false; /* NDMP Protocol specific snooping enabled */
bool ndmp_fhinfo_set_zero_for_invalid_u_quad
= false; // Workaround for Isilon 9.1.0.0 not accepting -1 as value for
// FhInfo (which is the tape offset)
Expand Down
10 changes: 0 additions & 10 deletions core/src/dird/reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ bool CheckResources()
}
}

// When the user didn't force us we optimize for size.
if (!me->optimize_for_size && !me->optimize_for_speed) {
me->optimize_for_size = true;
} else if (me->optimize_for_size && me->optimize_for_speed) {
Jmsg(nullptr, M_FATAL, 0,
T_("Cannot optimize for speed and size define only one in %s\n"),
configfile.c_str());
return false;
}

if (my_config->GetNextRes(R_DIRECTOR, (BareosResource*)me) != nullptr) {
Jmsg(nullptr, M_FATAL, 0,
T_("Only one Director resource permitted in %s\n"),
Expand Down
62 changes: 15 additions & 47 deletions core/src/dird/ua_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,17 @@ int InsertTreeHandler(void* ctx, int, char** row)
entry->node = node;
tree->root->hardlinks.insert(entry->key, entry);
} else {
// See if we are optimizing for speed or size.
if (!me->optimize_for_size && me->optimize_for_speed) {
// Hardlink to known file index: lookup original file
uint64_t file_key = (((uint64_t)JobId) << 32) + LinkFI;
HL_ENTRY* first_hl
= (HL_ENTRY*)tree->root->hardlinks.lookup(file_key);

if (first_hl && first_hl->node) {
// Then add hardlink entry to linked node.
entry = (HL_ENTRY*)tree->root->hardlinks.hash_malloc(
sizeof(HL_ENTRY));
entry->key = (((uint64_t)JobId) << 32) + FileIndex;
entry->node = first_hl->node;
tree->root->hardlinks.insert(entry->key, entry);
}
// Hardlink to known file index: lookup original file
uint64_t file_key = (((uint64_t)JobId) << 32) + LinkFI;
HL_ENTRY* first_hl = (HL_ENTRY*)tree->root->hardlinks.lookup(file_key);

if (first_hl && first_hl->node) {
// Then add hardlink entry to linked node.
entry
= (HL_ENTRY*)tree->root->hardlinks.hash_malloc(sizeof(HL_ENTRY));
entry->key = (((uint64_t)JobId) << 32) + FileIndex;
entry->node = first_hl->node;
tree->root->hardlinks.insert(entry->key, entry);
}
}
}
Expand Down Expand Up @@ -387,38 +383,10 @@ static int SetExtract(UaContext* ua,
uint64_t key = 0;
bool is_hardlinked = false;

// See if we are optimizing for speed or size.
if (!me->optimize_for_size && me->optimize_for_speed) {
if (node->hard_link) {
// Every hardlink is in hashtable, and it points to linked file.
key = (((uint64_t)node->JobId) << 32) + node->FileIndex;
is_hardlinked = true;
}
} else {
FileDbRecord fdbr;
POOLMEM* cwd;

/* Ordinary file, we get the full path, look up the attributes, decode
* them, and if we are hard linked to a file that was saved, we must
* load that file too. */
cwd = tree_getpath(node);
if (cwd) {
fdbr.FileId = 0;
fdbr.JobId = node->JobId;

if (node->hard_link
&& ua->db->GetFileAttributesRecord(ua->jcr, cwd, NULL, &fdbr)) {
int32_t LinkFI;
struct stat statp;

DecodeStat(fdbr.LStat, &statp, sizeof(statp),
&LinkFI); /* decode stat pkt */
key = (((uint64_t)node->JobId) << 32)
+ LinkFI; /* lookup by linked file's fileindex */
is_hardlinked = true;
}
FreePoolMemory(cwd);
}
if (node->hard_link) {
// Every hardlink is in hashtable, and it points to linked file.
key = (((uint64_t)node->JobId) << 32) + node->FileIndex;
is_hardlinked = true;
}

if (is_hardlinked) {
Expand Down
4 changes: 1 addition & 3 deletions core/src/tests/globbing_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2021-2022 Bareos GmbH & Co. KG
Copyright (C) 2021-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -81,8 +81,6 @@ class Globbing : public testing::Test {
tree.root = new_tree(1);
tree.node = (TREE_NODE*)tree.root;
me = new DirectorResource;
me->optimize_for_size = true;
me->optimize_for_speed = false;
ua = new_ua_context(&jcr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@
"code": 0,
"equals": true
},
"OptimizeForSize": {
"datatype": "BOOLEAN",
"code": 0,
"default_value": "false",
"deprecated": true,
"equals": true
},
"OptimizeForSpeed": {
"datatype": "BOOLEAN",
"code": 0,
"default_value": "false",
"deprecated": true,
"equals": true
},
"KeyEncryptionKey": {
"datatype": "AUTOPASSWORD",
"code": 1,
Expand Down

0 comments on commit 9a4c62e

Please sign in to comment.