aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthexai <58434170+thexai@users.noreply.github.com>2023-10-29 07:13:19 +0100
committerthexai <58434170+thexai@users.noreply.github.com>2023-10-29 10:39:38 +0100
commit0ad623cfbf508e1b611909fed784beb345885b5b (patch)
tree8b947caa83b912d62049a4aaf4f886c109b82e0f
parent5a6255c2d7062befe8d02dcdd90a27b7c6728167 (diff)
[FileSystem] Add GUI settings for NFS and SMB chunk size
-rw-r--r--addons/resource.language.en_gb/resources/strings.po32
-rwxr-xr-xsystem/settings/settings.xml20
-rw-r--r--xbmc/filesystem/NFSFile.cpp32
-rw-r--r--xbmc/platform/posix/filesystem/SMBFile.cpp6
-rw-r--r--xbmc/platform/posix/filesystem/SMBFile.h2
-rw-r--r--xbmc/platform/win32/filesystem/Win32File.cpp12
-rw-r--r--xbmc/settings/CMakeLists.txt2
-rw-r--r--xbmc/settings/ServicesSettings.cpp23
-rw-r--r--xbmc/settings/ServicesSettings.h23
-rw-r--r--xbmc/settings/Settings.cpp4
-rw-r--r--xbmc/settings/Settings.h1
11 files changed, 147 insertions, 10 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 557d2f7f04..66f9f2039f 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -22143,7 +22143,37 @@ msgctxt "#37052"
msgid "NFS protocol version to use when establishing NFS connections"
msgstr ""
-#empty strings from id 37053 to 38010
+#. Settings / Services "Chunk Size" group label
+#: system/settings/settings.xml
+msgctxt "#37053"
+msgid "Chunk Size"
+msgstr ""
+
+#. Setting #37054 "NFS Chunk Size"
+#: xbmc/filesystem/NFSFile.cpp
+msgctxt "#37054"
+msgid "NFS Chunk Size"
+msgstr ""
+
+#. Description of setting #37054 "NFS Chunk Size"
+#: system/settings/settings.xml
+msgctxt "#37055"
+msgid "Data chunk size used on NFS connections"
+msgstr ""
+
+#. Setting #37056 "SMB Chunk Size"
+#: system/settings/settings.xml
+msgctxt "#37056"
+msgid "SMB Chunk Size"
+msgstr ""
+
+#. Description of setting #37056 "SMB Chunk Size"
+#: system/settings/settings.xml
+msgctxt "#37057"
+msgid "Data chunk size used on SMB connections"
+msgstr ""
+
+#empty strings from id 37058 to 38010
#. Setting #38011 "Show All Items entry"
#: system/settings/settings.xml
diff --git a/system/settings/settings.xml b/system/settings/settings.xml
index 7154234eee..a9839e44e2 100755
--- a/system/settings/settings.xml
+++ b/system/settings/settings.xml
@@ -2417,6 +2417,16 @@
<control type="toggle" />
</setting>
</group>
+ <group id="4" label="37053">
+ <setting id="smb.chunksize" type="integer" label="37056" help="37057">
+ <level>2</level>
+ <default>128</default>
+ <constraints>
+ <options>filechunksizes</options>
+ </constraints>
+ <control type="list" format="string" />
+ </setting>
+ </group>
</category>
<category id="nfs" label="1201" help="36356">
<requirement>HAS_FILESYSTEM_NFS</requirement>
@@ -2432,6 +2442,16 @@
<control type="spinner" format="integer" />
</setting>
</group>
+ <group id="2" label="37053">
+ <setting id="nfs.chunksize" type="integer" label="37054" help="37055">
+ <level>2</level>
+ <default>128</default>
+ <constraints>
+ <options>filechunksizes</options>
+ </constraints>
+ <control type="list" format="string" />
+ </setting>
+ </group>
</category>
<category id="weather" label="8" help="36316">
<group id="1" label="16000">
diff --git a/xbmc/filesystem/NFSFile.cpp b/xbmc/filesystem/NFSFile.cpp
index 5e0c148770..b96b2bc4fa 100644
--- a/xbmc/filesystem/NFSFile.cpp
+++ b/xbmc/filesystem/NFSFile.cpp
@@ -56,6 +56,7 @@ constexpr auto IDLE_TIMEOUT = 30s; // close fast unused contexts when no active
constexpr int NFS4ERR_EXPIRED = -11; // client session expired due idle time greater than lease_time
constexpr auto SETTING_NFS_VERSION = "nfs.version";
+constexpr auto SETTING_NFS_CHUNKSIZE = "nfs.chunksize";
} // unnamed namespace
CNfsConnection::CNfsConnection()
@@ -334,15 +335,38 @@ bool CNfsConnection::Connect(const CURL& url, std::string &relativePath)
m_readChunkSize = nfs_get_readmax(m_pNfsContext);
m_writeChunkSize = nfs_get_writemax(m_pNfsContext);
+ const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
+ const uint64_t chunkSize =
+ settings ? (settings->GetInt(SETTING_NFS_CHUNKSIZE) * 1024) : (128 * 1024);
+
if (m_readChunkSize == 0)
{
- CLog::Log(LOGDEBUG, "NFS Server did not return max read chunksize - Using 128K default");
- m_readChunkSize = 128 * 1024; // 128K
+ CLog::Log(LOGDEBUG, "NFS Server did not return max read chunksize - Using setting value {}",
+ chunkSize);
+ m_readChunkSize = chunkSize;
+ }
+ else if (chunkSize < m_readChunkSize)
+ {
+ CLog::Log(LOGDEBUG,
+ "NFS Server max read chunksize ({}) is bigger than client setting - Using client "
+ "value {}",
+ m_readChunkSize, chunkSize);
+ m_readChunkSize = chunkSize;
}
+
if (m_writeChunkSize == 0)
{
- CLog::Log(LOGDEBUG, "NFS Server did not return max write chunksize - Using 128K default");
- m_writeChunkSize = 128 * 1024; // 128K
+ CLog::Log(LOGDEBUG, "NFS Server did not return max write chunksize - Using setting value {}",
+ chunkSize);
+ m_writeChunkSize = chunkSize;
+ }
+ else if (chunkSize < m_writeChunkSize)
+ {
+ CLog::Log(LOGDEBUG,
+ "NFS Server max write chunksize ({}) is bigger than client setting - Using client "
+ "value {}",
+ m_writeChunkSize, chunkSize);
+ m_writeChunkSize = chunkSize;
}
if (contextRet == CNfsConnection::ContextStatus::NEW)
diff --git a/xbmc/platform/posix/filesystem/SMBFile.cpp b/xbmc/platform/posix/filesystem/SMBFile.cpp
index 38a82c3114..db02e177a2 100644
--- a/xbmc/platform/posix/filesystem/SMBFile.cpp
+++ b/xbmc/platform/posix/filesystem/SMBFile.cpp
@@ -719,3 +719,9 @@ int CSMBFile::IoControl(EIoControl request, void* param)
return -1;
}
+int CSMBFile::GetChunkSize()
+{
+ const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
+
+ return settings ? (settings->GetInt(CSettings::SETTING_SMB_CHUNKSIZE) * 1024) : (128 * 1024);
+}
diff --git a/xbmc/platform/posix/filesystem/SMBFile.h b/xbmc/platform/posix/filesystem/SMBFile.h
index 8cc960e8e1..74d263588c 100644
--- a/xbmc/platform/posix/filesystem/SMBFile.h
+++ b/xbmc/platform/posix/filesystem/SMBFile.h
@@ -79,7 +79,7 @@ public:
bool OpenForWrite(const CURL& url, bool bOverWrite = false) override;
bool Delete(const CURL& url) override;
bool Rename(const CURL& url, const CURL& urlnew) override;
- int GetChunkSize() override { return 64*1024; }
+ int GetChunkSize() override;
int IoControl(EIoControl request, void* param) override;
protected:
diff --git a/xbmc/platform/win32/filesystem/Win32File.cpp b/xbmc/platform/win32/filesystem/Win32File.cpp
index ae92fd89af..8b2af8ad9a 100644
--- a/xbmc/platform/win32/filesystem/Win32File.cpp
+++ b/xbmc/platform/win32/filesystem/Win32File.cpp
@@ -8,6 +8,9 @@
#include "Win32File.h"
+#include "ServiceBroker.h"
+#include "settings/Settings.h"
+#include "settings/SettingsComponent.h"
#include "utils/log.h"
#include "platform/win32/CharsetConverter.h"
@@ -20,10 +23,8 @@
#include <intsafe.h>
#include <sys/stat.h>
-
using namespace XFILE;
-
CWin32File::CWin32File() : m_smbFile(false)
{
m_hFile = INVALID_HANDLE_VALUE;
@@ -40,7 +41,6 @@ CWin32File::CWin32File(bool asSmbFile) : m_smbFile(asSmbFile)
m_lastSMBFileErr = ERROR_SUCCESS;
}
-
CWin32File::~CWin32File()
{
if (m_hFile != INVALID_HANDLE_VALUE)
@@ -765,7 +765,11 @@ int CWin32File::Stat(struct __stat64* statData)
int CWin32File::GetChunkSize()
{
if (m_smbFile)
- return 64 * 1024;
+ {
+ const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();
+
+ return settings ? (settings->GetInt(CSettings::SETTING_SMB_CHUNKSIZE) * 1024) : (128 * 1024);
+ }
return 0;
}
diff --git a/xbmc/settings/CMakeLists.txt b/xbmc/settings/CMakeLists.txt
index f53d12b741..d477f51d5d 100644
--- a/xbmc/settings/CMakeLists.txt
+++ b/xbmc/settings/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SOURCES AdvancedSettings.cpp
LibExportSettings.cpp
MediaSettings.cpp
MediaSourceSettings.cpp
+ ServicesSettings.cpp
SettingAddon.cpp
SettingConditions.cpp
SettingControl.cpp
@@ -27,6 +28,7 @@ set(HEADERS AdvancedSettings.h
LibExportSettings.h
MediaSettings.h
MediaSourceSettings.h
+ ServicesSettings.h
SettingAddon.h
SettingConditions.h
SettingControl.h
diff --git a/xbmc/settings/ServicesSettings.cpp b/xbmc/settings/ServicesSettings.cpp
new file mode 100644
index 0000000000..099f25c196
--- /dev/null
+++ b/xbmc/settings/ServicesSettings.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "ServicesSettings.h"
+
+void CServicesSettings::SettingOptionsChunkSizesFiller(const SettingConstPtr& setting,
+ std::vector<IntegerSettingOption>& list,
+ int& current,
+ void* data)
+{
+ list.emplace_back("16 KB", 16);
+ list.emplace_back("32 KB", 32);
+ list.emplace_back("64 KB", 64);
+ list.emplace_back("128 KB", 128);
+ list.emplace_back("256 KB", 256);
+ list.emplace_back("512 KB", 512);
+ list.emplace_back("1 MB", 1024);
+}
diff --git a/xbmc/settings/ServicesSettings.h b/xbmc/settings/ServicesSettings.h
new file mode 100644
index 0000000000..92ee47adcc
--- /dev/null
+++ b/xbmc/settings/ServicesSettings.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "settings/ISubSettings.h"
+#include "settings/lib/Setting.h"
+
+#include <vector>
+
+class CServicesSettings : public ISubSettings
+{
+public:
+ static void SettingOptionsChunkSizesFiller(const SettingConstPtr& setting,
+ std::vector<IntegerSettingOption>& list,
+ int& current,
+ void* data);
+};
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index 7f30770710..8a2fef4219 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -43,6 +43,7 @@
#include "settings/DisplaySettings.h"
#include "settings/MediaSettings.h"
#include "settings/MediaSourceSettings.h"
+#include "settings/ServicesSettings.h"
#include "settings/SettingConditions.h"
#include "settings/SettingsComponent.h"
#include "settings/SkinSettings.h"
@@ -436,6 +437,8 @@ void CSettings::InitializeOptionFillers()
GetSettingsManager()->RegisterSettingOptionsFiller("timezones", CPosixTimezone::SettingOptionsTimezonesFiller);
#endif
GetSettingsManager()->RegisterSettingOptionsFiller("keyboardlayouts", CKeyboardLayoutManager::SettingOptionsKeyboardLayoutsFiller);
+ GetSettingsManager()->RegisterSettingOptionsFiller(
+ "filechunksizes", CServicesSettings::SettingOptionsChunkSizesFiller);
}
void CSettings::UninitializeOptionFillers()
@@ -482,6 +485,7 @@ void CSettings::UninitializeOptionFillers()
#endif // defined(TARGET_LINUX)
GetSettingsManager()->UnregisterSettingOptionsFiller("verticalsyncs");
GetSettingsManager()->UnregisterSettingOptionsFiller("keyboardlayouts");
+ GetSettingsManager()->UnregisterSettingOptionsFiller("filechunksizes");
}
void CSettings::InitializeConditions()
diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h
index 8a3dead5bb..c0a979d3c2 100644
--- a/xbmc/settings/Settings.h
+++ b/xbmc/settings/Settings.h
@@ -348,6 +348,7 @@ public:
static constexpr auto SETTING_SMB_MINPROTOCOL = "smb.minprotocol";
static constexpr auto SETTING_SMB_MAXPROTOCOL = "smb.maxprotocol";
static constexpr auto SETTING_SMB_LEGACYSECURITY = "smb.legacysecurity";
+ static constexpr auto SETTING_SMB_CHUNKSIZE = "smb.chunksize";
static constexpr auto SETTING_SERVICES_WSDISCOVERY = "services.wsdiscovery";
static constexpr auto SETTING_VIDEOSCREEN_MONITOR = "videoscreen.monitor";
static constexpr auto SETTING_VIDEOSCREEN_SCREEN = "videoscreen.screen";