From 97480b2421f9fd254cf89d8a541674b33eee0608 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 22 Mar 2020 11:11:18 +0100 Subject: [PATCH] Multi cache support --- plugins/dynamix/ArrayOperation.page | 4 ++-- plugins/dynamix/CacheDevices.page | 4 ++-- plugins/dynamix/DashStats.page | 2 +- plugins/dynamix/NewConfig.page | 2 +- plugins/dynamix/ShareEdit.page | 2 +- plugins/dynamix/include/Browse.php | 2 +- plugins/dynamix/include/DashUpdate.php | 4 +--- plugins/dynamix/include/DeviceList.php | 3 +-- plugins/dynamix/include/Helpers.php | 4 ++-- plugins/dynamix/template.php | 6 ++---- 10 files changed, 14 insertions(+), 19 deletions(-) diff --git a/plugins/dynamix/ArrayOperation.page b/plugins/dynamix/ArrayOperation.page index 0dba61911..3be2813ac 100644 --- a/plugins/dynamix/ArrayOperation.page +++ b/plugins/dynamix/ArrayOperation.page @@ -65,9 +65,9 @@ function status_indicator() { echo "$help"; } function missing_cache() { - global $cache; + global $disks; $missing = false; - foreach ($cache as $disk) $missing |= (strpos($disk['status'],'_MISSING')!==false); + foreach (cache_filter($disks) as $disk) $missing |= (strpos($disk['status'],'_MISSING')!==false); return $missing; } ?> diff --git a/plugins/dynamix/CacheDevices.page b/plugins/dynamix/CacheDevices.page index a415c352f..ed71cc600 100644 --- a/plugins/dynamix/CacheDevices.page +++ b/plugins/dynamix/CacheDevices.page @@ -83,11 +83,11 @@ pool_status(); - + -"?> +"?>
_(Device)__(Identification)__(Temp)_._(Reads)__(Writes)__(Errors)__(FS)__(Size)__(Used)__(Free)__(View)_
 
 
diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index a85d86f47..fd22715c5 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -78,7 +78,7 @@ foreach ($disks as $disk) { $cache_used[$name] = $disk['fsSize']-$disk['fsFree']; $cache_type[$name] = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme'; $cache_rate[$name] = number_format(100*$cache_used[$name]/($cache_size[$name] ?: 1),1,$dot,''); - if (!$cache[$name]['devices']) unset($pools[array_search($name,$pools)]); + if (!$disks[$name]['devices']) unset($pools[array_search($name,$pools)]); } break; } diff --git a/plugins/dynamix/NewConfig.page b/plugins/dynamix/NewConfig.page index 0229e875a..dc6f34abf 100644 --- a/plugins/dynamix/NewConfig.page +++ b/plugins/dynamix/NewConfig.page @@ -78,7 +78,7 @@ effect of making it ***impossible*** to rebuild an existing failed drive - you h - +
diff --git a/plugins/dynamix/ShareEdit.page b/plugins/dynamix/ShareEdit.page index 802014144..2038798ec 100644 --- a/plugins/dynamix/ShareEdit.page +++ b/plugins/dynamix/ShareEdit.page @@ -151,7 +151,7 @@ _(Use cache pool (for new files/directories))_: _(Select cache pool)_: : diff --git a/plugins/dynamix/include/Browse.php b/plugins/dynamix/include/Browse.php index 55748f215..b5e05aa4c 100644 --- a/plugins/dynamix/include/Browse.php +++ b/plugins/dynamix/include/Browse.php @@ -39,7 +39,7 @@ $user = $_GET['user']; $list = []; $all = $docroot.preg_replace('/([\'" &()[\]\\\\])/','\\\\$1',$dir).'/*'; $fix = substr($dir,0,4)=='/mnt' ? explode('/',trim_slash($dir))[2] : 'flash'; -$cache = implode('|',pools_filter(cache_filter($disks))) ?: 'cache'; +$cache = implode('|',pools_filter($disks)) ?: 'cache'; exec("shopt -s dotglob; stat -L -c'%F|%n|%s|%Y' $all 2>/dev/null",$file); if ($user) { diff --git a/plugins/dynamix/include/DashUpdate.php b/plugins/dynamix/include/DashUpdate.php index 75fab9f7e..e4ed1c531 100644 --- a/plugins/dynamix/include/DashUpdate.php +++ b/plugins/dynamix/include/DashUpdate.php @@ -263,9 +263,7 @@ case 'cache': require_once "$docroot/webGui/include/CustomMerge.php"; require_once "$docroot/webGui/include/Preselect.php"; $error = $warning = $red = $orange = $fail = $smart = $full = $high = 0; - $cache = cache_filter($disks); - $pools = pools_filter($cache); - foreach ($pools as $pool) if ($cache[$pool]['devices']) { + foreach (pools_filter($disks) as $pool) if ($disks[$pool]['devices']) { array_group('Cache',$pool); echo "\0".($error+$warning)."\0".($red+$orange)."\0".($fail+$smart)."\0".($full+$high)."\r"; } diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index 1a6cdea88..0aa22721b 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -379,8 +379,7 @@ case 'flash': break; case 'cache': $cache = cache_filter($disks); - $pools = pools_filter($cache); - foreach ($pools as $pool) { + foreach (pools_filter($cache) as $pool) { $tmp = "/var/tmp/$pool.log.tmp"; foreach ($cache as $disk) if (prefix($disk['name'])==$pool) $crypto |= $disk['luksState']!=0 || vfs_luks($disk['fsType']); if ($var['fsState']=='Stopped') { diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index 17e4a1268..2a82f7dce 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -79,8 +79,8 @@ function data_filter($disks) { function cache_filter($disks) { return array_filter($disks,'cache_only'); } -function pools_filter($cache) { - return array_unique(array_map('prefix',array_keys($cache))); +function pools_filter($disks) { + return array_unique(array_map('prefix',array_keys(cache_filter($disks)))); } function my_id($id) { global $display; diff --git a/plugins/dynamix/template.php b/plugins/dynamix/template.php index 3b37f416b..37e100dd9 100644 --- a/plugins/dynamix/template.php +++ b/plugins/dynamix/template.php @@ -32,11 +32,9 @@ $shares = (array)parse_ini_file('state/shares.ini',true); $sec_nfs = (array)parse_ini_file('state/sec_nfs.ini',true); // Pool devices -$cache = cache_filter($disks); -$pools = pools_filter($cache); - $pool_devices = false; -foreach ($pools as $pool) $pool_devices |= $cache[$pool]['devices']; +$pools = pools_filter($disks); +foreach ($pools as $pool) $pool_devices |= $disks[$pool]['devices']; // Read network settings extract(parse_ini_file('state/network.ini',true));