Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Feb 1998 10:20:27 -0500 (EST)
From:      "Bruce M. Walter" <walter@fortean.com>
To:        John Fieber <jfieber@indiana.edu>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Powering off the system/UPS 
Message-ID:  <Pine.BSF.3.95q.980206095913.22500A-100000@callisto.fortean.com>
In-Reply-To: <Pine.BSF.3.96.980206094636.9421H-100000@fallout.campusview.indiana.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
> > It's necessary to have kernel support because the powerdown procedure
> > should only be run after all disk syncing/buffer flushing etc...  The UPS
> > support code doesn't specifically need to be included,  but another
> > at_shutdown queue which gets called after SHUTDOWN_POSTSYNC or the
> > implementation of ordered/prioritized shutdown queues would allow for a
> > callout function to do the 'Right Thing.'
> 
> And halt(8) or shutdown(8) are incapable of doing the Right
> Thing?  I'm still failing to see the point.

Yes,  shutdown(8) actually calls halt(8).  halt(8) kills init (killing
system processes) and eventually calls the reboot syscall.  reboot(2)
calls the at_shutdown SHUTDOWN_PRESYNC list of callout methods, syncs the
disks and then calls the SHUTDOWN_POSTSYNC list of callout methods.  Then
if reboot was called with the RB_POWEROFF flag set, it calls
cpu_power_off() which is an empty routine unless you've compiled in APM
support in which case it calls apm_power_off().

The closest thing to a kernel callout which could call a UPS inverter
poweroff routine is at_shutdown/SHUTDOWN_POSTSYNC but some drivers (the
DPT driver for sure and maybe others) use this queue to flush unwritten
data from their cache to disk *AFTER* the final FS sync.  Since that
callout list is not ordered, there's no way to insure the power wouldn't
be cut after that flush has been performed. 

I've been hashing this out with Mike Smith, and he feels that

a) the at_shutdown queues should be ordered to insure their being called
in the right order -and-

b) another callout queue should be established, like
'SHUTDOWN_POSTPOSTSYNCREALLYIAMSHUTTINGDOWNNOW' ;) which would be called
after SHUTDOWN_POSTSYNC.  APM and whatever else that needs a powerdown
would be responsible for putting callouts on that list.

My only trepidation with this scenario is that the priorities are compiled
into the kernel and are not guaranteed to be correct because they are
specified by the people writing the drivers.

- Bruce

========================================================================
|| Bruce M. Walter                    || 107 Timber Hollow Court #335 ||
|| Senior Network Consultant          || Chapel Hill, NC  27514       ||
|| Fortean Technologies, Inc.         || Tel: 919-967-4766            ||
|| Information Technology Consultants || Fax: 919-967-4395            ||  
========================================================================
||       BSD Unix -- It's not just a job, it's a way of life!         ||
========================================================================




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.980206095913.22500A-100000>