From: Akira Hayakawa <ruby.wktk@gmail.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: "輝 早川" <ruby.wktk@gmail.com>
Subject: [PATCH] bugfix: map_context->ptr must be nullify in no-cache path.
Date: Sat, 10 Aug 2013 23:39:35 +0900 [thread overview]
Message-ID: <520650A7.4030408@gmail.com> (raw)
Hi,
Please apply this patch after the previous patch.
This will fix bug.
First, sorry to forget adding signed-off to that patch.
When running prepare script,
the kernel sometimes halt was my annoying problem.
I may solve this with this patch.
lc_end_io is a callback of a splitted bio.
It atomic_dec some reference count
if map_context->ptr is not NULL.
dmsetup create first calls lc_ctr and
seems to submit few bios to the device just created.
At this stage, the device is without cache and
it will later attach to cache.
Without cache,
said atomic_dec is not only needless
but also crash the kernel by NULL access.
Maybe,
map_context->ptr
where map_context is per_bio_data within bio
is NOT initialized zero-filled and
that makes the process
sometimes run through atomic_dec even though without cache.
Moving the line
assigning NULL to map_context->ptr in lc_map
to before "no-cache" path can solve this problem.
After this patch applied,
the kernel halt did not recur.
Akira
Signed-off-by: Akira Hayakawa <ruby.wktk@gmail.com>
---
drivers/md/dm-lc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-lc.c b/drivers/md/dm-lc.c
index b70ab38..8f76383 100644
--- a/drivers/md/dm-lc.c
+++ b/drivers/md/dm-lc.c
@@ -1889,6 +1889,9 @@ static int lc_map(struct dm_target *ti, struct bio *bio)
struct lc_device *lc = ti->private;
struct dm_dev *orig = lc->device;
+ map_context = dm_per_bio_data(bio, ti->per_bio_data_size);
+ map_context->ptr = NULL;
+
if (!lc->cache) {
bio_remap(bio, orig, bio->bi_sector);
return DM_MAPIO_REMAPPED;
@@ -1918,9 +1921,6 @@ static int lc_map(struct dm_target *ti, struct bio *bio)
return DM_MAPIO_SUBMITTED;
}
- map_context = dm_per_bio_data(bio, ti->per_bio_data_size);
- map_context->ptr = NULL;
-
bio_count = bio->bi_size >> SECTOR_SHIFT;
bio_fullsize = (bio_count == (1 << 3));
bio_offset = bio->bi_sector % (1 << 3);
--
1.8.3.4
reply other threads:[~2013-08-10 14:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=520650A7.4030408@gmail.com \
--to=ruby.wktk@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).