btrfsmaintenance icon indicating copy to clipboard operation
btrfsmaintenance copied to clipboard

Wait AC Power

Open comio opened this issue 8 years ago • 6 comments

NOT TESTED Only for review and discussion purpose.

comio avatar Jan 30 '18 09:01 comio

@sten0, Can you review the proposed code. Can you attach output of find /sys/class/power_supply -name online?. Thanks.

luigi

comio avatar Jan 31 '18 09:01 comio

@comio No output. Linux-4.9.80 on Debian 9. /sys/class/power_supply/AC: symbolic link to ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/ACPI0003:00/power_supply/AC /sys/class/power_supply/BAT0: symbolic link to ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0

On the other hand, if [ -f /sys/class/power_supply/*/online ]; then echo 'We are online"; fi works

sten0 avatar Feb 07 '18 20:02 sten0

@stem0 @kdave

we can backport this script from OpenRC:

on_ac_power

and use this implementation if on_ac_power command is not present. This will move all /proc/blablabla logic into an external command/function.

comio avatar Feb 22 '18 11:02 comio

I'm not sure if the on_ac_power is generally available, so we'll need some fallback anyway, but systemd has /usr/lib/systemd/systemd-ac-power so we can cover most cases I think.

kdave avatar Mar 06 '18 15:03 kdave

this is the code of on_ac_power:

systemd:on_ac_power

it's almost the same.

comio avatar Mar 06 '18 15:03 comio

So the way you implement it in https://github.com/kdave/btrfsmaintenance/pull/45/commits/14c44e9d6e9ccfe6be5bcae42fd4cfa80480f35e it will just wait for AC and if it does not show up, the task continues. Is this desired from the user's POV? Eg. should we make it more configurable:

  • if AC is not up after timeout, cancel the task (eg. skip balance)
  • if AC is not up, continue anyway (eg. run scrub that's read-only and typically not that hungry as balance)

kdave avatar Mar 06 '18 15:03 kdave