All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: NeilBrown <neilb@suse.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] bloody odd logics in md_exit()
Date: Sun, 30 Sep 2018 03:00:14 +0100	[thread overview]
Message-ID: <20180930020010.GJ32577@ZenIV.linux.org.uk> (raw)
In-Reply-To: <87k1n3gb2s.fsf@notabene.neil.brown.name>

On Sun, Sep 30, 2018 at 09:04:11AM +1000, NeilBrown wrote:

> Hi Al,
>  I don't think wake_up_all() does remove anything from the queue.
>  It simply wakes up the various processes that are waiting.
>  They remain on the queue until they call remove_wait_queue(), which
>  could be delayed arbitrarily.
>  If it was delayed until after the module was unloaded and
>  "md_event_waiters" no longer existed, the unlink attempt would cause an
>  invalid memory access.
> 
>  I think your approach for simplify the code would only work if
>  md_event_waiters could be moved out of the module, or if some global
>  wait_queue could be used instead.
>  Maybe we could use bit_waitqueue(NULL,0) (rather an ugly hack).
>  Maybe we could export a general-purpose waitqueue for modules to use.
>  Maybe procfs could export something??
> 
>  I agree that we can remove md_unloading, by moving remove_proc_entry()
>  before the wakeup.  I'm not yet convinced that we can remove the wakeup
>  loop.
>  
>  Or am I missing something else here?

You are not, unfortunately; I plead a bad braino.  remove_wait_queue() will,
indeed, happen only when we get around to poll_freewait().  Bugger...
That's a problem, and I'm not at all sure that it's only md that needs to
be concerned with it.  And it's not just procfs either - debugfs users have
exact same problem if they have ->poll() in their file_operations...

  reply	other threads:[~2018-09-30  8:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29  3:33 [RFC] bloody odd logics in md_exit() Al Viro
2018-09-29 23:04 ` NeilBrown
2018-09-30  2:00   ` Al Viro [this message]
2018-09-30  2:13   ` Matthew Wilcox
2018-09-30  3:17     ` Al Viro

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=20180930020010.GJ32577@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neilb@suse.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.