Skip to content

Commit

Permalink
Update memory query to new sysinfo function format
Browse files Browse the repository at this point in the history
Workaround for sysinfo build failures on trueNAS freebsd 12 system
  • Loading branch information
UP2GeeK authored and pkolaczk committed Apr 25, 2022
1 parent c1045da commit dc75976
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sled = "0.34"
smallvec = "1.8"
stfu8 = "0.2"
structopt = "0.3"
sysinfo = "0.16"
sysinfo = "0.23.10"
thread_local = "1.1"
uuid = { version = "0.8", features = ["v4"] }

Expand Down
14 changes: 5 additions & 9 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ impl DiskDevice {
FileLen(match self.disk_type {
DiskType::SSD => 4 * 1024,
DiskType::HDD => 4 * 1024,
DiskType::Removable => 4 * 1024,
DiskType::Unknown(_) => 4 * 1024,
})
}
Expand All @@ -105,7 +104,6 @@ impl DiskDevice {
FileLen(match self.disk_type {
DiskType::SSD => 4 * 1024,
DiskType::HDD => 16 * 1024,
DiskType::Removable => 16 * 1024,
DiskType::Unknown(_) => 16 * 1024,
})
}
Expand All @@ -118,7 +116,6 @@ impl DiskDevice {
FileLen(match self.disk_type {
DiskType::HDD => 64 * 1024 * 1024, // 64 MB
DiskType::SSD => 64 * 1024, // 64 kB
DiskType::Removable => 64 * 1024 * 1024,
DiskType::Unknown(_) => 64 * 1024 * 1024,
})
}
Expand Down Expand Up @@ -168,7 +165,6 @@ impl DiskDevices {
let p = match disk_type {
DiskType::SSD => pool_sizes.get(OsStr::new("ssd")),
DiskType::HDD => pool_sizes.get(OsStr::new("hdd")),
DiskType::Removable => pool_sizes.get(OsStr::new("removable")),
DiskType::Unknown(_) => pool_sizes.get(OsStr::new("unknown")),
};
match p {
Expand Down Expand Up @@ -244,17 +240,17 @@ impl DiskDevices {
String::from("unknown"),
pool_sizes,
);
for d in sys.get_disks() {
let device_name = Self::physical_device_name(d.get_name());
for d in sys.disks() {
let device_name = Self::physical_device_name(d.name());
let index = result.add_device(
device_name,
d.get_type(),
String::from_utf8_lossy(d.get_file_system()).to_string(),
d.type_(),
String::from_utf8_lossy(d.file_system()).to_string(),
pool_sizes,
);
result
.mount_points
.push((Path::from(d.get_mount_point()), index));
.push((Path::from(d.mount_point()), index));
}
result
.mount_points
Expand Down
4 changes: 2 additions & 2 deletions src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ fn evict_page_cache_if_low_mem(file: &mut File, len: FileLen) {
if len > skipped_prefix_len {
let mut system = System::new();
system.refresh_memory();
let free_mem = system.get_free_memory();
let total_mem = system.get_total_memory();
let free_mem = system.free_memory();
let total_mem = system.total_memory();
let free_ratio = free_mem as f32 / total_mem as f32;
if free_ratio < 0.05 {
evict_page_cache(
Expand Down

0 comments on commit dc75976

Please sign in to comment.