[PATCH] raid5: Flush data when do_md_stop in order to avoid stripe_cache leaking.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found some kernel message below:
=============================================================================
[  432.213819] BUG raid5-md0 (Not tainted): Objects remaining on kmem_cache_close()
[  432.213820]
-----------------------------------------------------------------------------
[  432.213820]
[  432.213823] INFO: Slab 0xffffea00029cae00 objects=24 used=1
fp=0xffff8800a72bb910 flags=0x100000000004080
[  432.213825] Pid: 6207, comm: mdadm Not tainted 3.5.0-rc6+ #56
[  432.213827] Call Trace:
[  432.213833]  [<ffffffff8111b4a1>] slab_err+0x71/0x80
[  432.213836]  [<ffffffff810e4998>] ? __free_pages+0x18/0x30
[  432.213839]  [<ffffffff8111f45a>] ? kmem_cache_destroy+0x16a/0x3a0
[  432.213841]  [<ffffffff8111f47d>] kmem_cache_destroy+0x18d/0x3a0
[  432.213845]  [<ffffffffa007ef8d>] free_conf+0x2d/0xf0 [raid456]
[  432.213848]  [<ffffffffa007f8b1>] stop+0x41/0x60 [raid456]
[  432.213851]  [<ffffffff81475e4a>] md_stop+0x1a/0x60
[  432.213854]  [<ffffffff8147ef20>] do_md_stop+0x90/0x4c0
[  432.213857]  [<ffffffff81248ea3>] ? security_capable+0x13/0x20
[  432.213859]  [<ffffffff81480f94>] md_ioctl+0x5f4/0x11f0
[  432.213862]  [<ffffffff8105cb5b>] ?lock_hrtimer_base.isra.24+0x2b/0x60
[  432.213865]  [<ffffffff81283228>] blkdev_ioctl+0xd8/0x790
[  432.213867]  [<ffffffff8105ce7a>] ? hrtimer_cancel+0x1a/0x30
[  432.213870]  [<ffffffff811587fb>] block_ioctl+0x3b/0x40
[  432.213873]  [<ffffffff81135b86>] do_vfs_ioctl+0x96/0x550
[  432.213876]  [<ffffffff8124c1a5>] ?inode_has_perm.isra.37.constprop.61+0x25/0x30
[  432.213878]  [<ffffffff8124e0af>] ? file_has_perm+0x8f/0xa0
[  432.213880]  [<ffffffff8105c6e0>] ? update_rmtp+0x70/0x70
[  432.213882]  [<ffffffff811360d1>] sys_ioctl+0x91/0xa0
[  432.213886]  [<ffffffff8166a0a2>] system_call_fastpath+0x16/0x1b
[  432.213888] INFO: Object 0xffff8800a72bbe40 @offset=15936
[  432.213890] SLUB raid5-md0: kmem_cache_destroy called for cache that
still has objects.
[  432.213892] Pid: 6207, comm: mdadm Not tainted 3.5.0-rc6+ #56
[  432.213893] Call Trace:
[  432.213895]  [<ffffffff8111f61a>] kmem_cache_destroy+0x32a/0x3a0
[  432.213898]  [<ffffffffa007ef8d>] free_conf+0x2d/0xf0 [raid456]
[  432.213900]  [<ffffffffa007f8b1>] stop+0x41/0x60 [raid456]
[  432.213902]  [<ffffffff81475e4a>] md_stop+0x1a/0x60
[  432.213904]  [<ffffffff8147ef20>] do_md_stop+0x90/0x4c0
[  432.213907]  [<ffffffff81248ea3>] ? security_capable+0x13/0x20
[  432.213909]  [<ffffffff81480f94>] md_ioctl+0x5f4/0x11f0
[  432.213911]  [<ffffffff8105cb5b>] ?lock_hrtimer_base.isra.24+0x2b/0x60
[  432.213913]  [<ffffffff81283228>] blkdev_ioctl+0xd8/0x790
[  432.213915]  [<ffffffff8105ce7a>] ? hrtimer_cancel+0x1a/0x30
[  432.213917]  [<ffffffff811587fb>] block_ioctl+0x3b/0x40
[  432.213919]  [<ffffffff81135b86>] do_vfs_ioctl+0x96/0x550
[  432.213921]  [<ffffffff8124c1a5>] ?inode_has_perm.isra.37.constprop.61+0x25/0x30
[  432.213923]  [<ffffffff8124e0af>] ? file_has_perm+0x8f/0xa0
[  432.213925]  [<ffffffff8105c6e0>] ? update_rmtp+0x70/0x70
[  432.213928]  [<ffffffff811360d1>] sys_ioctl+0x91/0xa0
[  432.213930]  [<ffffffff8166a0a2>] system_call_fastpath+0x16/0x1b

By the following steps, it can reappear.
1:create raid5
2:dd if=/dev/zero of=/dev/md0 bs=1M
3:when exec "mdadm -S /dev/md0", press "CTRL+C" in dd-command screen.

In commit 271f5a9b8f8ae0db95de72779d115c9d0b9d3cc5
Author: NeilBrown <neilb@xxxxxxx>
Remove invalidate_partition call from do_md_stop

Because the deadlock, Neil remove the flush data.But in this pathch,Neil
only thoungt the filesystem,but not consider the raw block deivces.

Using the latest kernel and readding "invalidate_partition" function.
By the patch suggested, i create os in md0(softraid5).But the deadlock
did not appear.
But maybe my test not correct,so i don't using "invalidate_partition" to
flush data. I used sync_block to flush data.

Signed-off-by: Jianpeng Ma <majianpeng@xxxxxxxxx>
---
 drivers/md/md.c    |    6 ++++++
 drivers/md/raid5.c |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index a4c219e..5716569 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5395,10 +5395,16 @@ static int do_md_stop(struct mddev * mddev, int mode, int is_open)
 	}
 
 	if (mddev->pers) {
+		struct block_device *bdev;
 		if (mddev->ro)
 			set_disk_ro(disk, 0);
 
 		__md_stop_writes(mddev);
+		/*flush data*/
+		bdev = bdget_disk(disk, 0);
+		sync_blockdev(bdev);
+		bdput(bdev);
+
 		md_stop(mddev);
 		mddev->queue->merge_bvec_fn = NULL;
 		mddev->queue->backing_dev_info.congested_fn = NULL;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 04348d7..922e26e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1682,6 +1682,7 @@ static void shrink_stripes(struct r5conf *conf)
 	while (drop_one_stripe(conf))
 		;
 
+	BUG_ON(atomic_read(&conf->active_stripes));
 	if (conf->slab_cache)
 		kmem_cache_destroy(conf->slab_cache);
 	conf->slab_cache = NULL;
-- 
1.7.5.4
?韬{.n?????%??檩??w?{.n???{炳盯w???塄}?财??j:+v??????2??璀??摺?囤??z夸z罐?+?????w棹f



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux