-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1275 from trapexit/noflush
Add flushonclose feature
- Loading branch information
Showing
11 changed files
with
196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,10 @@ These options are the same regardless of whether you use them with the | |
to the same as the process thread count. (default: 0) | ||
* **pin-threads=STR**: Selects a strategy to pin threads to CPUs | ||
(default: unset) | ||
* **scheduling-priority=INT**: Set mergerfs' scheduling | ||
* **flush-on-close=never|always|opened-for-write**: Flush data cache | ||
on file close. Mostly for when writeback is enabled or merging | ||
network filesystems. (default: opened-for-write) | ||
* **scheduling-priority=INT**: Set mergerfs' scheduling | ||
priority. Valid values range from -20 to 19. See `setpriority` man | ||
page for more details. (default: -10) | ||
* **fsname=STR**: Sets the name of the filesystem as seen in | ||
|
@@ -926,6 +929,27 @@ The options `statfs` and `statfs_ignore` can be used to modify | |
`statfs` behavior. | ||
|
||
|
||
#### flush-on-close | ||
|
||
https://lkml.kernel.org/linux-fsdevel/[email protected]/T/ | ||
|
||
By default FUSE would issue a flush before the release of a file | ||
descriptor. This was considered a bit aggressive and a feature added | ||
to give the FUSE server the ability to choose when that happens. | ||
|
||
Options: | ||
* always | ||
* never | ||
* opened-for-write | ||
|
||
For now it defaults to "opened-for-write" which is less aggressive | ||
than the behavior before this feature was added. It should not be a | ||
problem because the flush is really only relevant when a file is | ||
written to. Given flush is irrelevant for many filesystems in the | ||
future a branch specific flag may be added so only files opened on a | ||
specific branch would be flushed on close. | ||
|
||
|
||
# ERROR HANDLING | ||
|
||
POSIX filesystem functions offer a single return code meaning that | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
ISC License | ||
Copyright (c) 2023, Antonio SJ Musumeci <[email protected]> | ||
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_flushonclose.hpp" | ||
#include "ef.hpp" | ||
#include "errno.hpp" | ||
|
||
template<> | ||
std::string | ||
FlushOnClose::to_string() const | ||
{ | ||
switch(_data) | ||
{ | ||
case FlushOnClose::ENUM::NEVER: | ||
return "never"; | ||
case FlushOnClose::ENUM::OPENED_FOR_WRITE: | ||
return "opened-for-write"; | ||
case FlushOnClose::ENUM::ALWAYS: | ||
return "always"; | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
template<> | ||
int | ||
FlushOnClose::from_string(const std::string &s_) | ||
{ | ||
if(s_ == "never") | ||
_data = FlushOnClose::ENUM::NEVER; | ||
ef(s_ == "opened-for-write") | ||
_data = FlushOnClose::ENUM::OPENED_FOR_WRITE; | ||
ef(s_ == "always") | ||
_data = FlushOnClose::ENUM::ALWAYS; | ||
else | ||
return -EINVAL; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
ISC License | ||
Copyright (c) 2023, Antonio SJ Musumeci <[email protected]> | ||
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 "enum.hpp" | ||
|
||
|
||
enum class FlushOnCloseEnum | ||
{ | ||
NEVER, | ||
OPENED_FOR_WRITE, | ||
ALWAYS | ||
}; | ||
|
||
typedef Enum<FlushOnCloseEnum> FlushOnClose; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters