Multi cache support

This commit is contained in:
bergware
2020-03-21 13:58:26 +01:00
parent c809b0a885
commit 58509f1176
10 changed files with 35 additions and 23 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 $disks;
global $cache;
$missing = false;
foreach ($disks as $disk) if ($disk['type']=='Cache') $missing |= (strpos($disk['status'],'_MISSING')!==false);
foreach ($cache as $disk) $missing |= (strpos($disk['status'],'_MISSING')!==false);
return $missing;
}
?>
@@ -512,7 +512,7 @@ function formatWarning(val) {
<tr><td></td><td><input type="button" value="_(Clear Stats)_" onclick="toggle_state('Clear')"></td><td>**_(Clear Stats)_** _(will immediately clear all disk statistics)_.</td></tr>
<tr><td></td><td class="line" colspan="2"></td></tr>
</table>
<?if ($var['shareCacheEnabled']=="yes" && is_dir("/mnt/cache")):?>
<?if ($var['shareCacheEnabled']=="yes" && $pool_devices):?>
<form name="mover_schedule" method="POST" action="/update.htm" target="progressFrame">
<table markdown="1" class="array_status noshift">
<tr><td></td>

View File

@@ -1,6 +1,7 @@
Menu="Main:2"
Title="Pool Devices"
Tag="bullseye"
Cond="($pool_devices || $var['fsState']=='Stopped')"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
@@ -14,11 +15,6 @@ Tag="bullseye"
* all copies or substantial portions of the Software.
*/
?>
<?
$cache = cache_filter($disks);
$pools = pools_filter($cache);
$i = 0;
?>
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
<style>
table.divider{margin-top:2px}
@@ -80,6 +76,7 @@ $('#tab2').bind({click:function() {$('i.toggle').show('slow');}});
pool_status();
</script>
<?$i = 0?>
<?foreach ($pools as $pool):?>
<?if ($cache[$pool]['devicesSb'] || $var['fsState']=='Stopped'):?>
<table class="disk_status wide<?=$i?' divider':''?>">

View File

@@ -1,7 +1,7 @@
Menu="ShareSettings:2"
Title="Cache Settings"
Tag="upload"
Cond="((isset($disks['cache']))&&($disks['cache']['status']!='DISK_NP'))"
Cond="$pool_devices"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
@@ -29,7 +29,7 @@ $(check_cache_settings);
</script>
<form markdown="1" name="cache_settings" method="POST" action="/update.htm" target="progressFrame">
_(Use cache disk)_:
_(Use cache device)_:
: <select name="shareCacheEnabled" onchange="check_cache_settings()" <?=$disabled?>>
<?=mk_option($var['shareCacheEnabled'], "yes", _('Yes'))?>
<?=mk_option($var['shareCacheEnabled'], "no", _('No'))?>

View File

@@ -63,7 +63,6 @@ $parity = $var['mdResync'];
$mover = file_exists('/var/run/mover.pid');
$btrfs = exec('pgrep -cf /sbin/btrfs');
$dot = $display['number'][0];
$pools = pools_filter(cache_filter($disks));
foreach ($disks as $disk) {
switch ($disk['type']) {

View File

@@ -19,7 +19,6 @@ require_once "$docroot/webGui/include/Preselect.php";
$disk = &$disks[$name];
$date = date('Ymd-Hi');
$events = explode('|',$disk['smEvents'] ?? $var['smEvents'] ?? $numbers);
$pools = pools_filter(cache_filter($disks));
function displayTemp($temp) {
global $display;

View File

@@ -15,12 +15,16 @@ Tag="calendar-check-o"
*/
?>
<?
if (empty($disks['cache']) || $disks['cache']['status']=='DISK_NP') {
echo "<p class='notice'>"._('No Cache disk present')."!</p>";
} elseif ($var['shareCacheEnabled']!='yes') {
echo "<p class='notice'>"._('Cache disk not enabled')."!</p>";
$setup = true;
if ($var['shareCacheEnabled']!='yes') {
echo "<p class='notice'>"._('Cache device not enabled')."!</p>";
$setup = false;
} elseif (!$pool_devices) {
echo "<p class='notice'>"._('No Cache device present')."!</p>";
$setup = false;
} elseif ($var['shareUser']=='-') {
echo "<p class='notice'>"._('User shares not enabled')."!</p>";
$setup = false;
}
$cron = explode(' ',$var['shareMoverSchedule']);
$move = $cron[2]!='*' ? 3 : ($cron[4]!='*' ? 2 : (substr($cron[1],0,1)!='*' ? 1 : 0));
@@ -54,6 +58,7 @@ function presetMover(form) {
}
</script>
<form markdown="1" name="mover_schedule" method="POST" action="/update.htm" target="progressFrame" onsubmit="prepareMover(this)">
<?if ($setup):?>
_(Mover schedule)_:
: <select name="shareMoverSchedule" onchange="presetMover(this.form)">
<?for ($m=0; $m<count($mode); $m++):?>
@@ -127,6 +132,7 @@ _(Mover logging)_:
> Write mover messages to the syslog file.
:end
<?endif;?>
&nbsp;
: <input type="submit" name="changeMover" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">

View File

@@ -23,7 +23,7 @@ if ($newarray) {
@unlink('/boot/config/smart-one.cfg');
@unlink('/boot/config/smart-all.cfg');
@unlink('/boot/config/plugins/dynamix/monitor.ini');
@unlink('/var/tmp/cache_log.tmp');
foreach ($pools as $pool) @unlink("/var/tmp/$pool.log.tmp");
}
?>
<style>
@@ -36,7 +36,9 @@ function prepareNewConfig(form) {
switch (item.value) {
case 'parity': if (item.selected) form.preserveParity.disabled = false; break;
case 'data' : if (item.selected) form.preserveData.disabled = false; break;
case 'cache' : if (item.selected) form.preserveCache.disabled = false; break;
<?foreach ($pools as $pool):?>
case '<?=$pool?>': if (item.selected) form.preserve<?=ucfirst($pool)?>.disabled = false; break;
<?endforeach;?>
}
}
form.preset.disabled = true;
@@ -66,14 +68,18 @@ effect of making it ***impossible*** to rebuild an existing failed drive - you h
<form name="newConfig" method="POST" action="/update.htm" target="progressFrame" onsubmit="prepareNewConfig(this)">
<input type="hidden" name="preserveParity" value="yes" disabled>
<input type="hidden" name="preserveData" value="yes" disabled>
<input type="hidden" name="preserveCache" value="yes" disabled>
<?foreach ($pools as $pool):?>
<input type="hidden" name="preserve<?=$pool?>" value="yes" disabled>
<?endforeach;?>
<span class="indent">_(Preserve current assignments)_:</span>
<select id="s1" name="preset" multiple="multiple" style="display:none">
<option value=''>_(All)_</option>
<?=mk_option_check(0,'parity',_('Parity slots'))?>
<?=mk_option_check(0,'data',_('Data slots'))?>
<?=mk_option_check(0,'cache',_('Cache slots'))?>
<?foreach ($pools as $pool):?>
<?if ($cache[$pool]['devicesSb']) echo mk_option_check(0,$pool,ucfirst($pool).' '._('slots'))?>
<?endforeach;?>
</select>
<br>
<span class="indent"><input type="submit" class="lock" name="cmdInit" value="_(Apply)_" disabled><input type="button" class="lock" value="_(Done)_" onclick="done()"></span>

View File

@@ -16,8 +16,6 @@ Tag="share-alt-square"
?>
<?
$width = [123,300];
$cache = cache_filter($disks);
$pools = pools_filter($cache);
if ($name == "") {
/* default values when adding new share */

View File

@@ -41,7 +41,7 @@ function build_pages($pattern) {
}
function find_pages($item) {
global $docroot,$site,$var,$disks,$devs,$users,$shares,$sec,$sec_nfs,$name,$display;
global $docroot,$site,$var,$disks,$devs,$users,$shares,$sec,$sec_nfs,$name,$display,$pool_devices;
$pages = [];
foreach ($site as $page) {
if (empty($page['Menu'])) continue;

View File

@@ -31,6 +31,13 @@ $users = (array)parse_ini_file('state/users.ini',true);
$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]['devicesSb'];
// Read network settings
extract(parse_ini_file('state/network.ini',true));