- 論壇徽章:
- 0
|
__wait_on_bit 最終執(zhí)行下面的函數(shù):
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 }
監(jiān)視buffer_head結(jié)構(gòu)中->b_state字段的BH_Lock標(biāo)志位,如果此位clear即執(zhí)行sync_buffer,
它的實(shí)現(xiàn)細(xì)節(jié)及原理,這里暫時(shí)不討論。
------------------------------------------------------------------------------
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字段來獲取整個(gè)結(jié)構(gòu)*/
64 smp_mb();
65 bd = bh->b_bdev; /*獲取塊設(shè)備struct block_device*/
66 if (bd)
67 blk_run_address_space(bd->bd_inode->i_mapping); /*這里到了cache結(jié)構(gòu) address_space*/
/*這個(gè)函數(shù)最終會執(zhí)行到下面*/
68 io_schedule();
69 return 0;
70 }
-----------------------------------------------------------------------------
|
|