linux内核奇遇记之md源代码解读之七阵列同步一
- 5171 md_wakeup_thread(mddev->thread);
- 4823 static void raid5d(struct md_thread *thread)
- 4824 {
- 4825 struct mddev *mddev = thread->mddev;
- 4826 struct r5conf *conf = mddev->private;
- 4827 int handled;
- 4828 struct blk_plug plug;
- 4829
- 4830 pr_debug("+++ raid5d active\n");
- 4831
- 4832 md_check_recovery(mddev);
- 7672 /*
- 7673 * This routine is regularly called by all per-raid-array threads to
- 7674 * deal with generic issues like resync and super-block update.
- 7675 * Raid personalities that don't have a thread (linear/raid0) do not
- 7676 * need this as they never do any recovery or update the superblock.
- 7677 *
- 7678 * It does not do any resync itself, but rather "forks" off other threads
- 7679 * to do that as needed.
- 7680 * When it is determined that resync is needed, we set MD_RECOVERY_RUNNING in
- 7681 * "->recovery" and create a thread at ->sync_thread.
- 7682 * When the thread finishes it sets MD_RECOVERY_DONE
- 7683 * and wakeups up this thread which will reap the thread and finish up.
- 7684 * This thread also removes any faulty devices (with nr_pending == 0).
- 7685 *
- 7686 * The overall approach is:
- 7687 * 1/ if the superblock needs updating, update it.
- 7688 * 2/ If a recovery thread is running, don't do anything else.
- 7689 * 3/ If recovery has finished, clean up, possibly marking spares active.
- 7690 * 4/ If there are any faulty devices, remove them.
- 7691 * 5/ If array is degraded, try to add spares devices
- 7692 * 6/ If array has spares or is not in-sync, start a resync thread.
- 7693 */
- 7694 void md_check_recovery(struct mddev *mddev)
- 7695 {
- 7696 if (mddev->suspended)
- 7697 return;
- 7698
- 7699 if (mddev->bitmap)
- 7700 bitmap_daemon_work(mddev);
- 7701
- 7702 if (signal_pending(current)) {
- 7703 if (mddev->pers->sync_request && !mddev->external) {
- 7704 printk(KERN_INFO "md: %s in immediate safe mode\n",
- 7705 mdname(mddev));
- 7706 mddev->safemode = 2;
- 7707 }
- 7708 flush_signals(current);
- 7709 }
- 7710
- 7711 if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
- 7712 return;
- 7713 if ( ! (
- 7714 (mddev->flags & ~ (1<<MD_CHANGE_PENDING)) ||
- 7715 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
- 7716 test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
- 7717 (mddev->external == 0 && mddev->safemode == 1) ||
- 7718 (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending)
- 7719 && !mddev->in_sync && mddev->recovery_cp == MaxSector)
- 7720 ))
- 7721 return;
- 7723 if (mddev_trylock(mddev)) {
- 7724 int spares = 0;
- ...
- 7746 if (!mddev->external) {
- 7747 int did_change = 0;
- 7748 spin_lock_irq(&mddev->write_lock);
- 7749 if (mddev->safemode &&
- 7750 !atomic_read(&mddev->writes_pending) &&
- 7751 !mddev->in_sync &&
- 7752 mddev->recovery_cp == MaxSector) {
- 7753 mddev->in_sync = 1;
- 7754 did_change = 1;
- 7755 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
- 7756 }
- 7757 if (mddev->safemode == 1)
- 7758 mddev->safemode = 0;
- 7759 spin_unlock_irq(&mddev->write_lock);
- 7760 if (did_change)
- 7761 sysfs_notify_dirent_safe(mddev->sysfs_state);
- 7762 }
- 7763
- 7764 if (mddev->flags)
- 7765 md_update_sb(mddev, 0);
- 7766
- 7767 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
- 7768 !test_bit(MD_RECOVERY_DONE, &mddev->recovery)) {
- 7769 /* resync/recovery still happening */
- 7770 clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
- 7771 goto unlock;
- 7772 }
- 7773 if (mddev->sync_thread) {
- 7774 reap_sync_thread(mddev);
- 7775 goto unlock;
- 7776 }
- 7777 /* Set RUNNING before clearing NEEDED to avoid
- 7778 * any transients in the value of "sync_action".
- 7779 */
- 7780 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
- 7781 /* Clear some bits that don't mean anything, but
- 7782 * might be left set
- 7783 */
- 7784 clear_bit(MD_RECOVERY_INTR, &mddev->recovery);
- 7785 clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
- 7786
- 7787 if (!test_and_clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
- 7788 test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
- 7789 goto unlock;
- 7790 /* no recovery is running.
- 7791 * remove any failed drives, then
- 7792 * add spares if possible.
- 7793 * Spare are also removed and re-added, to allow
- 7794 * the personality to fail the re-add.
- 7795 */
- 7796
- 7797 if (mddev->reshape_position != MaxSector) {
- 7798 if (mddev->pers->check_reshape == NULL ||
- 7799 mddev->pers->check_reshape(mddev) != 0)
- 7800 /* Cannot proceed */
- 7801 goto unlock;
- 7802 set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
- 7803 clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
- 7804 } else if ((spares = remove_and_add_spares(mddev))) {
- 7805 clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
- 7806 clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
- 7807 clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
- 7808 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
- 7809 } else if (mddev->recovery_cp < MaxSector) {
- 7810 set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
- 7811 clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
- 7812 } else if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
- 7813 /* nothing to be done ... */
- 7814 goto unlock;
- /* recovery/resync flags
- * NEEDED: we might need to start a resync/recover
- * RUNNING: a thread is running, or about to be started
- * SYNC: actually doing a resync, not a recovery
- * RECOVER: doing recovery, or need to try it.
- * INTR: resync needs to be aborted for some reason
- * DONE: thread is done and is waiting to be reaped
- * REQUEST: user-space has requested a sync (used with SYNC)
- * CHECK: user-space request for check-only, no repair
- * RESHAPE: A reshape is happening
- *
- * If neither SYNC or RESHAPE are set, then it is a recovery.
- */
- #define MD_RECOVERY_RUNNING 0
- #define MD_RECOVERY_SYNC 1
- #define MD_RECOVERY_RECOVER 2
- #define MD_RECOVERY_INTR 3
- #define MD_RECOVERY_DONE 4
- #define MD_RECOVERY_NEEDED 5
- #define MD_RECOVERY_REQUESTED 6
- #define MD_RECOVERY_CHECK 7
- #define MD_RECOVERY_RESHAPE 8
- #define MD_RECOVERY_FROZEN 9
* RUNNING: 准备启动或已经有同步线程有运行
* SYNC: 做同步操作
* RECOVER: 尝试或已经在重建操作
* INTR: 同步中断
* DONE: 同步完成
* REQUEST: 用户请求同步
* CHECK: 用户请求检查
* RESHAPE: reshape操作
- 7816 if (mddev->pers->sync_request) {
- 7817 if (spares) {
- ...
- 7823 }
- 7824 mddev->sync_thread = md_register_thread(md_do_sync,
- 7825 mddev,
- 7826 "resync");
- 7827 if (!mddev->sync_thread) {
- ...
- 7837 } else
- 7838 md_wakeup_thread(mddev->sync_thread);
- 7839 sysfs_notify_dirent_safe(mddev->sysfs_action);
- 7840 md_new_event(mddev);
- 7841 }
- ...
- 7850 mddev_unlock(mddev);
- 7851 }
linux内核奇遇记之md源代码解读之七阵列同步一相关推荐
- linux内核奇遇记之md源代码解读之八阵列同步二
linux内核奇遇记之md源代码解读之八阵列同步二 转载请注明出处:http://blog.csdn.net/liumangxiong 在上一小节里讲到启动同步线程: 7824 mddev->s ...
- linux内核奇遇记之md源代码解读之十二raid读写
linux内核奇遇记之md源代码解读之十二raid读写 转载请注明出处:http://blog.csdn.net/liumangxiong 我们都知道,对一个linux块设备来说,都有一个对应的请求队 ...
- 复制linux内核,linux内核写时复制机制源代码解读
作者简介 写时复制技术(一下简称COW)是linux内核比较重要的一种机制,我们都知道:父进程fork子进程的时候,子进程会和父进程会以只读的方式共享所有私有的可写页,当有一方将要写的时候会发生COW ...
- 高通linux内核目录,高通 android 源代码以及目标系统目录结构
下面为高通android源代码结构 build/ – Build 环境建立和makefiles生成4 bionic/ – Android C 库 dalvik/ – Android Java 虚拟机 ...
- xilinx linux内核,Xilinx-Zynq Linux内核源码编译过程
本文内容依据http://www.wiki.xilinx.com网址编写,编译所用操作系统为ubuntu 14 1.交叉编译环境的安装配置 2.uboot的编译 1)下载uboot源代码 下载uboo ...
- Linux内核调试方法【转】
转自:http://www.cnblogs.com/shineshqw/articles/2359114.html kdb:只能在汇编代码级进行调试: 优点是不需要两台机器进行调试. gdb:在调试模 ...
- Linux内核移植之一:内核源码结构与Makefile分析
内容来自 韦东山<嵌入式Linux应用开发完全手册> 一.内核介绍 1.版本及其特点 Linux内核的版本号可以从源代码的顶层目录下的Makefile中看到,比如下面几行它们构成了Linu ...
- linux 内核移植和根文件系统的制作【转载】
原文地址:http://www.cnblogs.com/hnrainll/archive/2011/06/09/2076214.html 1.1 Linux内核基础知识 在动手进行Linux内核移植之 ...
- linux内核源码lxr,配置glimpse与LXR读取linux内核源码
配置glimpse与LXR读取linux内核源码 1.安装 源代码编译glimpse sudo apt-get install flex sudo apt-get install lxr 2.设置Ap ...
- zynq linux内核出错,Xilinx Zynq Linux内核源码编译过程
1.交叉编译环境的安装配置 1) +Xilinx+Tools 2.uboot的编译 1)下载uboot源代码 下载uboot源代码,务必要下载tar.gz格式的文件,地址: https://githu ...
最新文章
- 2022-2028年中国汽车制动器行业投资分析及前景预测报告
- SQL Server2000 未公开的存储过程
- Java黑皮书课后题第2章:2.5(金融应用:计算小费)编写一个程序,读入一笔费用与小费利率,计算小费和总钱数
- 【SPSS】第十周-面板数据的线性回归
- Notable magic numbers
- nodejs基础整理
- oracle 基本语法,正则表达式应用
- 【BZOJ 1036】树的统计【树链剖分模板】
- 钣金编程软件Radan无人值守,自动排版功能
- python爬虫如何更换ip_Python爬虫被封IP,怎么换ip?
- 几种凹凸贴图(Bump Mapping)的学习记录
- 台式电脑锁定计算机,电脑锁住了怎么解锁
- java人民币金额大写_[求助]用java实现整数转换为人民币金额大写的功能
- Jib使用小结(Maven插件版)
- Python之Turtle库绘制简单图形
- 对26个英文字母进行huffman编码
- 不怕千招会,就怕一招精,学编程不要盲目跟风
- App中的微信支付和支付宝支付如何实现
- Kali下载Python软件包管理工具
- create与oncreate的区别