Auto-guess atomic_write_size from /sys

This commit is contained in:
Vitaliy Filippov
2025-12-02 01:52:12 +03:00
parent eaff4509ca
commit 959f792f82
8 changed files with 48 additions and 2 deletions
+9 -1
View File
@@ -56,8 +56,16 @@ static int check_queue_cache(std::string dev, std::string parent_dev)
return trim(r) == "write through" ? 0 : -1;
}
uint64_t get_atomic_write_size(const std::string & dev)
{
auto parent_dev = get_parent_device(dev);
if (parent_dev == "")
return 0;
return stoull_full(trim(read_file("/sys/block/"+parent_dev.substr(5)+"/queue/atomic_write_max_bytes")));
}
// returns 1 = warning, -1 = error, 0 = success
int disable_cache(std::string dev)
int disable_cache(const std::string & dev)
{
auto parent_dev = get_parent_device(dev);
if (parent_dev == "")