Multi cache support

This commit is contained in:
bergware
2020-03-22 11:11:18 +01:00
parent c7a3637f08
commit 97480b2421
10 changed files with 14 additions and 19 deletions

View File

@@ -65,9 +65,9 @@ function status_indicator() {
echo "<a class='info'><i class='fa fa-$orb orb $color-orb'></i><span>$help</span></a>";
}
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;
}
?>

View File

@@ -83,11 +83,11 @@ pool_status();
<?$i = 0?>
<?foreach ($pools as $pool):?>
<?if ($cache[$pool]['devices'] || $var['fsState']=='Stopped'):?>
<?if ($disks[$pool]['devices'] || $var['fsState']=='Stopped'):?>
<table class="disk_status wide<?=$i?' divider':''?>">
<thead><tr><td>_(Device)_</td><td>_(Identification)_</td><td>_(Temp)_.</td><td>_(Reads)_</td><td>_(Writes)_</td><td>_(Errors)_</td><td>_(FS)_</td><td>_(Size)_</td><td>_(Used)_</td><td>_(Free)_</td><td>_(View)_</td></tr></thead>
<tbody id="pool_device<?=$i++?>">
<?foreach ($cache as $disk) if (prefix($disk['name']==$pool)) echo "<tr><td colspan='11'>&nbsp;</td></tr>"?>
<?foreach (cache_filter($disks) as $disk) if (prefix($disk['name']==$pool)) echo "<tr><td colspan='11'>&nbsp;</td></tr>"?>
</tbody>
</table>
<?endif;?>

View File

@@ -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;
}

View File

@@ -78,7 +78,7 @@ effect of making it ***impossible*** to rebuild an existing failed drive - you h
<?=mk_option_check(0,'parity',_('Parity slots'))?>
<?=mk_option_check(0,'data',_('Data slots'))?>
<?foreach ($pools as $pool):?>
<?if ($cache[$pool]['devices']) echo mk_option_check(0,$pool,ucfirst($pool).' '._('slots'))?>
<?if ($disks[$pool]['devices']) echo mk_option_check(0,$pool,ucfirst($pool).' '._('slots'))?>
<?endforeach;?>
</select>
<br>

View File

@@ -151,7 +151,7 @@ _(Use cache pool (for new files/directories))_:
_(Select cache pool)_:
: <select name="shareCachePool">
<?foreach ($pools as $pool):?>
<?if ($cache[$pool]['devices']) echo mk_option($share['cachePool'],$pool,ucfirst($pool))?>
<?if ($disks[$pool]['devices']) echo mk_option($share['cachePool'],$pool,ucfirst($pool))?>
<?endforeach;?>
</select>

View File

@@ -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) {

View File

@@ -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";
}

View File

@@ -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') {

View File

@@ -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;

View File

@@ -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));