All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Kendall <wkendall@sgi.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 4/4] xfsdump: convert to the POSIX signal API
Date: Thu, 04 Aug 2011 07:35:04 -0500	[thread overview]
Message-ID: <4E3A91F8.3080606@sgi.com> (raw)
In-Reply-To: <20110804075331.GA8836@infradead.org>

On 08/04/2011 02:53 AM, Christoph Hellwig wrote:
> On Wed, Aug 03, 2011 at 02:28:54PM -0500, Bill Kendall wrote:
>> Here's some background explaining why things are done as they
>> are now, from my understanding of the code.
>>
>> The regular handler won't acquire a lock. The signal handler is
>> replaced because the rules are different when receiving a signal
>> while in a dialog. For instance, SIGINT normally means interrupt
>> the dump session, but in a dialog we just return a caller-supplied
>> value indicating the interrupt.
>>
>> When a dialog is required, the caller does this:
>>
>>     dlog_begin();   // grabs mlog_lock
>>     dlog_*_query(); // ends up in promptinput()
>>     dlog_end();     // releases mlog_lock
>>
>> I think the purpose of holding the lock is simply to prevent
>> other output on the terminal while waiting for a response.
>
> Ok, that makes some sense.
>
>> Any thread may issue a dialog, and it's possible that while
>> a thread is sitting in a dialog, the main thread may try to
>> log a message (e.g., progress report) and get blocked on the
>> mlog lock. At this point nobody would be able to handle signals --
>> the main thread blocks all signals except while in sigsuspend,
>> and other threads always block signals. So we unblock the
>> signals in the current thread to ensure some thread is available
>> to handle them.
>
> Unblocking the signals during the dialog, but still using the normal
> signal handler for it would solve that problem, right?

Right, with some rework of that handler. It would have to do
something like:

   case SIGINT:
       if (is_dialog_active(SIGINT))
           dlg_sigterm_received = BOOL_TRUE;
       else
           sigterm_received = BOOL_TRUE;

(The SIGINT param is needed because it's optional whether a
dialog handles a particular signal.)

Otherwise we'd race between main's use of sigterm_received and
the dialog's need to use it.

Do you prefer this over the signal handler swap?

>
> Btw, I looked over the main sighandler a bit, and it seems like most
> of it can simply go away for a pthreaded variant - there is no need
> to handle SIGCLD, and all threads have the same pid, so basically
> what is left is SIGHUP/SIGTERM/SIGINT/SIGQUIT handling, which does
> nothing but a dlog_desist in most cases and setting the sigfoo_received
> variable.

Yes, the previous patch in this series takes care of that. :)

Bill

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2011-08-04 12:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 20:40 [PATCH 0/4] xfsdump: convert to using the POSIX signal API Bill Kendall
2011-07-29 20:40 ` [PATCH 1/4] xfsdump: remove conditional OPENMASKED code Bill Kendall
2011-08-02 10:13   ` Christoph Hellwig
2011-08-02 14:07     ` Bill Kendall
2011-07-29 20:40 ` [PATCH 2/4] xfsdump: process EPIPE instead of catching SIGPIPE Bill Kendall
2011-08-02 10:15   ` Christoph Hellwig
2011-07-29 20:40 ` [PATCH 3/4] xfsdump: remove SIGCHLD handling Bill Kendall
2011-08-02 10:22   ` Christoph Hellwig
2011-08-02 14:13     ` Bill Kendall
2011-07-29 20:40 ` [PATCH 4/4] xfsdump: convert to the POSIX signal API Bill Kendall
2011-08-03 10:48   ` Christoph Hellwig
2011-08-03 10:56     ` Christoph Hellwig
2011-08-03 12:11     ` Bill Kendall
2011-08-03 12:39       ` Christoph Hellwig
2011-08-03 19:28         ` Bill Kendall
2011-08-04  7:53           ` Christoph Hellwig
2011-08-04 12:35             ` Bill Kendall [this message]
2011-08-04 12:37               ` Christoph Hellwig
2011-08-03 10:59 ` [PATCH 0/4] xfsdump: convert to using " Christoph Hellwig
2011-08-03 11:57   ` Bill Kendall
2011-08-03 12:02     ` Christoph Hellwig
2011-08-03 12:07       ` Bill Kendall

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

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

  git send-email \
    --in-reply-to=4E3A91F8.3080606@sgi.com \
    --to=wkendall@sgi.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    /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.
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.