Linux RAID subsystem development
 help / color / mirror / Atom feed
From: "Li, Zhen-Hua" <zhen-hual@hp.com>
To: linux-kernel@vger.kernel.org, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	dm-devel@redhat.com, Neil Brown <neilb@suse.de>,
	linux-raid@vger.kernel.org
Cc: "Li, Zhen-Hua" <zhen-hual@hp.com>
Subject: [PATCH 1/1] driver/md/block: Alloc space for member flush_rq
Date: Wed, 28 May 2014 14:22:52 +0800	[thread overview]
Message-ID: <1401258172-17381-1-git-send-email-zhen-hual@hp.com> (raw)

This patch is trying to fix a kernel crash bug.

When kernel boots on a HP large system, it crashes.
The reason is when blk_rq_init is called, the second parameter rq , which
is a member as q->flush_rq, is NULL. Kernel does not allocate space for it.

This fix adds an alloc for flush_rq member when request_queue is created in
struct mapped_device *alloc_dev(int minor);

Bug Details:
Error message:

[   62.931942] BUG: unable to handle kernel NULL pointer dereference at (null)
[   62.931949] IP: [<ffffffff812b3f30>] blk_rq_init+0x40/0x160^M
[   62.931949] PGD 0 ^M
[   62.931951] Oops: 0002 [#1] SMP

[   62.932019] Call Trace:
[   62.932025]  [<ffffffff812bc5b8>] blk_flush_complete_seq+0x2d8/0x300
[   62.932027]  [<ffffffff812bca55>] blk_insert_flush+0x1e5/0x250
[   62.932029]  [<ffffffff812b3038>] __elv_add_request+0x1d8/0x2d0
[   62.932031]  [<ffffffff812ba630>] blk_flush_plug_list+0x140/0x230
[   62.932033]  [<ffffffff812baab4>] blk_finish_plug+0x14/0x40
[   62.932041]  [<ffffffffa0311e0c>] _xfs_buf_ioapply+0x2fc/0x3d0 [xfs]
[   62.932053]  [<ffffffffa036e63f>] ? xlog_bdstrat+0x1f/0x50 [xfs]
[   62.932061]  [<ffffffffa0313716>] xfs_buf_iorequest+0x46/0x90 [xfs]
[   62.932071]  [<ffffffffa036e63f>] xlog_bdstrat+0x1f/0x50 [xfs]
[   62.932080]  [<ffffffffa0370385>] xlog_sync+0x265/0x450 [xfs]
[   62.932090]  [<ffffffffa0370602>] xlog_state_release_iclog+0x92/0xb0 [xfs]
[   62.932099]  [<ffffffffa03713ba>] _xfs_log_force+0x15a/0x290 [xfs]
[   62.932108]  [<ffffffffa0371516>] xfs_log_force+0x26/0x80 [xfs]
[   62.932117]  [<ffffffffa0371594>] xfs_log_worker+0x24/0x50 [xfs]
[   62.932122]  [<ffffffff8108ce8b>] process_one_work+0x17b/0x460
[   62.932125]  [<ffffffff8108dc5b>] worker_thread+0x11b/0x400
[   62.932126]  [<ffffffff8108db40>] ? rescuer_thread+0x400/0x400
[   62.932130]  [<ffffffff81094ca1>] kthread+0xe1/0x100
[   62.932133]  [<ffffffff81094bc0>] ? kthread_create_on_node+0x1a0/0x1a0
[   62.932140]  [<ffffffff8162ae3c>] ret_from_fork+0x7c/0xb0
[   62.932141]  [<ffffffff81094bc0>] ? kthread_create_on_node+0x1a0/0x1a0

Signed-off-by: Li, Zhen-Hua <zhen-hual@hp.com>
---
 drivers/md/dm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 455e649..9ff6df6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1893,6 +1893,10 @@ static struct mapped_device *alloc_dev(int minor)
 	if (!md->queue)
 		goto bad_queue;
 
+	md->queue->flush_rq = kzalloc(sizeof(struct request), GFP_KERNEL);
+	if (!md->queue->flush_rq)
+		goto bad_disk;
+
 	dm_init_md_queue(md);
 
 	md->disk = alloc_disk(1);
-- 
2.0.0-rc0

             reply	other threads:[~2014-05-28  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28  6:22 Li, Zhen-Hua [this message]
2014-05-28 15:03 ` [PATCH 1/1] driver/md/block: Alloc space for member flush_rq Mike Snitzer
2014-05-29  1:58   ` Li, Zhen-Hua

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=1401258172-17381-1-git-send-email-zhen-hual@hp.com \
    --to=zhen-hual@hp.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=snitzer@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