From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Milan Broz <mbroz@redhat.com>,
Alasdair G Kergon <agk@redhat.com>
Subject: [patch 16/43] dm crypt: wait for endio to complete before destruction
Date: Fri, 20 Mar 2009 15:28:26 -0700 [thread overview]
Message-ID: <20090320222925.453417607@mini.kroah.org> (raw)
In-Reply-To: <20090320232116.GA3375@kroah.com>
[-- Attachment #1: dm-crypt-wait-for-endio-to-complete-before-destruction.patch --]
[-- Type: text/plain, Size: 4681 bytes --]
2.6.28-stable review patch. If anyone has any objections, please let us know.
------------------
From: Milan Broz <mbroz@redhat.com>
commit b35f8caa0890169000fec22902290d9a15274cbd upstream.
The following oops has been reported when dm-crypt runs over a loop device.
...
[ 70.381058] Process loop0 (pid: 4268, ti=cf3b2000 task=cf1cc1f0 task.ti=cf3b2000)
...
[ 70.381058] Call Trace:
[ 70.381058] [<d0d76601>] ? crypt_dec_pending+0x5e/0x62 [dm_crypt]
[ 70.381058] [<d0d767b8>] ? crypt_endio+0xa2/0xaa [dm_crypt]
[ 70.381058] [<d0d76716>] ? crypt_endio+0x0/0xaa [dm_crypt]
[ 70.381058] [<c01a2f24>] ? bio_endio+0x2b/0x2e
[ 70.381058] [<d0806530>] ? dec_pending+0x224/0x23b [dm_mod]
[ 70.381058] [<d08066e4>] ? clone_endio+0x79/0xa4 [dm_mod]
[ 70.381058] [<d080666b>] ? clone_endio+0x0/0xa4 [dm_mod]
[ 70.381058] [<c01a2f24>] ? bio_endio+0x2b/0x2e
[ 70.381058] [<c02bad86>] ? loop_thread+0x380/0x3b7
[ 70.381058] [<c02ba8a1>] ? do_lo_send_aops+0x0/0x165
[ 70.381058] [<c013754f>] ? autoremove_wake_function+0x0/0x33
[ 70.381058] [<c02baa06>] ? loop_thread+0x0/0x3b7
When a table is being replaced, it waits for I/O to complete
before destroying the mempool, but the endio function doesn't
call mempool_free() until after completing the bio.
Fix it by swapping the order of those two operations.
The same problem occurs in dm.c with md referenced after dec_pending.
Again, we swap the order.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/md/dm-crypt.c | 17 ++++++++++-------
drivers/md/dm.c | 32 +++++++++++++++++++-------------
2 files changed, 29 insertions(+), 20 deletions(-)
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -480,9 +480,12 @@ static int __noflush_suspending(struct m
static void dec_pending(struct dm_io *io, int error)
{
unsigned long flags;
+ int io_error;
+ struct bio *bio;
+ struct mapped_device *md = io->md;
/* Push-back supersedes any I/O errors */
- if (error && !(io->error > 0 && __noflush_suspending(io->md)))
+ if (error && !(io->error > 0 && __noflush_suspending(md)))
io->error = error;
if (atomic_dec_and_test(&io->io_count)) {
@@ -492,25 +495,28 @@ static void dec_pending(struct dm_io *io
* This must be handled before the sleeper on
* suspend queue merges the pushback list.
*/
- spin_lock_irqsave(&io->md->pushback_lock, flags);
- if (__noflush_suspending(io->md))
- bio_list_add(&io->md->pushback, io->bio);
+ spin_lock_irqsave(&md->pushback_lock, flags);
+ if (__noflush_suspending(md))
+ bio_list_add(&md->pushback, io->bio);
else
/* noflush suspend was interrupted. */
io->error = -EIO;
- spin_unlock_irqrestore(&io->md->pushback_lock, flags);
+ spin_unlock_irqrestore(&md->pushback_lock, flags);
}
end_io_acct(io);
- if (io->error != DM_ENDIO_REQUEUE) {
- blk_add_trace_bio(io->md->queue, io->bio,
+ io_error = io->error;
+ bio = io->bio;
+
+ free_io(md, io);
+
+ if (io_error != DM_ENDIO_REQUEUE) {
+ blk_add_trace_bio(md->queue, io->bio,
BLK_TA_COMPLETE);
- bio_endio(io->bio, io->error);
+ bio_endio(bio, io_error);
}
-
- free_io(io->md, io);
}
}
@@ -518,6 +524,7 @@ static void clone_endio(struct bio *bio,
{
int r = 0;
struct dm_target_io *tio = bio->bi_private;
+ struct dm_io *io = tio->io;
struct mapped_device *md = tio->io->md;
dm_endio_fn endio = tio->ti->type->end_io;
@@ -541,15 +548,14 @@ static void clone_endio(struct bio *bio,
}
}
- dec_pending(tio->io, error);
-
/*
* Store md for cleanup instead of tio which is about to get freed.
*/
bio->bi_private = md->bs;
- bio_put(bio);
free_tio(md, tio);
+ bio_put(bio);
+ dec_pending(io, error);
}
static sector_t max_io_len(struct mapped_device *md,
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -568,19 +568,22 @@ static void crypt_inc_pending(struct dm_
static void crypt_dec_pending(struct dm_crypt_io *io)
{
struct crypt_config *cc = io->target->private;
+ struct bio *base_bio = io->base_bio;
+ struct dm_crypt_io *base_io = io->base_io;
+ int error = io->error;
if (!atomic_dec_and_test(&io->pending))
return;
- if (likely(!io->base_io))
- bio_endio(io->base_bio, io->error);
+ mempool_free(io, cc->io_pool);
+
+ if (likely(!base_io))
+ bio_endio(base_bio, error);
else {
- if (io->error && !io->base_io->error)
- io->base_io->error = io->error;
- crypt_dec_pending(io->base_io);
+ if (error && !base_io->error)
+ base_io->error = error;
+ crypt_dec_pending(base_io);
}
-
- mempool_free(io, cc->io_pool);
}
/*
next prev parent reply other threads:[~2009-03-20 23:31 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090320222810.386844059@mini.kroah.org>
2009-03-20 23:21 ` [patch 00/43] 2.6.28.9-stable review Greg KH
2009-03-20 22:28 ` [patch 01/43] [IA64] Build fix for __early_pfn_to_nid() undefined link error Greg KH
2009-03-20 22:28 ` [patch 02/43] Fix misreporting of #cores as #hyperthreads for Q9550 Greg KH
2009-03-20 22:28 ` [patch 03/43] eventfd: remove fput() call from possible IRQ context Greg KH
2009-03-20 22:28 ` [patch 04/43] S390: __div64_31 broken for CONFIG_MARCH_G5 Greg KH
2009-03-20 22:28 ` [patch 05/43] ALSA: Fix vunmap and free order in snd_free_sgbuf_pages() Greg KH
2009-03-20 22:28 ` [patch 06/43] ALSA: mixart, fix lock imbalance Greg KH
2009-03-20 22:28 ` [patch 07/43] ALSA: pcm_oss, fix locking typo Greg KH
2009-03-20 22:28 ` [patch 08/43] ALSA: hda - Fix DMA mask for ATI controllers Greg KH
2009-03-20 22:28 ` [patch 09/43] ALSA: hda - Workaround for buggy DMA position on " Greg KH
2009-03-20 22:28 ` [patch 10/43] ALSA: opl3sa2 - Fix NULL dereference when suspending snd_opl3sa2 Greg KH
2009-03-20 22:28 ` [patch 11/43] nfsd: nfsd should drop CAP_MKNOD for non-root Greg KH
2009-03-20 22:28 ` [patch 12/43] NFSD: provide encode routine for OP_OPENATTR Greg KH
2009-03-20 22:28 ` [patch 13/43] dm ioctl: validate name length when renaming Greg KH
2009-03-20 22:28 ` [patch 14/43] dm io: respect BIO_MAX_PAGES limit Greg KH
2009-03-20 22:28 ` [patch 15/43] dm crypt: fix kcryptd_async_done parameter Greg KH
2009-03-20 22:28 ` Greg KH [this message]
2009-03-20 22:28 ` [patch 17/43] ata_piix: add workaround for Samsung DB-P70 Greg KH
2009-03-20 22:28 ` [patch 18/43] V4L/DVB (10218): cx23885: Fix Oops for mixed install of analog and digital only cards Greg KH
2009-03-20 22:28 ` [patch 19/43] thinkpad-acpi: fix module autoloading for older models Greg KH
2009-03-20 22:28 ` [patch 20/43] Add -fwrapv to gcc CFLAGS Greg KH
2009-03-20 22:28 ` [patch 21/43] Move cc-option to below arch-specific setup Greg KH
2009-03-20 22:28 ` [patch 22/43] USB: storage: Unusual USB device Prolific 2507 variation added Greg KH
2009-03-20 22:28 ` [patch 23/43] USB: Add Vendor/Product ID for new CDMA U727 to option driver Greg KH
2009-03-20 22:28 ` [patch 24/43] USB: option.c: add ZTE 622 modem device Greg KH
2009-03-20 22:28 ` [patch 25/43] USB: Add device id for Option GTM380 to option driver Greg KH
2009-03-20 22:28 ` [patch 26/43] USB: Option: let cdc-acm handle Sony Ericsson F3507g / Dell 5530 Greg KH
2009-03-20 22:28 ` [patch 27/43] USB: Updated unusual-devs entry for USB mass storage on Nokia 6233 Greg KH
2009-03-20 22:28 ` [patch 28/43] USB: unusual_devs: Add support for GI 0431 SD-Card interface Greg KH
2009-03-20 22:28 ` [patch 29/43] USB: serial: add FTDI USB/Serial converter devices Greg KH
2009-03-20 22:28 ` [patch 30/43] USB: serial: ftdi: enable UART detection on gnICE JTAG adaptors blacklist interface0 Greg KH
2009-03-20 22:28 ` [patch 31/43] USB: serial: new cp2101 device id Greg KH
2009-03-20 22:28 ` [patch 32/43] USB: usbtmc: fix stupid bug in open() Greg KH
2009-03-20 22:28 ` [patch 33/43] USB: usbtmc: add protocol 1 support Greg KH
2009-03-20 22:28 ` [patch 34/43] USB: usbfs: keep async URBs until the device file is closed Greg KH
2009-03-20 22:28 ` [patch 35/43] USB: EHCI: expedite unlinks when the root hub is suspended Greg KH
2009-03-20 22:28 ` [patch 36/43] USB: EHCI: Fix isochronous URB leak Greg KH
2009-03-20 22:28 ` [patch 37/43] powerpc: Remove extra semicolon in fsl_soc.c Greg KH
2009-03-20 22:28 ` [patch 38/43] drm/i915: set vblank enabled flag correctly across IRQ install/uninstall Greg KH
2009-03-21 0:09 ` Eric Anholt
2009-03-21 0:43 ` Greg KH
2009-03-20 22:28 ` [patch 39/43] drm/i915: dont enable vblanks on disabled pipes Greg KH
2009-03-20 22:28 ` [patch 40/43] drm/i915: Dont double-unpin buffers if we take a signal in evict_everything() Greg KH
2009-03-20 22:28 ` [patch 41/43] drm/i915: Dont print to dmesg when taking signal during object_pin Greg KH
2009-03-20 22:28 ` [patch 42/43] drm/i915: Dont allow objects to get bound while VT switched Greg KH
2009-03-20 22:28 ` [patch 43/43] menu: fix embedded menu snafu Greg KH
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=20090320222925.453417607@mini.kroah.org \
--to=gregkh@suse.de \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbroz@redhat.com \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--cc=zwane@arm.linux.org.uk \
/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
Powered by JetHome