All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: David Rientjes <rientjes@google.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: autofs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Matthew Wilcox <mawilcox@microsoft.com>
Subject: Re: [PATCH] autofs4: Use wait_event_killable
Date: Tue, 20 Mar 2018 10:42:34 +0800	[thread overview]
Message-ID: <daecdffe-b768-9c69-8609-b899ddde720c@themaw.net> (raw)
In-Reply-To: <alpine.DEB.2.20.1803191218210.114201@chino.kir.corp.google.com>

On 20/03/18 03:25, David Rientjes wrote:
> On Mon, 19 Mar 2018, Matthew Wilcox wrote:
> 
>> diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
>> index a0c57c37fa21..c160e9b3aa0f 100644
>> --- a/fs/autofs4/waitq.c
>> +++ b/fs/autofs4/waitq.c
>> @@ -19,9 +19,6 @@
>>   */
>>  static autofs_wqt_t autofs4_next_wait_queue = 1;
>>  
>> -/* These are the signals we allow interrupting a pending mount */
>> -#define SHUTDOWN_SIGS	(sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT))
>> -
>>  void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
>>  {
>>  	struct autofs_wait_queue *wq, *nwq;
>> @@ -486,29 +483,7 @@ int autofs4_wait(struct autofs_sb_info *sbi,
>>  	 * wq->name.name is NULL iff the lock is already released
>>  	 * or the mount has been made catatonic.
>>  	 */
>> -	if (wq->name.name) {
>> -		/* Block all but "shutdown" signals while waiting */
>> -		unsigned long shutdown_sigs_mask;
>> -		unsigned long irqflags;
>> -		sigset_t oldset;
>> -
>> -		spin_lock_irqsave(&current->sighand->siglock, irqflags);
>> -		oldset = current->blocked;
>> -		shutdown_sigs_mask = SHUTDOWN_SIGS & ~oldset.sig[0];
>> -		siginitsetinv(&current->blocked, shutdown_sigs_mask);
>> -		recalc_sigpending();
>> -		spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
>> -
>> -		wait_event_interruptible(wq->queue, wq->name.name == NULL);
>> -
>> -		spin_lock_irqsave(&current->sighand->siglock, irqflags);
>> -		current->blocked = oldset;
>> -		recalc_sigpending();
>> -		spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
>> -	} else {
>> -		pr_debug("skipped sleeping\n");
>> -	}
>> -
>> +	wait_event_killable(wq->queue, wq->name.name == NULL);
>>  	status = wq->status;
>>  
>>  	/*
> 
> I understand converting the wait_event_interruptible() to 
> wait_event_killable(), but why was the above wait_event_interruptible() 
> only called when wq->name.name != NULL?  

The code pre-dates my involvement in autofs too.

I always thought it was because wq->name.name can become NULL before
the wait is reached. Such as if the user space daemon manages to invoke
autofs4_wait_release() before the wait call.

And if the autofs mount is made catatonic before the wait is reached
wq->name.name will be set to NULL and wake up called for each waiter
so that doesn't seem to require the if conditional either.

Both of these cases to fit with what Matthew has already said and I
can't think of any others.

There may have been other reasons at some point, a lot has changed
over (a long) time.

Ian

  parent reply	other threads:[~2018-03-20  2:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 19:16 Matthew Wilcox
2018-03-19 19:25 ` David Rientjes
2018-03-19 19:30   ` Matthew Wilcox
2018-03-20  2:42   ` Ian Kent [this message]
2018-03-20  1:58 ` Ian Kent
2018-03-20  3:12   ` Matthew Wilcox

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=daecdffe-b768-9c69-8609-b899ddde720c@themaw.net \
    --to=raven@themaw.net \
    --cc=autofs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mawilcox@microsoft.com \
    --cc=rientjes@google.com \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH] autofs4: Use wait_event_killable' \
    /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

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.