From 3dfd3099ba457d5d8f8e8ab2873d02ffdaf3fdf5 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 1 Mar 2022 17:49:39 +0100 Subject: [PATCH] BTRFS balance and scrub scheduler --- plugins/dynamix/DeviceInfo.page | 162 ++++++++++++++++++++++- plugins/dynamix/include/update.btrfs.php | 29 ++++ plugins/dynamix/nchan/device_list | 2 +- plugins/dynamix/nchan/update_2 | 2 +- 4 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 plugins/dynamix/include/update.btrfs.php diff --git a/plugins/dynamix/DeviceInfo.page b/plugins/dynamix/DeviceInfo.page index 668a327a8..e6662ca7e 100644 --- a/plugins/dynamix/DeviceInfo.page +++ b/plugins/dynamix/DeviceInfo.page @@ -3,8 +3,8 @@ Title="$name _(Settings)_" Tag="hdd-o" --- +function presetBTRFS(form,job) { + var mode = form.mode.value; + form.min.disabled = mode==0; + form.day.disabled = mode==0 || mode!=3; + form.dotm.disabled = mode==0 || mode!=4; + form.hour1.disabled = mode==0; + form.hour2.disabled = mode==0; + form.day.value = form.day.disabled ? '*' : (form.day.value=='*' ? 0 : form.day.value); + form.dotm.value = form.dotm.disabled ? '*' : (form.dotm.value=='*' ? 1 : form.dotm.value); + if (mode==1) {$(job+'-hour1').hide(); $(job+'-hour2').show();} else {$(job+'-hour2').hide(); $(job+'-hour1').show();} +} +function prepareBTRFS(form,cookie,value) { + var include = ''; + var mode = form.mode.value; + form.hour.value = mode!=1 ? form.hour1.value : form.hour2.value; + form.min.value = mode!=1 ? form.min.value : 0; + form.hour1.disabled = true; + form.hour2.disabled = true; + for (var i=0,item; item=form.disk.options[i]; i++) { + if (item.selected) { + if (include.length) include += ','; + include += item.value; + item.selected = false; + } + } + item = form.disk.options[0]; + item.value = include; + item.selected = true; + $.cookie(cookie,value) +} + function prepareDeviceInfo(form) { var events = []; for (var i=0; i < ; i++) { @@ -287,9 +322,9 @@ function freeSpace(val) { } $(function() { 1):?> - var ctrl = "'>"; + var ctrl = "'>"; ctrl += ""; - ctrl += ""; + ctrl += ""; $('.tabs').append(ctrl); @@ -524,6 +559,60 @@ _(btrfs balance status)_: +
+ +
+ + + + + +_(Balance schedule)_: +: + +_(Day of the week)_: +: + +_(Day of the month)_: +: + +_(Time of the day)_: +: +: + +  +: +
_(Scrub Status)_
@@ -563,6 +652,60 @@ _(btrfs scrub status)_: +
+ +
+ + + + + +_(Scrub schedule)_: +: + +_(Day of the week)_: +: + +_(Day of the month)_: +: + +_(Time of the day)_: +: +: + +  +: +
_(Check Filesystem Status)_
@@ -789,3 +932,12 @@ _(Name)_: '> + + + + diff --git a/plugins/dynamix/include/update.btrfs.php b/plugins/dynamix/include/update.btrfs.php new file mode 100644 index 000000000..90fa8e855 --- /dev/null +++ b/plugins/dynamix/include/update.btrfs.php @@ -0,0 +1,29 @@ + +0 && substr($cmd,0,strlen($valid))==$valid) { + $hour = isset($_POST['hour']) ? $_POST['hour'] : '*'; + $min = isset($_POST['min']) ? $_POST['min'] : '*'; + $dotm = isset($_POST['dotm']) ? $_POST['dotm'] : '*'; + $day = isset($_POST['day']) ? $_POST['day'] : '*'; + $cron = "# Generated btrfs ".str_replace('_',' ',$job)." schedule:\n$min $hour $dotm * $day $cmd &> /dev/null\n\n"; +} else { + $cron = ""; +} +parse_cron_cfg('dynamix', $job, $cron); +?> diff --git a/plugins/dynamix/nchan/device_list b/plugins/dynamix/nchan/device_list index 6d121cb8e..9c019bff6 100755 --- a/plugins/dynamix/nchan/device_list +++ b/plugins/dynamix/nchan/device_list @@ -68,7 +68,7 @@ function device_info(&$disk,$online) { ($disk['type']=='Data' && $disk['status']!='DISK_NP') || ($disk['type']=='Cache' && $disk['status']!='DISK_NP') || ($disk['name']=='flash') || in_array($disk['name'],$pools) || - $disk['type']=='New' ? "$fancyname" : $fancyname; + $disk['type']=='New' ? "$fancyname" : $fancyname; if ($crypto) switch ($disk['luksState']) { case 0: if (!vfs_luks($disk['fsType'])) diff --git a/plugins/dynamix/nchan/update_2 b/plugins/dynamix/nchan/update_2 index b220c204d..e5720d918 100755 --- a/plugins/dynamix/nchan/update_2 +++ b/plugins/dynamix/nchan/update_2 @@ -139,7 +139,7 @@ function device_name(&$disk) { $name = my_disk($disk['name']); [$p1,$p2] = explode(' ',$name); $name = _($p1).($p2?" $p2":""); - return " $name"; + return " $name"; } function device_status(&$disk, &$error, &$warning) { global $var;