All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH] Flush deferred queue when dm_suspend() is interrupted
Date: Thu, 09 Mar 2006 18:48:29 -0500	[thread overview]
Message-ID: <4410BECD.9080908@ce.jp.nec.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]

Hello,

I found in a code review that dm_suspend() doesn't flush
deferred queue when it's interrupted and failed to suspend.

Attached patch theoretically fixes this problem.
But I don't have a testcase to pick this point
and would like to hear comment from others whether
there is something to prevent this.

Also, modifying DMF_BLOCK_IO outside of io_lock may
cause a race like this:
   CPU0 (dm_suspend)         CPU1 (dm_request)
   -------------------------------------------------
   set_bit(DMF_BLOCK_IO)
   ...
   up_write(io_lock)
                               down_read(io_lock)
                               test_bit(DMF_BLOCK_IO)
                               up_read(io_lock)
                               queue_io(deferred)
                                 down_write(io_lock)
                                 test_bit(DMF_BLOCK_IO)
                                 up_write(io_lock)
   clear_bit(DMF_BLOCK_IO)

   The deferred I/O never be flushed until dm_resume().


For the failed dm_suspend() case, there is another problem
that presuspend is not reverted.
It may require a new method like suspend_cancel() for
any target which implements presuspend().

I would appreicate a comment for this as well.

Thanks,
-- 
Jun'ichi Nomura, NEC Solutions (America), Inc.

[-- Attachment #2: dm-flush-queue-eintr.patch --]
[-- Type: text/x-patch, Size: 727 bytes --]

When dm_suspend() is interrupted, it's possible that some bios are
queued to deferred list.
DMF_BLOCK_IO modification must be protected by io->lock.

Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>


--- linux-2.6.16-rc5.orig/drivers/md/dm.c	2006-02-27 00:09:35.000000000 -0500
+++ linux-2.6.16-rc5/drivers/md/dm.c	2006-03-08 14:54:09.000000000 -0500
@@ -1152,9 +1152,10 @@ int dm_suspend(struct mapped_device *md,
 	/* were we interrupted ? */
 	r = -EINTR;
 	if (atomic_read(&md->pending)) {
+		clear_bit(DMF_BLOCK_IO, &md->flags);
+		__flush_deferred_io(md, bio_list_get(&md->deferred));
 		up_write(&md->io_lock);
 		unlock_fs(md);
-		clear_bit(DMF_BLOCK_IO, &md->flags);
 		goto out;
 	}
 	up_write(&md->io_lock);

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2006-03-09 23:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09 23:48 Jun'ichi Nomura [this message]
2006-03-12 21:02 ` [PATCH] Flush deferred queue when dm_suspend() is interrupted Alasdair G Kergon

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=4410BECD.9080908@ce.jp.nec.com \
    --to=j-nomura@ce.jp.nec.com \
    --cc=dm-devel@redhat.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.