unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: David Michael <fedora.dm0@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] dmd: Allow storing early logs before writing to disk
Date: Sat, 13 Sep 2014 14:16:33 +0200	[thread overview]
Message-ID: <87ha0bk95q.fsf@gnu.org> (raw)
In-Reply-To: <CAEvUa7nTh8YQNFS-3zN7OG6RzXBpaBJD5Y-AWw=+X+u+yn_pjw@mail.gmail.com> (David Michael's message of "Thu, 11 Sep 2014 22:09:14 -0400")

David Michael <fedora.dm0@gmail.com> skribis:

> On Thu, Sep 11, 2014 at 10:31 AM, Ludovic Courtès <ludo@gnu.org> wrote:
>> David Michael <fedora.dm0@gmail.com> skribis:
>>
>>> When using dmd to bring up a read-only file system, it will quit when it
>>> fails to open a log file for writing.
>>
>> Out of curiosity, are you trying to use dmd in the initrd, or maybe on
>> GNU/Hurd?
>
> I've replaced Hurd's /libexec/runsystem script with dmd; i.e., Hurd's
> own init program is launching dmd.  There are some pending patches to
> restructure the Hurd system startup, so I'll probably try to use dmd
> as the real init process once those are accepted.

Nice!

>>> This is a proof-of-concept patch that adds the option to start writing
>>> logs to a string port.  It allows having a dmdconf.scm that runs fsck,
>>> makes the disk writable, and then starts writing past and future log
>>> messages to disk with (start-logging "/var/log/dmd.log").
>>
>> That sounds useful.
>>
>>> Does anyone have any thoughts on this?  Is there a better way to handle
>>> this case?
>>
>> The problem is: when does it figure out that it can now write to the
>> file?
>
> This patch expects that dmd is explicitly told when it's safe to write
> the file.  (See reasoning/concerns below.)  A dmdconf.scm could do
> something like this on boot with it.
>
>     ;; The system was booted read-only ...
>     (system* "/sbin/fsck" "--preen" "--writable")
>     ;; Now it's writable (on success), so dump saved log lines to disk
>     (start-logging "/var/log/dmd.log")

OK.

>> The ideal thing would be:
>>
>>   1. Run ‘dmd -l foo.log’.
>>   2. If foo.log is not writable, then make ‘log-output-port’ a string
>>      port.
>
> Do you think it makes sense to define log-output-port as a string port
> at first instead of a void port?

No, because running dmd without ‘-l’ means disabling logging altogether,
hence the void port.

>>   3. When foo.log becomes writable, have ‘log-output-port’ point to it
>>      and dump previously buffered data.
>>
>> But #3 is difficult.
>>
>> Maybe instead of using a string port, we could use a string port that
>> keeps trying to open the log file?
>>
>> It would be best to use inotify (or the Hurd’s fs_notify), of course.
>
> Something like that would be a nice transparent solution for read-only
> booting, but I could see another issue arising from it later.  It's
> common to have /var or /var/log on a different volume that may not be
> mounted when the root file system's /var/log is writable.  Writing
> logs as soon as possible could miss the sysadmin's desired log volume
> (which theoretically could also happen with dmd as is).

Right, that makes sense.  I think it’s a good argument against trying to
do something too smart.

So probably the patch you propose is the best approach.

Then I would suggest a small change: instead of the magic
‘--log-file=delayed’, what about adding a new option, say,
‘--buffered-log’?  WDYT?

> I haven't done the research, but I'd imagine if other init systems
> write anything to persistent storage, it would be done after fscking
> and/or mounting all relevant entries in /etc/fstab.  It doesn't look
> like dmd is currently doing any /etc/fstab processing, so I've
> included some of that in my dmdconf.scm, and the explicit procedure
> call to start logging declares that the file systems are now in a
> usable state.  Admittedly, it might not be necessary to worry about
> mounting volumes when you have passive translators, but it may be
> cause for concern if the same functionality is used with Linux.

Yeah passive translators greatly simplify things, at the expense of
making it more difficult to track changes to the system configuration.

For the Linux-based distro we don’t use dmd in the initrd.  This is
unfortunate because that leads to some code duplication between initrd
vs. full system, but OTOH, there would be complications with having dmd
do the switch-root thing, I think.

Thanks,
Ludo’.

  reply	other threads:[~2014-09-13 12:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 23:58 [PATCH] dmd: Allow storing early logs before writing to disk David Michael
2014-09-11 14:31 ` Ludovic Courtès
2014-09-12  2:09   ` David Michael
2014-09-13 12:16     ` Ludovic Courtès [this message]
2014-09-17 21:36       ` David Michael
2014-09-19  7:57         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ha0bk95q.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=fedora.dm0@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).