public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Takashi Sato <t-sato@yk.jp.nec.com>,
	linux-fsdevel@vger.kernel.org, dm-devel@redhat.com,
	viro@ZenIV.linux.org.uk, linux-ext4@vger.kernel.org,
	xfs@oss.sgi.com, hch@infradead.org, axboe@kernel.dk,
	mtk.manpages@googlemail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] Add timeout feature
Date: Sun, 24 Aug 2008 21:03:57 +0400	[thread overview]
Message-ID: <20080824170357.GC3792@tv-sign.ru> (raw)
In-Reply-To: <20080821132006.9949101c.akpm@linux-foundation.org>

On 08/21, Andrew Morton wrote:
>
> On Mon, 18 Aug 2008 21:28:56 +0900
> Takashi Sato <t-sato@yk.jp.nec.com> wrote:
>
> > +void del_freeze_timeout(struct block_device *bdev)
> > +{
> > +	/*
> > +	 * It's possible that the delayed work task (freeze_timeout()) calls
> > +	 * del_freeze_timeout().  If the delayed work task calls
> > +	 * cancel_delayed_work_sync((), the deadlock will occur.
> > +	 * So we need this check (delayed_work_pending()).
> > +	 */
> > +	if (delayed_work_pending(&bdev->bd_freeze_timeout))
> > +		cancel_delayed_work_sync(&bdev->bd_freeze_timeout);
> > +}

I don't understand this patch, but the code above looks strange to me...

Let's suppose del_freeze_timeout() is called by ioctl_thaw()->thaw_bdev().
Now,

	IF delayed_work_pending() == T

		we can deadlock if the timer expires before
		cancel_delayed_work_sync() cancels it?
		in that case we are going to wait for this work,
		but freeze_timeout()->thaw_bdev() will block
		on ->bd_freeze_sem, no?

	ELSE

		we don't really flush the work, it is possible
		the timer has already expired and the work
		is pending. It will run later.

Perhaps this all is correct, but in that case, why can't we just do

	void del_freeze_timeout(struct block_device *bdev)
	{
		cancel_delayed_work(&bdev->bd_freeze_timeout);
	}

?

> Perhaps cancel_delayed_work_sync() shouldn't hang up if called from the
> work handler?

This is trivial,

	--- kernel/workqueue.c
	+++ kernel/workqueue.c
	@@ -516,6 +516,9 @@ static void wait_on_cpu_work(struct cpu_
		struct wq_barrier barr;
		int running = 0;
	 
	+	if (cwq->thread == current)
	+		return;
	+
		spin_lock_irq(&cwq->lock);
		if (unlikely(cwq->current_work == work)) {
			insert_wq_barrier(cwq, &barr, cwq->worklist.next);

but do we really need this?

We have a similar hack in flush_cpu_workqueue(), and we are going
to kill it once we fix the callers.

I dunno.

Oleg.

  parent reply	other threads:[~2008-08-24 16:58 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 12:28 [PATCH 3/3] Add timeout feature Takashi Sato
2008-08-21 20:20 ` Andrew Morton
2008-08-22 18:16   ` Christoph Hellwig
2008-08-24 17:03   ` Oleg Nesterov [this message]
2008-08-29  9:39   ` Takashi Sato
  -- strict thread matches above, loose matches on Subject: below --
2008-09-08 11:53 Takashi Sato
2008-09-08 17:11 ` Christoph Hellwig
2008-09-25 21:06   ` Ric Wheeler
2008-09-26  8:52     ` Takashi Sato
2008-09-26 10:58       ` Ric Wheeler
2008-09-29 11:11         ` Takashi Sato
2008-09-26 12:35       ` Valdis.Kletnieks
2008-09-29 14:13       ` Christoph Hellwig
2008-09-29 14:36         ` Eric Sandeen
2008-09-29 14:37           ` Christoph Hellwig
2008-09-29 14:45             ` Eric Sandeen
2008-09-29 22:08               ` jim owens
2008-10-05 10:00               ` Pavel Machek
2008-10-09 10:12               ` Takashi Sato
2008-10-09 10:18                 ` Christoph Hellwig
2008-07-22  9:36 Takashi Sato
2008-06-30 12:24 Takashi Sato
2008-07-01  8:10 ` Christoph Hellwig
2008-07-07 11:07   ` Pavel Machek
2008-07-08 23:10     ` Dave Chinner
2008-07-08 23:20       ` Pavel Machek
2008-07-09  0:52         ` Dave Chinner
2008-07-09  1:09           ` Theodore Tso
2008-07-09  4:21             ` Brad Boyer
2008-07-09  6:13             ` Miklos Szeredi
2008-07-09  6:16               ` Christoph Hellwig
2008-07-09  6:22                 ` Miklos Szeredi
2008-07-09  6:41                   ` Arjan van de Ven
2008-07-09  6:48                     ` Miklos Szeredi
2008-07-09  6:55                       ` Arjan van de Ven
2008-07-09  7:08                         ` Miklos Szeredi
2008-07-09 20:48                           ` Pavel Machek
2008-07-09  7:13                         ` Dave Chinner
2008-07-09 11:09                           ` Theodore Tso
2008-07-09 11:49                             ` Dave Chinner
2008-07-09 12:24                               ` Theodore Tso
2008-07-09 12:59                                 ` Olaf Frączyk
2008-07-09 13:57                                   ` Arjan van de Ven
2008-07-09 13:55                               ` Arjan van de Ven
2008-07-09 13:58                               ` jim owens
2008-07-09 14:13                                 ` jim owens
     [not found]                                 ` <20080713120602.GC7517@elf.ucw.cz>
2008-07-13 17:15                                   ` jim owens
2008-07-14  6:36                                     ` Pavel Machek
2008-07-14 13:17                                       ` jim owens
2008-07-14 13:12                                 ` Takashi Sato
2008-07-14 14:04                                   ` jim owens
2008-07-09 13:53                           ` Arjan van de Ven
2008-07-09  6:59                     ` Dave Chinner
2008-07-09  7:13                       ` Miklos Szeredi
2008-07-09  7:33                         ` Dave Chinner
2008-07-09  8:11                           ` Miklos Szeredi
2008-07-09 11:15                             ` Dave Chinner
2008-07-09 20:44           ` Pavel Machek
2008-06-24  7:00 Takashi Sato
2008-06-24 22:09 ` Andrew Morton
2008-06-27 11:33   ` Takashi Sato
2008-06-27 18:57     ` Andrew Morton
2008-06-29 23:13       ` Takashi Sato
2008-06-30  0:01         ` Andrew Morton

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=20080824170357.GC3792@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@googlemail.com \
    --cc=t-sato@yk.jp.nec.com \
    --cc=viro@ZenIV.linux.org.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox