---
title: bcache模块注册超时导致操作系统无法启动的解决方法
description: "bcache模块注册超时操作系统无法启动。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengsdss/troubleshooting/trouble/boostkit_sds_troublecase_007.html
sourcePath: /source/zh/kunpengsdss/troubleshooting/trouble/boostkit_sds_troublecase_007.html
indexId: bd4a0d24d87c8c8f01431989d676831caa15c9eee887743e0cb072db7a3131f880
---
# bcache模块注册超时导致操作系统无法启动的解决方法

#### 问题现象描述

bcache模块注册超时操作系统无法启动。

使用鲲鹏服务器运行Ceph应用。每台服务器配置有20个HDD、4个SSD。使用bcache方案，每个SSD上有5个分区作为5个HDD的cache分区。总共4*5个bcache分区，运行20个OSD。测试过程中，重启服务器，发现服务器无法正常启动，无法进入系统。


#### 关键过程、根本原因分析

通过手动打点计时，分析bcache模块注册过程的时间分布。发现在注册前端分区很快完成，而注册cache分区的耗时较长达到10多秒，总共20个cache分区需要注册，而udev启动设备默认的超时时长为180秒，在超时时间内有一部分的设备根本无法完成注册，导致了被杀死。进一步分析是在注册cache分区的过程中，bch_tree_check占用了绝大部分时间。此函数是对cache中btree中的key进行校验，判断key是否有效或者损坏，保障数据的一致性。当key很多的时候，校验就会比较慢。

```
Mar 05 12:00:15 hwceph1 systemd-udevd[9474]: worker [9476] /devices/pci0000:00/0000:00:08.0/0000:03:00.0/host4/target4:0:4/4:0:4:0/block/
sdd/sdd1 timeout; kill it
Mar 05 12:00:15 hwceph1 systemd-udevd[9474]: seq 6970
/devices/pci0000:00/0000:00:08.0/0000:03:00.0/host4/target4:0:6/4:0:6:0/block/sdf/sdf1 timeout; kill it
Mar 05 12:00:15 hwceph1 systemd-udevd[9474]: seq 6984 '/devices/pci0000:00/0000:00:08.0/0000:03:00.0/host4/target4:0:6/4:0:6:0/block/sdf/sdf1' killed
Mar 05 12:00:15 hwceph1 systemd-udevd[9474]: worker [9500] /devices/pci0000:00/0000:00:08.0/0000:03:00.0/host4/target4:0:25/4:0:25:0/block/sdx/sdx12 timeout; kill it
```


#### 结论、解决方案及效果

- 加速bcache模块的注册，初步验证可行
  加速bch_btree_check的运行时间。已有patch：https://patchwork.kernel.org/patch/11383771/(https://bbs.huaweicloud.com/forum/thread-45557-1-1.html#) 将变成多线程并行校验。

- 延长udev设备管理超时时间，验证可行
  通过延长udev设备管理事件的超时时间，让bcache-register不会被终止，等待bcache分区注册成功。在启动项中增加udev.event_timeout=300，超时时长可以按情况设置。
