All of lore.kernel.org
 help / color / mirror / Atom feed
* block devices loosing state after resume: trigger udev rules to re-apply settings
@ 2015-02-28  8:30 Chris
  2015-02-28  8:38 ` Bug#725284: Bug#779412: " Michael Biebl
  0 siblings, 1 reply; 3+ messages in thread
From: Chris @ 2015-02-28  8:30 UTC (permalink / raw)
  To: 779412; +Cc: 725284, linux-raid, smartmontools-support

(http://bugs.debian.org/779412 explanation)

There is a general problem with non-permanent block devices settings
(hard disks, optical disks, usb storage, ...), that are not restored 
when resuming from suspend (instead using factory defaults and 
loosing all pre-suspend settings).

And as long as the ata/scsi command set drivers can not save and
restore every state register a device may have (impossible?),
systemd may ship a viable workaround for this:

A systemd unit file could trigger an udev change action upon resume for
block devices. This way the same udev rules that set up the devices when
they are first plugged, will re-apply their settings after resume.

Providing this centrally with the systemd package could avoid that 
multiple packages ship their own files, resulting in multiple change 
events triggerd on each resume.

Examples for very important (non-permanent) settings are with
hdparm (i.e. the important -B hard disk wear settings)
https://bugs.debian.org/725284
smartctl/mdadm/lvm/btrfs/zfs/... (i.e. set error recovery timeouts to
prevent controller resets and data loss)
http://sourceforge.net/p/smartmontools/mailman/message/33501936/




A draft for such a central systemd unit file:

[Unit]
Description=Trigger all block device udev rules on resume, to re-apply all non-permanent device settings (e.g. smartctl and hdparm rules).
After=suspend.target After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/sbin/udevadm trigger --action=change --subsystem-match=block

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Bug#725284: Bug#779412: block devices loosing state after resume: trigger udev rules to re-apply settings
  2015-02-28  8:30 block devices loosing state after resume: trigger udev rules to re-apply settings Chris
@ 2015-02-28  8:38 ` Michael Biebl
  2015-02-28  9:47   ` Chris
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Biebl @ 2015-02-28  8:38 UTC (permalink / raw)
  To: Chris, 779412; +Cc: 725284, linux-raid, smartmontools-support

[-- Attachment #1: Type: text/plain, Size: 1693 bytes --]

Am 28.02.2015 um 09:30 schrieb Chris:
> (http://bugs.debian.org/779412 explanation)
> 
> There is a general problem with non-permanent block devices settings
> (hard disks, optical disks, usb storage, ...), that are not restored 
> when resuming from suspend (instead using factory defaults and 
> loosing all pre-suspend settings).
> 
> And as long as the ata/scsi command set drivers can not save and
> restore every state register a device may have (impossible?),
> systemd may ship a viable workaround for this:
> 
> A systemd unit file could trigger an udev change action upon resume for
> block devices. This way the same udev rules that set up the devices when
> they are first plugged, will re-apply their settings after resume.
> 
> Providing this centrally with the systemd package could avoid that 
> multiple packages ship their own files, resulting in multiple change 
> events triggerd on each resume.
> 
> Examples for very important (non-permanent) settings are with
> hdparm (i.e. the important -B hard disk wear settings)
> https://bugs.debian.org/725284
> smartctl/mdadm/lvm/btrfs/zfs/... (i.e. set error recovery timeouts to
> prevent controller resets and data loss)
> http://sourceforge.net/p/smartmontools/mailman/message/33501936/
> 

I don't think working around this in udev/systemd is a good idea.
After all, most of those custom settings aren't applied via udev rules
anyway. This should be fixed in the kernel properly (or the individual
services) and not be papered over in systemd.

Marco, what do you think?

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug#779412: block devices loosing state after resume: trigger udev rules to re-apply settings
  2015-02-28  8:38 ` Bug#725284: Bug#779412: " Michael Biebl
@ 2015-02-28  9:47   ` Chris
  0 siblings, 0 replies; 3+ messages in thread
From: Chris @ 2015-02-28  9:47 UTC (permalink / raw)
  To: Michael Biebl; +Cc: linux-raid, 725284, smartmontools-support, 779412

Am Sat, 28 Feb 2015 09:38:27 +0100
schrieb Michael Biebl <biebl@debian.org>:

> I don't think working around this in udev/systemd is a good idea.

Idealy and in the long run, the kernel drivers should keep state, yes.
But until then, better not to make releases with default configurations
that deliver serious problems (excessive hardware wear, data loss) to
the users. 

I believe before things stadardized around systemd and udev, packages
like hdparm, laptop-mode-tools, pm-utils, acpi-support,
gnome-power-manager, and more, all tried to work around problems with
block devices loosing state. Unfortunately, accumulating a large mess
and interferences resuling in releases with many bugs in this regard.

Now the situation can improve a lot, if we can say packages are safe if
they use udev rules to initialize devices. (As the kernel keeps
state, or systemd centrally triggers a udev change event where this is
not (yet) the case.)

> most of those custom settings aren't applied via udev rules
> anyway.

Which settings were you refering to?
With current versions hdparm, mdadm, etc. all seem to ship udev rules.
And that seems to be the proper way to configure the standard
hot-pluggable systems of today. (leaving aside embedded, non-systemd,
non udev systems)



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-28  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-28  8:30 block devices loosing state after resume: trigger udev rules to re-apply settings Chris
2015-02-28  8:38 ` Bug#725284: Bug#779412: " Michael Biebl
2015-02-28  9:47   ` Chris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.