- 论坛徽章:
- 0
|
__wait_on_bit 最终执行下面的函数:
87 /*
88 * Block until a buffer comes unlocked. This doesn't stop it
89 * from becoming locked again - you have to lock it yourself
90 * if you want to preserve its state.
91 */
92 void __wait_on_buffer(struct buffer_head * bh)
93 {
94 wait_on_bit(&bh->b_state, BH_Lock, sync_buffer, TASK_UNINTERRUPTIBLE);
95 }
监视buffer_head结构中->b_state字段的BH_Lock标志位,如果此位clear即执行sync_buffer,
它的实现细节及原理,这里暂时不讨论。
------------------------------------------------------------------------------
58 static int sync_buffer(void *word)
59 {
60 struct block_device *bd;
61 struct buffer_head *bh
62 = container_of(word, struct buffer_head, b_state);
63/*直接用b_state字段来获取整个结构*/
64 smp_mb();
65 bd = bh->b_bdev; /*获取块设备struct block_device*/
66 if (bd)
67 blk_run_address_space(bd->bd_inode->i_mapping); /*这里到了cache结构 address_space*/
/*这个函数最终会执行到下面*/
68 io_schedule();
69 return 0;
70 }
-----------------------------------------------------------------------------
|
|