20 Aug 10:25
how to maintain the coherence between PG_Dirty and BH_Dirty
From: Trotski Liu <trotski.liu <at> gmail.com>
Subject: how to maintain the coherence between PG_Dirty and BH_Dirty
Newsgroups: gmane.linux.kernel
Date: 2008-08-20 08:26:22 GMT
Subject: how to maintain the coherence between PG_Dirty and BH_Dirty
Newsgroups: gmane.linux.kernel
Date: 2008-08-20 08:26:22 GMT
Sorry for my rash mail, but I really have some questions which have
bothered me for a long time.
1) Since clear_page_dirty_for_io move the dirty bit from pte to page
structure, and dirty all the buffer_head associated with the page
structure, what is the purpose of set_page_dirty in do_wp_page /
do_linear_fault ?
The dirty state is recorded in the pte, and even if we do not
call the set_page_dirty, each clear_page_dirty_for_io will set
PG_Dirty correctly according to the pte.
We only need to call set_page_dirty when the dirty pte will be
unmapped, and as long as the pte is not unmapped, the _PAGE_DIRTY in
pte will reflect the lastest dirty state of the page, isn't it?
2) in some circumstance(e.g. do_wp_page,do_linear_fault), we call
set_page_dirty without holding PG_Lock. is it possible that the page
isn't associated with any buffer_head, and set_page_dirty works like
this:
CPU 1 : spin_lock ( private_lock )
CPU 1 : nothing to do because none buffer_head is attached
CPU 1 : spin_unlock ( private_lock )
CPU 2 ( or preempt ) : create_empty_buffers {
: lock_page
: spin_lock ( private_lock )
: attached clean buffers to the page
because CPU 1 is not set PG_Dirty yet
: spin_unlock ( private_lock )
: unlock_page }
CPU 1 : Set_Bit ( PG_Dirty )
the result is dirty page with clean buffer_head, and data will lost.
(Continue reading)
RSS Feed