Skip to content

Commit f068b4e

Browse files
authored
Merge pull request #2592 from SimonFair/Dedicated-Boot
feat(Boot): add dedicated boot pool support.
2 parents ce7c578 + de5e3a1 commit f068b4e

4 files changed

Lines changed: 102 additions & 59 deletions

File tree

emhttp/plugins/dynamix/DashStats.page

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,10 @@ switch ($themeHelper->getThemeName()) { // $themeHelper set in DefaultPageLayout
11721172
<?
11731173
$poolsandboot = array_merge($pools, $bootpools );
11741174
foreach ($poolsandboot as $pool):
1175+
$poolDisk = $disks[$pool] ?? [];
1176+
$poolType = strtolower((string)_var($poolDisk,'type',''));
1177+
$bootPoolMode = strtolower((string)_var($poolDisk,'bootPool','no'));
1178+
if ($poolType === 'cache' && $bootPoolMode === 'dedicated') continue;
11751179
$cache = array_filter(array_merge(cache_filter($disks)),function($disk) use ($pool){return prefix($disk['name'])==$pool;});
11761180
$boot= array_filter(array_merge(boot_filter($disks)),function($disk) use ($pool){return prefix($disk['name'])==$pool;});
11771181
$power = _var($display,'power') && in_array('nvme',array_column($cache,'transport')) ? ' / '._('Power') : '';

emhttp/plugins/dynamix/DeviceInfo.page

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $events = explode('|', $disk['smEvents'] ?? $var['smEvents'] ?? $numbers);
2525
$mode = ['Disabled','Hourly','Daily','Weekly','Monthly'];
2626
$days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
2727
$sheets = [];
28+
$isDedicatedBootPool = (_var($disk,'type') === 'Cache' && strtolower((string)_var($disk,'bootPool','no')) === 'dedicated');
2829
$i = $n = 0;
2930

3031
function hasSubpools($name)
@@ -39,6 +40,8 @@ function hasSubpools($name)
3940
return false;
4041
}
4142
$fsTypeDisabled = (_var($disk, 'fsType') == 0);
43+
$diskCompressionDisabled = false;
44+
$diskAutotrimDisabled = false;
4245
if (_var($disk,'type')== "Boot") {
4346
$fsTypeImmutable = true;
4447
$fsProfileImmutable = true;
@@ -50,6 +53,13 @@ if (_var($disk,'type')== "Boot") {
5053
$fsTypeImmutable = true;
5154
$fsProfileImmutable = !(_var($var, 'fsState') == 'Stopped' && empty(_var($disk, 'fsGroups', '1')));
5255
}
56+
if ($isDedicatedBootPool) {
57+
$fsTypeDisabled = true;
58+
$diskCompressionDisabled = true;
59+
$diskAutotrimDisabled = true;
60+
$fsTypeImmutable = true;
61+
$fsProfileImmutable = true;
62+
}
5363

5464
foreach ($disks as $sheet) {
5565
if (_var($sheet, 'type') == "Flash" || _var($sheet, 'color') == "grey-off" || empty($sheet['name'])) {
@@ -389,6 +399,9 @@ function selectDiskFsProfileZFS(slots,init,subpool) {
389399
selectDiskFsWidthZFS(slots,false);
390400
});
391401
}
402+
var isDedicatedBootPool = <?= $isDedicatedBootPool ? 'true' : 'false' ?>;
403+
var fsTypeDisabledByServer = <?= $fsTypeDisabled ? 'true' : 'false' ?>;
404+
var fsProfileDisabledByServer = <?= $fsProfileImmutable ? 'true' : 'false' ?>;
392405
/* called upon page load (init==true) and when user changes file system type (init==false) */
393406
function selectDiskFsProfile(init) {
394407
var t = init ? null : 'slow';
@@ -407,6 +420,10 @@ function selectDiskFsProfile(init) {
407420
fsType = 'zfs';
408421
}
409422

423+
$('#diskFsType').prop('disabled', fsTypeDisabledByServer || isDedicatedBootPool);
424+
$('#diskFsProfile').prop('disabled', fsProfileDisabledByServer || isDedicatedBootPool);
425+
$('#diskFsWidth').prop('disabled', fsProfileDisabledByServer || isDedicatedBootPool);
426+
410427
if (slots == 1 || fsType == 'auto') {
411428
$('#profile').hide(t);
412429
} else {
@@ -440,24 +457,27 @@ function selectDiskFsProfile(init) {
440457
selectDiskFsProfileEXFAT();
441458
}
442459

443-
if (subpool != '' || fsType == 'auto' || fsType.indexOf('xfs') != -1 || fsType.indexOf('ext') != -1 || fsType.indexOf('ntfs') != -1 || fsType.indexOf('exfat') != -1) {
460+
var compressionDisabled = (subpool != '' || fsType == 'auto' || fsType.indexOf('xfs') != -1 || fsType.indexOf('ext') != -1 || fsType.indexOf('ntfs') != -1 || fsType.indexOf('exfat') != -1);
461+
if (compressionDisabled) {
444462
$('#compression').hide(t);
445-
$('#diskCompression').prop('disabled',true);
463+
$('#diskCompression').prop('disabled', compressionDisabled || isDedicatedBootPool);
446464
} else {
447465
$('#compression').show(t);
448-
$('#diskCompression').prop('disabled',(fsStatus == 'Mounted'));
466+
$('#diskCompression').prop('disabled', (fsStatus == 'Mounted') || isDedicatedBootPool);
449467
}
450468

451469
<?if (diskType('Data') || isSubpool($name)):?>
452470
$('#autotrim').hide(t);
453-
$('#diskAutotrim').prop('disabled',true);
471+
var autotrimDisabled = true;
472+
$('#diskAutotrim').prop('disabled', autotrimDisabled || isDedicatedBootPool);
454473
<?else:?>
455474
if (fsType == 'auto') {
456475
$('#autotrim').hide(t);
457-
$('#diskAutotrim').prop('disabled',true);
476+
var autotrimDisabled = true;
477+
$('#diskAutotrim').prop('disabled', autotrimDisabled || isDedicatedBootPool);
458478
} else {
459479
$('#autotrim').show(t);
460-
$('#diskAutotrim').prop('disabled',(fsStatus == 'Mounted'));
480+
$('#diskAutotrim').prop('disabled', (fsStatus == 'Mounted') || isDedicatedBootPool);
461481
}
462482
<?endif;?>
463483
}
@@ -945,7 +965,7 @@ _(Allocation profile)_:
945965
</div>
946966
<div markdown="1" id="compression">
947967
_(Compression)_:
948-
: <select id="diskCompression" name="diskCompression.<?=_var($disk, 'idx', 0)?>">
968+
: <select id="diskCompression" name="diskCompression.<?=_var($disk, 'idx', 0)?>" <?=disabled_if($diskCompressionDisabled)?>>
949969
<?=mk_option(_var($disk, 'compression'), "off", _('Off'))?>
950970
<?=mk_option(_var($disk, 'compression'), "on", _('On'))?>
951971
</select>
@@ -954,7 +974,7 @@ _(Compression)_:
954974
</div>
955975
<div markdown="1" id="autotrim">
956976
_(Autotrim)_:
957-
: <select id="diskAutotrim" name="diskAutotrim.<?=_var($disk, 'idx', 0)?>">
977+
: <select id="diskAutotrim" name="diskAutotrim.<?=_var($disk, 'idx', 0)?>" <?=disabled_if($diskAutotrimDisabled)?>>
958978
<?=mk_option(_var($disk, 'autotrim'), "on", _('On'))?>
959979
<?=mk_option(_var($disk, 'autotrim'), "off", _('Off'))?>
960980
</select>
@@ -1011,7 +1031,7 @@ _(Critical disk utilization threshold)_ (%):
10111031
<?endif;?>
10121032
<?if (isPool($name) && isSubpool($name)===false):?>
10131033
<?if (_var($var,'fsState')=="Stopped" || (_var($var,'fsState')=="Started" && _var($var,'startMode')!="Normal")): $erasable=true; endif;?>
1014-
<input type="button" id="eraseButton" value="_(Erase Pool)_" onclick="eraseDisk()"<?=$erasable ? '' : ' disabled'?>>
1034+
<input type="button" id="eraseButton" value="_(Erase Pool)_" onclick="eraseDisk()"<?=($erasable && !$isDedicatedBootPool) ? '' : ' disabled'?>>
10151035
<?if (_var($var,'fsState')=="Stopped" && !$poolBootSizeLocked): $removeable=true; endif;?>
10161036
<input type="button" id="removeButton" value="_(Remove Pool)_" onclick="removePool()"<?=$removeable ? '' : ' disabled'?>>
10171037
<?endif;?>

emhttp/plugins/dynamix/nchan/device_list

Lines changed: 66 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ function get_pool_data_metrics(?array $poolDisk, string $poolName='', array $dis
306306
];
307307
}
308308

309+
function resolve_boot_pool_mode(string $poolName, array $allDisks=[]): string
310+
{
311+
$firstPoolDisk = ($poolName !== '' && !empty($allDisks))
312+
? get_first_pool_disk_in_disks($poolName, $allDisks)
313+
: null;
314+
$mode = strtolower(trim((string)_var($firstPoolDisk,'bootPool','')));
315+
if (!in_array($mode,['no','yes','dedicated'],true)) $mode = 'no';
316+
return $mode;
317+
}
318+
309319
function pool_status_html(string $poolName, array $poolstatusData, array $disks): string
310320
{
311321
if (!$poolName || empty($poolstatusData['pools'][$poolName])) return '';
@@ -328,7 +338,7 @@ function pool_status_html(string $poolName, array $poolstatusData, array $disks)
328338
return " <a href='$deviceUrl' title='"._('View pool details')."'>($displayText)</a>";
329339
}
330340

331-
function pool_function_row(string $label, ?array $poolDisk, ?array $firstMember, array $metrics, string $poolName='', array $poolstatusData=[], bool $showSummary=false, array $fsOverride=[], bool $showPoolStatusInTitle=true, string $statusPoolName='', string $summaryDisplayName='', bool $summaryShowView=true): string
341+
function pool_function_row(string $label, ?array $poolDisk, ?array $firstMember, array $metrics, string $poolName='', array $poolstatusData=[], bool $showSummary=false, array $fsOverride=[], bool $showPoolStatusInTitle=true, string $statusPoolName='', string $summaryDisplayName='', bool $summaryShowView=true, string $summaryRowId=''): string
332342
{
333343
global $disks;
334344
$disk = $poolDisk ?: ($firstMember ?? []);
@@ -359,7 +369,8 @@ function pool_function_row(string $label, ?array $poolDisk, ?array $firstMember,
359369
$title .= pool_status_html($statusPool, $poolstatusData, $disks);
360370
}
361371
$echo = [];
362-
$rowId = ($showSummary && $poolName !== '') ? " id='pool_".htmlspecialchars($poolName, ENT_QUOTES)."'" : '';
372+
$anchorId = $summaryRowId !== '' ? $summaryRowId : ($poolName !== '' ? 'pool_'.$poolName : '');
373+
$rowId = ($showSummary && $anchorId !== '') ? " id='".htmlspecialchars($anchorId, ENT_QUOTES)."'" : '';
363374
$echo[] = "<tr class='pool_header'{$rowId}>";
364375
if ($showSummary && $poolName !== '') {
365376
$echo[] = "<td>".device_info($disk,true,$poolName,$poolstatusData,[
@@ -1051,13 +1062,9 @@ while (true) {
10511062
if ($poolIndex === false && $poolName !== '') {
10521063
$poolIndex = array_search(prefix($poolName), $pools, true);
10531064
}
1054-
if ($poolIndex !== false) {
1055-
$poolAnchor = "/Main#pool_device".$poolIndex;
1056-
} else {
1057-
$poolAnchor = $poolName !== '' ? "/Main#pool_".$poolName : '';
1058-
}
1065+
$poolAnchor = $poolName !== '' ? "/Main#pool_boot_".$poolName : '';
10591066
$poolLink = $poolAnchor !== ''
1060-
? "<a href=\"".htmlspecialchars($poolAnchor, ENT_QUOTES)."\">"._($poolLabel,3)."</a>"
1067+
? "<a href=\"".htmlspecialchars($poolAnchor, ENT_QUOTES)."\" title=\"".htmlspecialchars($poolLabel, ENT_QUOTES)."\"><i class='icon-disk icon'></i></a>"
10611068
: '';
10621069
$desc = $poolLink !== ''
10631070
? sprintf(_('%s -> %s'), _('Boot device'), $poolLink)
@@ -1101,6 +1108,7 @@ while (true) {
11011108
$off = false;
11021109
$poolDisk = $Cache[$pool] ?? null;
11031110
$firstMember = get_pool_first_member($pool, $Cache, $devicePools);
1111+
$bootPoolMode = resolve_boot_pool_mode($root, $disks);
11041112
$bootDisk = find_boot_disk_for_pool($pool, $Boot, $Cache);
11051113
$bootPoolName = prefix(_var($bootDisk,'name',''));
11061114
$bootMetrics = get_boot_pool_metrics($Boot, $bootPoolName, $bootDisk);
@@ -1114,13 +1122,13 @@ while (true) {
11141122
}
11151123
$poolDeviceUrl = "/Main/Device?name=".urlencode($pool);
11161124
$poolLink = "<a href=\"$poolDeviceUrl\">"._($poolLabel,3)."</a>";
1117-
$summaryName = $poolLink;
1125+
$dataSummaryName = $poolLink;
11181126
if (!empty($bootDisk)) {
11191127
$bootPoolName = prefix(_var($bootDisk,'name',''));
1120-
$bootLabel = _("Internal Boot");
1128+
$bootLabel = _($bootPoolMode === 'dedicated' ? 'Internal Boot(Dedicated)' : 'Internal Boot');
11211129
$bootDeviceUrl = "/Main/Boot?name=".urlencode($bootPoolName);
11221130
$bootLink = "<a href=\"$bootDeviceUrl\">"._($bootLabel,3)."</a>";
1123-
$summaryName = $poolLink." / ".$bootLink;
1131+
$bootSummaryName = $bootLink;
11241132
$bootFsInfo = get_boot_pool_fs_info($Boot, $bootPoolName);
11251133
$bootFsType = _var($bootDisk,'fsType','') ?: _var($bootFsInfo,'fsType','');
11261134
$bootFsStatus = _var($bootDisk,'fsStatus','') ?: _var($bootFsInfo,'fsStatus','');
@@ -1143,27 +1151,30 @@ while (true) {
11431151
],
11441152
true,
11451153
$bootPoolName,
1146-
$summaryName,
1147-
false
1154+
$bootSummaryName,
1155+
false,
1156+
'pool_boot_'.$pool
11481157
);
11491158
if ($bootRow !== '') $echo[$a][] = $bootRow;
11501159
}
1151-
$dataLabel = isSubpool($pool) ? _('ZFS subpool') : _('Data Partition');
1152-
$dataRow = pool_function_row(
1153-
'<i class="fa fa-bullseye title"></i> '.$dataLabel,
1154-
$poolDisk,
1155-
$firstMember,
1156-
$dataMetrics,
1157-
$pool,
1158-
$poolstatus,
1159-
empty($bootDisk),
1160-
[],
1161-
true,
1162-
'',
1163-
empty($bootDisk) ? $summaryName : '',
1164-
false
1165-
);
1166-
if ($dataRow !== '') $echo[$a][] = $dataRow;
1160+
if ($bootPoolMode !== 'dedicated') {
1161+
$dataLabel = isSubpool($pool) ? _('ZFS subpool') : _('Data Partition');
1162+
$dataRow = pool_function_row(
1163+
'<i class="fa fa-bullseye title"></i> '.$dataLabel,
1164+
$poolDisk,
1165+
$firstMember,
1166+
$dataMetrics,
1167+
$pool,
1168+
$poolstatus,
1169+
empty($bootDisk),
1170+
[],
1171+
true,
1172+
'',
1173+
$dataSummaryName,
1174+
false
1175+
);
1176+
if ($dataRow !== '') $echo[$a][] = $dataRow;
1177+
}
11671178
$memberIndex = 1;
11681179
foreach ($Cache as $disk) if (prefix(_var($disk,'name'))==$pool) {
11691180
$memberDeviceUrl = "/Main/Device?name=".urlencode(_var($disk,'name',$pool));
@@ -1232,13 +1243,14 @@ while (true) {
12321243
}
12331244
$poolDisk = $Cache[$pool] ?? null;
12341245
$firstMember = get_pool_first_member($pool, $Cache, $devicePools);
1246+
$bootPoolMode = resolve_boot_pool_mode($root, $disks);
12351247
$bootDisk = find_boot_disk_for_pool($pool, $Boot, $Cache);
12361248
$bootPoolName = prefix(_var($bootDisk,'name',''));
12371249
$bootMetrics = get_boot_pool_metrics($Boot, $bootPoolName, $bootDisk);
12381250
$dataMetrics = get_pool_data_metrics($poolDisk, $pool, $disks);
12391251
if (!empty($bootDisk)) {
12401252
$bootPoolName = prefix(_var($bootDisk,'name',''));
1241-
$bootLabel = _("Internal Boot");
1253+
$bootLabel = _($bootPoolMode === 'dedicated' ? 'Internal Boot(Dedicated)' : 'Internal Boot');
12421254
$bootDeviceUrl = "/Main/Boot?name=".urlencode($bootPoolName);
12431255
$bootDir = _var($bootDisk,'fsMountpoint','/boot');
12441256
$bootBrowseUrl = $bootDir !== '' ? "/Main/Browse?dir=".htmlspecialchars($bootDir) : $bootDeviceUrl;
@@ -1255,7 +1267,8 @@ while (true) {
12551267
: "<a class='view' href=\"$poolBrowseUrl\"><i class=\"icon-u-tab\" title=\""._('Browse')." $poolDir\"></i></a>";
12561268
$poolLink = "<a href=\"$poolDeviceUrl\">"._($poolLabel,3)."</a>";
12571269
$flashWarn = flash_smb_warning_html(_var($bootDisk,'name',''));
1258-
$summaryName = $poolIcon.$poolLink." / ".$bootIcon.$bootLink.$flashWarn;
1270+
$bootSummaryName = $bootIcon.$bootLink.$flashWarn;
1271+
$dataSummaryName = $poolLink;
12591272
$bootFsInfo = get_boot_pool_fs_info($Boot, $bootPoolName);
12601273
$bootFsType = _var($bootDisk,'fsType','') ?: _var($bootFsInfo,'fsType','');
12611274
$bootFsStatus = _var($bootDisk,'fsStatus','') ?: _var($bootFsInfo,'fsStatus','');
@@ -1278,33 +1291,36 @@ while (true) {
12781291
],
12791292
true,
12801293
$bootPoolName,
1281-
$summaryName,
1282-
false
1294+
$bootSummaryName,
1295+
false,
1296+
'pool_boot_'.$pool
12831297
);
12841298
if ($bootRow !== '') $echo[$a][] = $bootRow;
12851299
}
12861300
if (empty($bootDisk)) {
12871301
$poolLabel = ucfirst($pool);
12881302
$poolDeviceUrl = "/Main/Device?name=".urlencode($pool);
12891303
$poolLink = "<a href=\"$poolDeviceUrl\">"._($poolLabel,3)."</a>";
1290-
$summaryName = $poolLink;
1304+
$dataSummaryName = $poolLink;
1305+
}
1306+
if ($bootPoolMode !== 'dedicated') {
1307+
$dataLabel = isSubpool($pool) ? _('ZFS subpool') : _('Data Partition');
1308+
$dataRow = pool_function_row(
1309+
'<i class="fa fa-bullseye title"></i> '.$dataLabel,
1310+
$poolDisk,
1311+
$firstMember,
1312+
$dataMetrics,
1313+
$pool,
1314+
$poolstatus,
1315+
true,
1316+
[],
1317+
true,
1318+
'',
1319+
$dataSummaryName,
1320+
true
1321+
);
1322+
if ($dataRow !== '') $echo[$a][] = $dataRow;
12911323
}
1292-
$dataLabel = isSubpool($pool) ? _('ZFS subpool') : _('Data Partition');
1293-
$dataRow = pool_function_row(
1294-
'<i class="fa fa-bullseye title"></i> '.$dataLabel,
1295-
$poolDisk,
1296-
$firstMember,
1297-
$dataMetrics,
1298-
$pool,
1299-
$poolstatus,
1300-
empty($bootDisk),
1301-
[],
1302-
true,
1303-
'',
1304-
empty($bootDisk) ? $summaryName : '',
1305-
true
1306-
);
1307-
if ($dataRow !== '') $echo[$a][] = $dataRow;
13081324
$memberIndex = 1;
13091325
foreach ($Cache as $disk) if (prefix(_var($disk,'name'))==$pool) {
13101326
$memberDeviceUrl = "/Main/Device?name=".urlencode(_var($disk,'name',$pool));

emhttp/plugins/dynamix/nchan/update_2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ while (true) {
374374

375375

376376
foreach (array_merge(pools_filter($disks),flash_filter($disks)) as $pool) {
377+
$poolTypeRaw = strtolower((string)_var($disks[$pool],'type',''));
378+
$bootPoolMode = strtolower((string)_var($disks[$pool],'bootPool','no'));
379+
if ($poolTypeRaw === 'cache' && $bootPoolMode === 'dedicated') continue;
377380
if (empty($disks[$pool]['devices'])) continue;
378381
if (in_array(_var($disks[$pool],'fsType'), ['zfs','btrfs','luks:zfs','luks:btrfs']) && !empty($poolstatus['pools'][$pool])) {
379382
$status = $poolstatus['pools'][$pool]['overall_status'] ?? 'UNKNOWN';

0 commit comments

Comments
 (0)