mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-03 05:10:14 -05:00
Support Linux v6.13 FUSE max_page_limit
This commit is contained in:
parent
d31e97e64c
commit
92ae63e842
12 changed files with 221 additions and 24 deletions
|
|
@ -102,7 +102,7 @@ Config::Config()
|
|||
follow_symlinks(FollowSymlinks::ENUM::NEVER),
|
||||
fsname(),
|
||||
func(),
|
||||
fuse_msg_size(FUSE_MAX_MAX_PAGES),
|
||||
fuse_msg_size("1M"),
|
||||
ignorepponrename(false),
|
||||
inodecalc("hybrid-hash"),
|
||||
lazy_umount_mountpoint(false),
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@
|
|||
#include "config_cachefiles.hpp"
|
||||
#include "config_flushonclose.hpp"
|
||||
#include "config_follow_symlinks.hpp"
|
||||
#include "config_pid.hpp"
|
||||
#include "config_inodecalc.hpp"
|
||||
#include "config_link_exdev.hpp"
|
||||
#include "config_log_metrics.hpp"
|
||||
#include "config_moveonenospc.hpp"
|
||||
#include "config_nfsopenhack.hpp"
|
||||
#include "config_pagesize.hpp"
|
||||
#include "config_pid.hpp"
|
||||
#include "config_rename_exdev.hpp"
|
||||
#include "config_set.hpp"
|
||||
#include "config_statfs.hpp"
|
||||
|
|
@ -124,7 +125,7 @@ public:
|
|||
FollowSymlinks follow_symlinks;
|
||||
ConfigSTR fsname;
|
||||
Funcs func;
|
||||
ConfigUINT64 fuse_msg_size;
|
||||
ConfigPageSize fuse_msg_size;
|
||||
ConfigBOOL ignorepponrename;
|
||||
InodeCalc inodecalc;
|
||||
ConfigBOOL kernel_cache;
|
||||
|
|
|
|||
61
src/config_pagesize.cpp
Normal file
61
src/config_pagesize.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2025, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config_pagesize.hpp"
|
||||
|
||||
#include "from_string.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
ConfigPageSize::ConfigPageSize(const uint64_t v_)
|
||||
: _v(v_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ConfigPageSize::ConfigPageSize(const std::string &s_)
|
||||
{
|
||||
from_string(s_);
|
||||
}
|
||||
|
||||
std::string
|
||||
ConfigPageSize::to_string(void) const
|
||||
{
|
||||
return std::to_string(_v);
|
||||
}
|
||||
|
||||
int
|
||||
ConfigPageSize::from_string(const std::string &s_)
|
||||
{
|
||||
uint64_t v;
|
||||
uint64_t pagesize;
|
||||
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
|
||||
str::from(s_,&v);
|
||||
if(!std::isalpha(s_.back()))
|
||||
v *= pagesize;
|
||||
|
||||
_v = ((v + pagesize - 1) / pagesize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
src/config_pagesize.hpp
Normal file
51
src/config_pagesize.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2025, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tofrom_string.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class ConfigPageSize : public ToFromString
|
||||
{
|
||||
private:
|
||||
uint64_t _v;
|
||||
|
||||
public:
|
||||
ConfigPageSize(const uint64_t);
|
||||
ConfigPageSize(const std::string &);
|
||||
|
||||
public:
|
||||
std::string to_string(void) const final;
|
||||
int from_string(const std::string &) final;
|
||||
|
||||
public:
|
||||
ConfigPageSize&
|
||||
operator=(const uint64_t v_)
|
||||
{
|
||||
_v = v_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator const uint64_t() const
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
};
|
||||
|
|
@ -76,6 +76,11 @@ namespace str
|
|||
tmp = ::strtoll(value_.c_str(),&endptr,10);
|
||||
switch(*endptr)
|
||||
{
|
||||
case 'b':
|
||||
case 'B':
|
||||
tmp *= 1ULL;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
case 'K':
|
||||
tmp *= 1024ULL;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@
|
|||
|
||||
#include "fuse.h"
|
||||
|
||||
#include "ghc/filesystem.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace l
|
||||
|
|
@ -68,15 +71,67 @@ namespace l
|
|||
*want_ = false;
|
||||
}
|
||||
|
||||
#define MAX_FUSE_MSG_SIZE 65535
|
||||
static const char MAX_PAGES_LIMIT_FILEPATH[] = "/proc/sys/fs/fuse/max_pages_limit";
|
||||
|
||||
static
|
||||
void
|
||||
want_if_capable_max_pages(fuse_conn_info *conn_,
|
||||
Config::Write &cfg_)
|
||||
{
|
||||
std::fstream f;
|
||||
uint64_t max_pages_limit;
|
||||
|
||||
if(ghc::filesystem::exists(MAX_PAGES_LIMIT_FILEPATH))
|
||||
{
|
||||
if(cfg_->fuse_msg_size > MAX_FUSE_MSG_SIZE)
|
||||
syslog_info("fuse_msg_size > %u: setting it to %u",
|
||||
MAX_FUSE_MSG_SIZE,
|
||||
MAX_FUSE_MSG_SIZE);
|
||||
cfg_->fuse_msg_size = std::min((uint64_t)cfg_->fuse_msg_size,
|
||||
(uint64_t)MAX_FUSE_MSG_SIZE);
|
||||
|
||||
f.open(MAX_PAGES_LIMIT_FILEPATH,f.in|f.out);
|
||||
if(f.is_open())
|
||||
{
|
||||
f >> max_pages_limit;
|
||||
syslog_info("%s currently set to %u",
|
||||
MAX_PAGES_LIMIT_FILEPATH,
|
||||
(uint64_t)max_pages_limit);
|
||||
if(cfg_->fuse_msg_size > max_pages_limit)
|
||||
{
|
||||
f.seekp(0);
|
||||
f << (uint64_t)cfg_->fuse_msg_size;
|
||||
f.flush();
|
||||
syslog_info("%s changed to %u",
|
||||
MAX_PAGES_LIMIT_FILEPATH,
|
||||
(uint64_t)cfg_->fuse_msg_size);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cfg_->fuse_msg_size != FUSE_DEFAULT_MAX_MAX_PAGES)
|
||||
syslog_info("unable to open %s",MAX_PAGES_LIMIT_FILEPATH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cfg_->fuse_msg_size > FUSE_DEFAULT_MAX_MAX_PAGES)
|
||||
syslog_info("fuse_msg_size request %u > %u: setting it to %u",
|
||||
(uint64_t)cfg_->fuse_msg_size,
|
||||
FUSE_DEFAULT_MAX_MAX_PAGES,
|
||||
FUSE_DEFAULT_MAX_MAX_PAGES);
|
||||
cfg_->fuse_msg_size = std::min((uint64_t)cfg_->fuse_msg_size,
|
||||
(uint64_t)FUSE_DEFAULT_MAX_MAX_PAGES);
|
||||
}
|
||||
|
||||
if(l::capable(conn_,FUSE_CAP_MAX_PAGES))
|
||||
{
|
||||
l::want(conn_,FUSE_CAP_MAX_PAGES);
|
||||
conn_->max_pages = cfg_->fuse_msg_size;
|
||||
syslog_info("requesting max pages size of %u",
|
||||
(uint64_t)cfg_->fuse_msg_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue