- 论坛徽章:
- 0
|
(1) mm/filemap.c
507 void fastcall __lock_page(struct page *page)
508 {
509 DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
510
/*
struct wait_bit_queue wait =
{
.key =
.wait =
{
}
}
*/
511 __wait_on_bit_lock(page_waitqueue(page), &wait, sync_page,
512 TASK_UNINTERRUPTIBLE);
513 }
514 EXPORT_SYMBOL(__lock_page);
(2) include/linux/wait.h
393 #define DEFINE_WAIT_BIT(name, word, bit) \
394 struct wait_bit_queue name = { \
395 .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \
396 .wait = { \
397 .private = current, \
398 .func = wake_bit_function, \
399 .task_list = \
400 LIST_HEAD_INIT((name).wait.task_list), \
401 }, \
402 }
(3)kernel/wait.c
179 int __sched fastcall
180 __wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
181 int (*action)(void *), unsigned mode)
182 {
183 int ret = 0;
184
185 do {
186 prepare_to_wait_exclusive(wq, &q->wait, mode);
187 if (test_bit(q->key.bit_nr, q->key.flags)) {
188 if ((ret = (*action)(q->key.flags)))
189 break;
190 }
191 } while (test_and_set_bit(q->key.bit_nr, q->key.flags));
192 finish_wait(wq, &q->wait);
193 return ret;
194 }
195 EXPORT_SYMBOL(__wait_on_bit_lock);
(4) static int sync_page(void *word)
135 {
136 struct address_space *mapping;
137 struct page *page;
138
139 page = container_of((unsigned long *)word, struct page, flags);
140
162 smp_mb();
163 mapping = page_mapping(page);
164 if (mapping && mapping->a_ops && mapping->a_ops->sync_page)
165 mapping->a_ops->sync_page(page);
166 io_schedule();
167 return 0;
168 }
逻辑简单,调用mapping->a_ops->sync_page(page),对于ext2就是ext2_aops
->block_sync_page->run_task_queue(&tq_disk)(fs/buffer.c).让磁盘有更多
机会运行回写,读入等任务.这样说不定就不用再等待了.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/17526/showart_1079656.html |
|