* [RFC] 2.4 truncate locking
@ 2002-04-17 15:09 William Lee Irwin III
2002-04-19 4:37 ` William Lee Irwin III
0 siblings, 1 reply; 2+ messages in thread
From: William Lee Irwin III @ 2002-04-17 15:09 UTC (permalink / raw)
To: linux-kernel; +Cc: viro
I did some research on how truncate_inode_pages()'s locking works.
Please feel free to clarify and/or correct my notes on the subject,
which I'd like to turn into a docpatch soon.
Thanks to Al Viro, Rik van Riel, Arjan van de Ven, and Christoph Hellwig
for their help to clarify these rules.
Cheers,
Bill
(1) exclusion from freeing of the inode
inode->i_count for holding a reference count to protect against
prematurely freeing the inode.
(2) exclusion from simultaneous manipulation of the inode page lists
pagecache_lock protects page->list and the inode list heads.
(3) exclusion from creation of memory mappings to the affected region
inode->i_shared_lock and inode->i_mmap_lock serialize mmap
operations, but are not held by truncate_inode_pages() and so
proceed simultaneously. No pages are allocated by this operation
to refer to the inode, as this is done lazily at fault-time.
See (8) for fault-time exclusion.
(4) exclusion from writes to the affected region
inode->i_sem
(5) exclusion from reads to the affected region
reads beyond inode->i_size do not perform pagecache lookup
pagecache_lock serializes pagecache access while truncation
simultaneously proceeds
(6) exclusion from pageout of the affected region
pagemap_lru_lock
(7) exclusion from multiple simultaneous truncate operations
inode->i_sem
(8) exclusion from memory-mapped reads or writes of the affected region
either
(1) unmapping the pages from all processes referencing the pages
to obtain unique references to them all by means of
vmtruncate() / zap_page_range()
*or*
(2) a unique reference to the inode itself (vma's mapping a file
have ->vm_file which holds a reference to the inode)
(9) exclusion from simultaneous manipulation of page->mapping
pagemap_lru_lock
(10) exclusion from simultaneous manipulation of pages by buffer cache
PG_locked
and
unique reference to page by page->buffers == NULL
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] 2.4 truncate locking
2002-04-17 15:09 [RFC] 2.4 truncate locking William Lee Irwin III
@ 2002-04-19 4:37 ` William Lee Irwin III
0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2002-04-19 4:37 UTC (permalink / raw)
To: linux-kernel; +Cc: viro
On Wed, Apr 17, 2002 at 08:09:12AM -0700, William Lee Irwin III wrote:
> I did some research on how truncate_inode_pages()'s locking works.
> Please feel free to clarify and/or correct my notes on the subject,
> which I'd like to turn into a docpatch soon.
>
> (9) exclusion from simultaneous manipulation of page->mapping
> pagemap_lru_lock
This is incorrect. It appears to be a combination of PG_locked and
pagecache_lock, where both are required for writing, and only one of
the two for reading.
Cheers,
Bill
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-19 4:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-17 15:09 [RFC] 2.4 truncate locking William Lee Irwin III
2002-04-19 4:37 ` William Lee Irwin III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox