Commit 3e884b46 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] add shmem_vm_writeback()

Give tmpfs its own shmem_vm_writeback (and empty shmem_writepages):
going through the default mpage_writepages is very wrong for tmpfs,
since that may write nearby pages while still mapped into mms, but
"writing" converts pages from tmpfs file identity to swap backing
identity: doing so while mapped breaks assumptions throughout e.g.  the
shared file is liable to disintegrate into private instances.
parent 83c69b86
......@@ -515,9 +515,8 @@ static int shmem_writepage(struct page * page)
if (!PageLocked(page))
BUG();
if (!(current->flags & PF_MEMALLOC))
return fail_writepage(page);
if (page_mapped(page))
BUG();
mapping = page->mapping;
index = page->index;
......@@ -551,6 +550,19 @@ static int shmem_writepage(struct page * page)
return fail_writepage(page);
}
static int shmem_writepages(struct address_space *mapping, struct writeback_control *wbc)
{
return 0;
}
static int shmem_vm_writeback(struct page *page, struct writeback_control *wbc)
{
clear_page_dirty(page);
if (shmem_writepage(page) < 0)
set_page_dirty(page);
return 0;
}
/*
* shmem_getpage_locked - either get the page from swap or allocate a new one
*
......@@ -1524,6 +1536,8 @@ static void destroy_inodecache(void)
static struct address_space_operations shmem_aops = {
.writepage = shmem_writepage,
.writepages = shmem_writepages,
.vm_writeback = shmem_vm_writeback,
.set_page_dirty = __set_page_dirty_nobuffers,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment