is this a bug?

From: Jay
Date: Wed Mar 23 2011 - 20:47:11 EST


Assuming vmscan is doing its job to steal the last page from an
inode's namespace, so:

shrink_page_list -> remove_mapping -> __remove_from_page_cache:

void __remove_from_page_cache(struct page *page)



        radix_tree_delete(&mapping->page_tree, page->index);

        page->mapping = NULL;

>>> after removing the page from radix tree, it stuck at here.




then another process just calls iput_final to release the inode, so
iput_final -> evict:

static void evict(struct inode *inode)



        } else {

                if (inode->i_data.nrpages)

>>> here it finds that nrpage is 1, so go into truncate_inode_pages() but it won't find any page in the page tree.

                        truncate_inode_pages(&inode->i_data, 0);

>>> here nrpages remains 1.


>>> hit  BUG_ON(inode->i_data.nrpages) in end_writeback().




The root cause of this problem is that nrpages is accessed w/o holding
mapping->page_tree. The fix is also easy, just grab ->tree_lock inside

+       spin_lock_irq(&mapping->tree_lock);

-         if (mapping->nrpages == 0)

+        if (mapping->nrpages == 0) {

+               spin_unlock_irq(&mapping->tree_lock);


+        }

+        spin_unlock_irq(&mapping->tree_lock);

Am I missed anything?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at