Request for export of truncate_complete_page
Subsystems (3)
Hello!
Can I ask for truncate_complete_page() to be exported?
For Lustre filesystem it is necessary to poke out pages in the middle of a file, but truncate_inode_pages() is not very suitable, because we poke those pages one at a time when locks on those pages are cancelled, but we cannot kill entire set of pages as a group, because there might be some other lock that covers a subset of those pages, so we still need to iterate through all of them, and while we are at it, it is easier to kill pages as we check them one by one.
include/linux/mm.h renamed from include/linux/mm.h.orig +2 -0
@@ -941,6 +941,8 @@ extern unsigned long do_brk(unsigned lon/* filemap.c */ extern unsigned long page_unuse (struct page *); +extern void truncate_complete_page (struct address_space *mapping, +struct page *page);extern void truncate_inode_pages (struct address_space *,loff_t );extern void truncate_inode_pages_range (struct address_space *,loff_t lstart,loff_t lend);
mm/truncate.c renamed from mm/truncate.c.orig +2 -1
@@ -33,7 +33,7 @@ static inline void truncate_partial_page* its lock, b) when a concurrent invalidate_inode_pages got there first and * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space. */ -static void +void truncate_complete_page (struct address_space *mapping,struct page *page) {if (page->mapping != mapping)
@@ -48,6 +48,7 @@ truncate_complete_page(struct address_spremove_from_page_cache (page);page_cache_release (page);/* pagecache ref */ } +EXPORT_SYMBOL (truncate_complete_page);/* * This is for invalidate_inode_pages(). That function can be called at
Bye,
Oleg
Quoted 12 lines · Oleg Drokin
Hello!
Can I ask for
truncate_complete_page()to be exported?
For Lustre filesystem it is necessary to poke out pages in the middle of a file, buttruncate_inode_pages()is not very suitable, because we poke those pages one at a time when locks on those pages are cancelled, but we cannot kill entire set of pages as a group, because there might be some other lock that covers a subset of those pages, so we still need to iterate through all of them, and while we are at it, it is easier to kill pages as we check them one by one.
Isn't truncate_inode_pages_range() suitable?
Quoted 1 line
+EXPORT_SYMBOL(truncate_complete_page);
_GPL would be nicer. Plus a comment to keep people from "cleaning it up".
Quoted 10 lines · Oleg Drokin
Hello!
Can I ask for
truncate_complete_page()to be exported?
For Lustre filesystem it is necessary to poke out pages in the middle of a file, buttruncate_inode_pages()is not very suitable, because we poke those pages one at a time when locks on those pages are cancelled, but we cannot kill entire set of pages as a group, because there might be some other lock that covers a subset of those pages, so we still need to iterate through all of them, and while we are at it, it is easier to kill pages as we check them one by one.
Truncating around inside a file is very fishy, so this would need a review of cour code. Once you submit the new lustre client we can discuss exporting this as _GPL, before we won't export it anyway.
Hello!
Quoted 9 lines · Andrew Morton
Quoted 8 lines
Can I ask for
truncate_complete_page()to be exported?
For Lustre filesystem it is necessary to poke out pages in the middle of a file, buttruncate_inode_pages()is not very suitable, because we poke those pages one at a time when locks on those pages are cancelled, but we cannot kill entire set of pages as a group, because there might be some other lock that covers a subset of those pages, so we still need to iterate through all of them, and while we are at it, it is easier to kill pages as we check them one by one.Isn't
truncate_inode_pages_range()suitable?
No, for the reason I specified above. We still walk entire region on page by page basis, checking that page is not covered by other locks that might warrant its exclusion from truncating, pushing writing of the page if it is still dirty and needs to be written (or clearing its dirty flag if it needs to be discarded).
So we have sort of reimplemented truncate_inode_pages_range() with extra logic specific to Lustre and calling truncate_inode_pages_range() for every page we want to get rid of is overkill.
Quoted 2 lines
Quoted 1 line
+EXPORT_SYMBOL(truncate_complete_page);
_GPLwould be nicer. Plus a comment to keep people from "cleaning it up".
Not that I mind if it is GPL or not, but currently truncate_complete_page() can be reimplemented with EXPORT_SYMBOL stuff only. Here's how:
static inline void ll_remove_from_page_cache(struct page *page)
{
struct address_space *mapping = page->mapping;
BUG_ON(!PageLocked(page));
write_lock_irq(&mapping->tree_lock);
radix_tree_delete(&mapping->page_tree, page->index);
page->mapping = NULL;
mapping->nrpages--;
atomic_add(-1, &nr_pagecache); // XXX pagecache_acct(-1);
write_unlock_irq(&mapping->tree_lock);
}static inline voidtruncate_complete_page(struct address_space *mapping, struct page *page)
{
if (page->mapping != mapping)
return;
if (PagePrivate(page))
page->mapping->a_ops->invalidatepage(page, 0);
clear_page_dirty(page);
ClearPageUptodate(page);
ClearPageMappedToDisk(page);
ll_remove_from_page_cache(page);
page_cache_release(page); /* pagecache ref */
}Bye,
Oleg