嵌入式爱好者

嵌入式爱好者 门户 知识库 查看内容

linux-6q-读写u盘内容时插拔u盘内核崩溃问题

2024-3-25 14:28| 发布者: PaperLove| 查看: 124| 评论: 0

类目:  >  知识库     文档编号: 1338

问题:读写u盘内容时插拔u盘内核崩溃问题
内核报错日志:
root@imx6qsabresd:~# dd if=/dev/urandom of=/dev/sda1 bs=1M count=1024
[  361.110177] usb 1-1.2: USB disconnect, device number 39
[  361.194087] FAT-fs (sda1): FAT read failed (blocknr 2582)
[  361.528671] Unable to handle kernel paging request at virtual address 2a9e5000
[  361.535908] pgd = a96b4000
[  361.538620] [2a9e5000] *pgd=00000000
[  361.542219] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[  361.547535] Modules linked in: wlan mxc_dcic
[  361.551862] CPU: 2 PID: 1160 Comm: dd Not tainted 4.1.15-00016-ga44221e #1
[  361.558741] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[  361.565275] task: a8395000 ti: a97c4000 task.ti: a97c4000
[  361.570694] PC is at __percpu_counter_add+0x30/0x104
[  361.575665] LR is at __percpu_counter_add+0x28/0x104
[  361.580638] pc : [<802fb890>]    lr : [<802fb888>]    psr: 200e0093
[  361.580638] sp : a97c5d70  ip : 00000000  fp : 00000200
[  361.592120] r10: abc30cc0  r9 : 00000200  r8 : 00000000
[  361.597351] r7 : 00000000  r6 : 00000001  r5 : 00000018  r4 : a83df550
[  361.603882] r3 : 00000000  r2 : 2a9e5000  r1 : 80adedec  r0 : 00000002
[  361.610416] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  361.617642] Control: 10c53c7d  Table: 396b404a  DAC: 00000015
[  361.623395] Process dd (pid: 1160, stack limit = 0xa97c4210)
[  361.629058] Stack: (0xa97c5d70 to 0xa97c6000)
[  361.633423] 5d60:                                     a83df530 80c3ba4c abc30cc0 a00e0013
[  361.641610] 5d80: 00000000 00000200 abc30cc0 800c6764 00000018 8087bc98 abc30cc0 a6024d64
[  361.649797] 5da0: a6024d74 8012eacc a6493e80 00000000 00001000 00000000 a6493e80 80130818
[  361.657982] 5dc0: 00001000 00000000 00001000 00001000 a6024c90 00000000 a89f09c0 80889218
[  361.666167] 5de0: 00001000 801308a4 abc30cc0 00001000 a6024d64 00001000 00000000 80133b1c
[  361.674353] 5e00: 00001000 00001000 abc30cc0 8011c018 00000000 80133af4 a97c5f14 800bd8e4
[  361.682538] 5e20: 00001000 00001000 abc30cc0 8011c018 00400000 00000000 a8977e50 00000000
[  361.690724] 5e40: a97c4000 00000000 abc30cc0 8011c018 5948f429 00000000 a97c5f28 a6024d64
[  361.698909] 5e60: a89f09c0 00000000 00000000 a89f09c0 a97c5f14 800becc0 00000000 00000000
[  361.707094] 5e80: 00000000 00000000 00000000 00000000 00000000 d7e00000 00000000 a97c5f28
[  361.715279] 5ea0: a89f09c0 a97c5f14 00000000 00000000 0002d800 801346cc 00000006 8038ba84
[  361.723465] 5ec0: a9fe3648 0000c000 a97c5ec8 a97c5ec8 a97c5ed0 a97c5ed0 a97c5ed8 a97c5ed8
[  361.731651] 5ee0: 00100000 a89f09c0 00000000 00100000 a97c5f88 00400000 00000000 80103f00
[  361.739837] 5f00: 00100000 76f73000 76f57d14 76bbd000 00100000 00000001 00000000 00100000
[  361.748022] 5f20: a97c5f0c 00000001 a89f09c0 00000000 00400000 00000000 00000000 00000000
[  361.756207] 5f40: 00000000 00000000 a8102a70 a89f09c0 00100000 76bbd000 a97c5f88 8000f604
[  361.764393] 5f60: a97c4000 801046a8 00000000 a8992240 a89f09c0 a89f09c0 76bbd000 00100000
[  361.772578] 5f80: 8000f604 80104ec0 00400000 00000000 00102008 00000000 00100000 0002d898
[  361.780764] 5fa0: 00000004 8000f480 00000000 00100000 00000001 76bbd000 00100000 00000000
[  361.788949] 5fc0: 00000000 00100000 0002d898 00000004 76bbd000 00000000 00000001 0002d800
[  361.797135] 5fe0: 00000000 7ee94b2c 000146d8 76efb800 400e0010 00000001 00000000 00000000
[  361.805334] [<802fb890>] (__percpu_counter_add) from [<800c6764>] (account_page_dirtied+0x74/0xe0)
[  361.814310] [<800c6764>] (account_page_dirtied) from [<8012eacc>] (__set_page_dirty+0x50/0xb8)
[  361.822936] [<8012eacc>] (__set_page_dirty) from [<80130818>] (__block_commit_write+0x84/0xac)
[  361.831560] [<80130818>] (__block_commit_write) from [<801308a4>] (block_write_end+0x40/0x80)
[  361.840100] [<801308a4>] (block_write_end) from [<80133b1c>] (blkdev_write_end+0x28/0x48)
[  361.848295] [<80133b1c>] (blkdev_write_end) from [<800bd8e4>] (generic_perform_write+0x114/0x1ac)
[  361.857182] [<800bd8e4>] (generic_perform_write) from [<800becc0>] (__generic_file_write_iter+0x178/0x1c8)
[  361.866849] [<800becc0>] (__generic_file_write_iter) from [<801346cc>] (blkdev_write_iter+0x98/0x138)
[  361.876084] [<801346cc>] (blkdev_write_iter) from [<80103f00>] (__vfs_write+0xa8/0xd8)
[  361.884013] [<80103f00>] (__vfs_write) from [<801046a8>] (vfs_write+0x90/0x16c)
[  361.891335] [<801046a8>] (vfs_write) from [<80104ec0>] (SyS_write+0x44/0x9c)
[  361.898401] [<80104ec0>] (SyS_write) from [<8000f480>] (ret_fast_syscall+0x0/0x3c)
[  361.905980] Code: e34800ad ebffd0bb e5943018 ee1d2f90 (e7933002)
[  361.912082] ---[ end trace 89058ac714e79a6b ]---
[  361.916707] note: dd[1160] exited with preempt_count 2
解决方法见链接:
补丁如下:
diff --git a/block/blk-core.c b/block/blk-core.c
index bbbf36e6066b..edf8d72daa83 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -554,7 +554,7 @@ void blk_cleanup_queue(struct request_queue *q)
  q->queue_lock = &q->__queue_lock;
  spin_unlock_irq(lock);
 
- bdi_destroy(&q->backing_dev_info);
+ bdi_unregister(&q->backing_dev_info);
 
  /* @q is and will stay empty, shutdown and put */
  blk_put_queue(q);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 2b8fd302f677..c0bb3291859c 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -501,6 +501,7 @@ static void blk_release_queue(struct kobject *kobj)
  struct request_queue *q =
  container_of(kobj, struct request_queue, kobj);
 
+ bdi_exit(&q->backing_dev_info);
  blkcg_exit_queue(q);
 
  if (q->elevator) {
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index d87d8eced064..17d1799f8552 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -110,12 +110,15 @@ struct backing_dev_info {
 struct backing_dev_info *inode_to_bdi(struct inode *inode);
 
 int __must_check bdi_init(struct backing_dev_info *bdi);
-void bdi_destroy(struct backing_dev_info *bdi);
+void bdi_exit(struct backing_dev_info *bdi);
 
 __printf(3, 4)
 int bdi_register(struct backing_dev_info *bdi, struct device *parent,
  const char *fmt, ...);
 int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
+void bdi_unregister(struct backing_dev_info *bdi);
+void bdi_destroy(struct backing_dev_info *bdi);
+
 int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
 void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages,
  enum wb_reason reason);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 000e7b3b9896..1cf18ff42c54 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -421,10 +421,8 @@ err:
 }
 EXPORT_SYMBOL(bdi_init);
 
-void bdi_destroy(struct backing_dev_info *bdi)
+void bdi_unregister(struct backing_dev_info *bdi)
 {
- int i;
-
  bdi_wb_shutdown(bdi);
  bdi_set_min_ratio(bdi, 0);
 
@@ -436,11 +434,24 @@ void bdi_destroy(struct backing_dev_info *bdi)
  device_unregister(bdi->dev);
  bdi->dev = NULL;
  }
+}
+
+void bdi_exit(struct backing_dev_info *bdi)
+{
+ int i;
+
+ WARN_ON_ONCE(bdi->dev);
 
  for (i = 0; i < NR_BDI_STAT_ITEMS; i++)
  percpu_counter_destroy(&bdi->bdi_stat[i]);
  fprop_local_destroy_percpu(&bdi->completions);
 }
+
+void bdi_destroy(struct backing_dev_info *bdi)
+{
+ bdi_unregister(bdi);
+ bdi_exit(bdi);
+}
 EXPORT_SYMBOL(bdi_destroy);
 
 /*


已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2025-3-10 09:51

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部