mirror of
https://github.com/unraid/webgui.git
synced 2026-01-21 09:00:19 -06:00
TRIM: improved ZFS trim reporting
This commit is contained in:
@@ -37,24 +37,29 @@ function write(...$messages){
|
||||
curl_close($com);
|
||||
}
|
||||
|
||||
write(_("SSD Trim started").". "._("Please wait")."...\n");
|
||||
write(_("SSD Trim started").". "._("Please wait")."...\n","\n");
|
||||
// trim btrfs pools
|
||||
$trim = popen('fstrim -a -v','r');
|
||||
$trim = popen('fstrim -va','r');
|
||||
while (!feof($trim)) write(fgets($trim));
|
||||
pclose($trim);
|
||||
write("\n","\n");
|
||||
write("\n");
|
||||
|
||||
// trim zfs pools
|
||||
exec("/usr/sbin/zpool status|grep -Po 'pool: \K.+'",$zfs_pools);
|
||||
exec("zpool status|grep -Po 'pool: \K.+'",$zfs_pools);
|
||||
foreach ($zfs_pools as $pool) if ($pool) {
|
||||
exec("/usr/sbin/zpool trim $pool");
|
||||
unset($devs);
|
||||
exec("zpool trim $pool");
|
||||
while (true) {
|
||||
sleep(1);
|
||||
$trim = exec("/usr/sbin/zpool status -t $pool|grep -Pom1 '\d+% trimmed'");
|
||||
write("ZFS pool $pool $trim\r");
|
||||
$trim = exec("zpool status -t $pool|grep -Pom1 '\d+% trimmed'");
|
||||
write("/mnt/$pool: $trim\r");
|
||||
if (substr($trim,0,3)==100) break;
|
||||
}
|
||||
write("\n");
|
||||
$trim = preg_replace('/(.$)/',' $1',exec("zfs list $pool|grep -Pom1 '^$pool\s+\K\S+'"))."iB";
|
||||
$bytes = exec("zfs list -p $pool|grep -Pom1 '^$pool\s+\K\d+'");
|
||||
exec("zpool status -t $pool|grep -Po '^\s+\K.+100%'",$devs);
|
||||
$devs = implode(', ',array_map(function($dev){return "/dev/".strtok($dev,' ');},$devs));
|
||||
write("/mnt/$pool: $trim ($bytes bytes) trimmed on $devs\r","\n");
|
||||
}
|
||||
write(_("Finished")."\n",'_DONE_','');
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user