2007-09-10 09:39:18

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [0/35] intro

Hi, this patch set adds following functions

- page_inode(page) ... returns inode from page, (page->mapping->host)
- page_mapping_cache(page) ... returns addrees_space from page
- page_mapping_anon(page) ... return anon_vma from page
- page_is_pagecache(page) ... returns 1 if the page is page cache
- pagecache_consistent(page, mapping) ... returns if page_mapping_cache(page)
equals to mapping.

By adding aboves, this patch set removes all *direct* references to
page->mapping in usual codes. (compile tested with all mod config.)

I think this can improve VM/FS dependency and make things robust.
In addition, page->mapping is not a just address_space, now.
(And we can hide page->mapping details from moduled FSs.)

patch set is structured as
[1] ... new interface definition
[2] ... changes in /mm
[3] ... changes in /kernel and /fs
[4...] ... changes in each FSs. (most of patches are very small.)

Any comments are welcome.

Thanks,
-Kame


2007-09-10 09:41:09

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [1/35] interface definitions


- changes page->mapping from address_space* to unsigned long
- add page_mapping_anon() function.
- add linux/page-cache.h
- add page_inode() function
- add page_is_pagecache() function
- add pagecaceh_consisten() function for pagecache consistency test.
- expoterd swapper_space. inline function page_mapping() refers this.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
include/linux/fs.h | 1 +
include/linux/mm.h | 20 +++++++++++++++++---
include/linux/mm_types.h | 2 +-
include/linux/page-cache.h | 39 +++++++++++++++++++++++++++++++++++++++
mm/swap_state.c | 2 ++
5 files changed, 60 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/include/linux/page-cache.h
===================================================================
--- /dev/null
+++ test-2.6.23-rc4-mm1/include/linux/page-cache.h
@@ -0,0 +1,39 @@
+/*
+ * For interface definitions between memory management and file systems.
+ * - This file defines small interface functions for handling page cache.
+ */
+
+#ifndef _LINUX_PAGECACHE_H
+#define _LINUX_PAGECACHE_H
+
+#include <linux/mm.h>
+/* page_mapping_xxx() function is defined in mm.h */
+
+static inline int page_is_pagecache(struct page *page)
+{
+ if (!page->mapping || (page->mapping & PAGE_MAPPING_ANON))
+ return 0;
+ return 1;
+}
+
+/*
+ * Return an inode this page belongs to
+ */
+
+static inline struct inode *page_inode(struct page *page)
+{
+ if (!page_is_pagecache(page))
+ return NULL;
+ return page_mapping_cache(page)->host;
+}
+
+/*
+ * Test a page is a page-cache of an address_space.
+ */
+static inline int
+pagecache_consistent(struct page *page, struct address_space *as)
+{
+ return (page_mapping(page) == as);
+}
+
+#endif
Index: test-2.6.23-rc4-mm1/include/linux/fs.h
===================================================================
--- test-2.6.23-rc4-mm1.orig/include/linux/fs.h
+++ test-2.6.23-rc4-mm1/include/linux/fs.h
@@ -582,6 +582,7 @@ static inline int mapping_writably_mappe
return mapping->i_mmap_writable != 0;
}

+#include <linux/page-cache.h>
/*
* Use sequence counter to get consistent i_size on 32-bit processors.
*/
Index: test-2.6.23-rc4-mm1/include/linux/mm_types.h
===================================================================
--- test-2.6.23-rc4-mm1.orig/include/linux/mm_types.h
+++ test-2.6.23-rc4-mm1/include/linux/mm_types.h
@@ -48,7 +48,7 @@ struct page {
* indicates order in the buddy
* system if PG_buddy is set.
*/
- struct address_space *mapping; /* If low bit clear, points to
+ unsigned long mapping; /* If low bit clear, points to
* inode address_space, or NULL.
* If page mapped as anonymous
* memory, low bit is set, and
Index: test-2.6.23-rc4-mm1/include/linux/mm.h
===================================================================
--- test-2.6.23-rc4-mm1.orig/include/linux/mm.h
+++ test-2.6.23-rc4-mm1/include/linux/mm.h
@@ -563,7 +563,7 @@ void page_address_init(void);
extern struct address_space swapper_space;
static inline struct address_space *page_mapping(struct page *page)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = (struct address_space *)page->mapping;

VM_BUG_ON(PageSlab(page));
if (unlikely(PageSwapCache(page)))
@@ -579,7 +579,21 @@ static inline struct address_space *page

static inline int PageAnon(struct page *page)
{
- return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
+ return (page->mapping & PAGE_MAPPING_ANON) != 0;
+}
+
+static inline struct anon_vma *page_mapping_anon(struct page *page)
+{
+ if (PageAnon(page))
+ return (struct anon_vma *)(page->mapping - PAGE_MAPPING_ANON);
+ return NULL;
+}
+
+static inline struct address_space *page_mapping_cache(struct page *page)
+{
+ if (PageAnon(page))
+ return NULL;
+ return (struct address_space *) page->mapping;
}

/*
@@ -848,7 +862,7 @@ static inline pmd_t *pmd_alloc(struct mm
#define pte_lock_init(_page) do { \
spin_lock_init(__pte_lockptr(_page)); \
} while (0)
-#define pte_lock_deinit(page) ((page)->mapping = NULL)
+#define pte_lock_deinit(page) ((page)->mapping = 0)
#define pte_lockptr(mm, pmd) ({(void)(mm); __pte_lockptr(pmd_page(*(pmd)));})
#else
/*
Index: test-2.6.23-rc4-mm1/mm/swap_state.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/swap_state.c
+++ test-2.6.23-rc4-mm1/mm/swap_state.c
@@ -45,6 +45,8 @@ struct address_space swapper_space = {
.backing_dev_info = &swap_backing_dev_info,
};

+EXPORT_SYMBOL(swapper_space);
+
#define INC_CACHE_INFO(x) do { swap_cache_info.x++; } while (0)

static struct {

2007-09-10 09:42:41

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [2/35] changes in /mm

Changes page->mapping handling in /mm directory.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


---
mm/filemap.c | 24 +++++++++++++-----------
mm/memory.c | 6 ++++--
mm/migrate.c | 17 ++++++-----------
mm/page-writeback.c | 4 ++--
mm/rmap.c | 27 ++++++++++++---------------
mm/shmem.c | 4 ++--
mm/truncate.c | 15 ++++++++-------
7 files changed, 47 insertions(+), 50 deletions(-)

Index: test-2.6.23-rc4-mm1/mm/filemap.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/filemap.c
+++ test-2.6.23-rc4-mm1/mm/filemap.c
@@ -115,11 +115,11 @@ generic_file_direct_IO(int rw, struct ki
*/
void __remove_from_page_cache(struct page *page)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping(page);

mem_container_uncharge_page(page);
radix_tree_delete(&mapping->page_tree, page->index);
- page->mapping = NULL;
+ page->mapping = 0;
mapping->nrpages--;
__dec_zone_page_state(page, NR_FILE_PAGES);
BUG_ON(page_mapped(page));
@@ -127,7 +127,7 @@ void __remove_from_page_cache(struct pag

void remove_from_page_cache(struct page *page)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping(page);

BUG_ON(!PageLocked(page));

@@ -454,7 +454,7 @@ int add_to_page_cache(struct page *page,
if (!error) {
page_cache_get(page);
SetPageLocked(page);
- page->mapping = mapping;
+ page->mapping = (unsigned long)mapping;
page->index = offset;
mapping->nrpages++;
__inc_zone_page_state(page, NR_FILE_PAGES);
@@ -642,7 +642,7 @@ repeat:
__lock_page(page);

/* Has the page been truncated while we slept? */
- if (unlikely(page->mapping != mapping)) {
+ if (unlikely(!pagecache_consistent(page, mapping))) {
unlock_page(page);
page_cache_release(page);
goto repeat;
@@ -751,7 +751,8 @@ unsigned find_get_pages_contig(struct ad
ret = radix_tree_gang_lookup(&mapping->page_tree,
(void **)pages, index, nr_pages);
for (i = 0; i < ret; i++) {
- if (pages[i]->mapping == NULL || pages[i]->index != index)
+ if (!page_is_pagecache(pages[i]) ||
+ pages[i]->index != index)
break;

page_cache_get(pages[i]);
@@ -980,7 +981,7 @@ page_not_up_to_date:
lock_page(page);

/* Did it get truncated before we got the lock? */
- if (!page->mapping) {
+ if (!page_is_pagecache(page)) {
unlock_page(page);
page_cache_release(page);
continue;
@@ -1007,7 +1008,7 @@ readpage:
if (!PageUptodate(page)) {
lock_page(page);
if (!PageUptodate(page)) {
- if (page->mapping == NULL) {
+ if (!page_is_pagecache(page)) {
/*
* invalidate_inode_pages got it
*/
@@ -1546,7 +1547,7 @@ retry:
goto out;

lock_page(page);
- if (!page->mapping) {
+ if (page_is_pagecache(page)) {
unlock_page(page);
page_cache_release(page);
goto retry;
@@ -2113,7 +2114,8 @@ static ssize_t generic_perform_write_2co
* use a non-zeroing copy, but the APIs aren't too
* consistent.
*/
- if (unlikely(!page->mapping || PageUptodate(page))) {
+ if (unlikely(!page_is_pagecache(page) ||
+ PageUptodate(page))) {
unlock_page(page);
page_cache_release(page);
page_cache_release(src_page);
@@ -2556,7 +2558,7 @@ out:
*/
int try_to_release_page(struct page *page, gfp_t gfp_mask)
{
- struct address_space * const mapping = page->mapping;
+ struct address_space * const mapping = page_mapping(page);

BUG_ON(!PageLocked(page));
if (PageWriteback(page))
Index: test-2.6.23-rc4-mm1/mm/memory.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/memory.c
+++ test-2.6.23-rc4-mm1/mm/memory.c
@@ -650,7 +650,8 @@ static unsigned long zap_pte_range(struc
* unmap shared but keep private pages.
*/
if (details->check_mapping &&
- details->check_mapping != page->mapping)
+ !pagecache_consistent(page,
+ details->check_mapping))
continue;
/*
* Each page->index must be checked when
@@ -2309,7 +2310,8 @@ static int __do_fault(struct mm_struct *
* reworking page_mkwrite locking API, which
* is better done later.
*/
- if (!page->mapping) {
+ if (!page_is_pagecache(page) &&
+ !PageAnon(page)) {
ret = 0;
anon = 1; /* no anon but release vmf.page */
goto out;
Index: test-2.6.23-rc4-mm1/mm/migrate.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/migrate.c
+++ test-2.6.23-rc4-mm1/mm/migrate.c
@@ -223,17 +223,12 @@ static void remove_anon_migration_ptes(s
{
struct anon_vma *anon_vma;
struct vm_area_struct *vma;
- unsigned long mapping;
-
- mapping = (unsigned long)new->mapping;
-
- if (!mapping || (mapping & PAGE_MAPPING_ANON) == 0)
- return;
-
/*
* We hold the mmap_sem lock. So no need to call page_lock_anon_vma.
*/
- anon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);
+ anon_vma = page_mapping_anon(new);
+ if (!anon_vma)
+ return;
spin_lock(&anon_vma->lock);

list_for_each_entry(vma, &anon_vma->head, anon_vma_node)
@@ -388,7 +383,7 @@ static void migrate_page_copy(struct pag
ClearPageActive(page);
ClearPagePrivate(page);
set_page_private(page, 0);
- page->mapping = NULL;
+ page->mapping = 0;

/*
* If any waiters have accumulated on the new page then
@@ -601,7 +596,7 @@ static int move_to_new_page(struct page
if (!rc)
remove_migration_ptes(page, newpage);
else
- newpage->mapping = NULL;
+ newpage->mapping = 0;

unlock_page(newpage);

@@ -658,7 +653,7 @@ static int unmap_and_move(new_page_t get
* Calling try_to_unmap() against a page->mapping==NULL page is
* BUG. So handle it here.
*/
- if (!page->mapping)
+ if (!page_is_pagecache(page) && !PageAnon(page))
goto rcu_unlock;
/* Establish migration ptes or remove ptes */
try_to_unmap(page, 1);
Index: test-2.6.23-rc4-mm1/mm/page-writeback.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/page-writeback.c
+++ test-2.6.23-rc4-mm1/mm/page-writeback.c
@@ -650,7 +650,7 @@ retry:
*/
lock_page(page);

- if (unlikely(page->mapping != mapping)) {
+ if (unlikely(!pagecache_consistent(page, mapping))) {
unlock_page(page);
continue;
}
@@ -758,7 +758,7 @@ int do_writepages(struct address_space *
*/
int write_one_page(struct page *page, int wait)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping(page);
int ret = 0;
struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL,
Index: test-2.6.23-rc4-mm1/mm/rmap.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/rmap.c
+++ test-2.6.23-rc4-mm1/mm/rmap.c
@@ -160,16 +160,14 @@ void __init anon_vma_init(void)
static struct anon_vma *page_lock_anon_vma(struct page *page)
{
struct anon_vma *anon_vma;
- unsigned long anon_mapping;

rcu_read_lock();
- anon_mapping = (unsigned long) page->mapping;
- if (!(anon_mapping & PAGE_MAPPING_ANON))
- goto out;
+
if (!page_mapped(page))
goto out;
-
- anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
+ anon_vma = page_mapping_anon(page);
+ if (!anon_vma)
+ goto out;
spin_lock(&anon_vma->lock);
return anon_vma;
out:
@@ -208,12 +206,11 @@ vma_address(struct page *page, struct vm
unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
{
if (PageAnon(page)) {
- if ((void *)vma->anon_vma !=
- (void *)page->mapping - PAGE_MAPPING_ANON)
+ if (vma->anon_vma != page_mapping_anon(page))
return -EFAULT;
} else if (page->mapping && !(vma->vm_flags & VM_NONLINEAR)) {
if (!vma->vm_file ||
- vma->vm_file->f_mapping != page->mapping)
+ vma->vm_file->f_mapping != page_mapping_cache(page))
return -EFAULT;
} else
return -EFAULT;
@@ -344,7 +341,7 @@ static int page_referenced_file(struct p
struct mem_container *mem_cont)
{
unsigned int mapcount;
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
@@ -422,7 +419,7 @@ int page_referenced(struct page *page, i
else if (TestSetPageLocked(page))
referenced++;
else {
- if (page->mapping)
+ if (page_mapping_cache(page))
referenced +=
page_referenced_file(page, mem_cont);
unlock_page(page);
@@ -514,7 +511,7 @@ static void __page_set_anon_rmap(struct

BUG_ON(!anon_vma);
anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
- page->mapping = (struct address_space *) anon_vma;
+ page->mapping = (unsigned long) anon_vma;

page->index = linear_page_index(vma, address);

@@ -549,7 +546,7 @@ static void __page_check_anon_rmap(struc
*/
struct anon_vma *anon_vma = vma->anon_vma;
anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
- BUG_ON(page->mapping != (struct address_space *)anon_vma);
+ BUG_ON(page->mapping != (unsigned long)anon_vma);
BUG_ON(page->index != linear_page_index(vma, address));
#endif
}
@@ -649,7 +646,7 @@ void page_remove_rmap(struct page *page,
printk (KERN_EMERG " page pfn = %lx\n", page_to_pfn(page));
printk (KERN_EMERG " page->flags = %lx\n", page->flags);
printk (KERN_EMERG " page->count = %x\n", page_count(page));
- printk (KERN_EMERG " page->mapping = %p\n", page->mapping);
+ printk (KERN_EMERG " page->mapping = %p\n", (void*)page->mapping);
print_symbol (KERN_EMERG " vma->vm_ops = %s\n", (unsigned long)vma->vm_ops);
if (vma->vm_ops) {
print_symbol (KERN_EMERG " vma->vm_ops->nopage = %s\n", (unsigned long)vma->vm_ops->nopage);
@@ -894,7 +891,7 @@ static int try_to_unmap_anon(struct page
*/
static int try_to_unmap_file(struct page *page, int migration)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
Index: test-2.6.23-rc4-mm1/mm/shmem.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/shmem.c
+++ test-2.6.23-rc4-mm1/mm/shmem.c
@@ -917,7 +917,7 @@ static int shmem_writepage(struct page *
BUG_ON(!PageLocked(page));
BUG_ON(page_mapped(page));

- mapping = page->mapping;
+ mapping = page_mapping_cache(page);
index = page->index;
inode = mapping->host;
info = SHMEM_I(inode);
@@ -1454,7 +1454,7 @@ static const struct inode_operations shm
*/
static int shmem_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int error = shmem_getpage(inode, page->index, &page, SGP_CACHE, NULL);
unlock_page(page);
return error;
Index: test-2.6.23-rc4-mm1/mm/truncate.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/mm/truncate.c
+++ test-2.6.23-rc4-mm1/mm/truncate.c
@@ -37,7 +37,7 @@
void do_invalidatepage(struct page *page, unsigned long offset)
{
void (*invalidatepage)(struct page *, unsigned long);
- invalidatepage = page->mapping->a_ops->invalidatepage;
+ invalidatepage = page_mapping_cache(page)->a_ops->invalidatepage;
#ifdef CONFIG_BLOCK
if (!invalidatepage)
invalidatepage = block_invalidatepage;
@@ -70,7 +70,7 @@ static inline void truncate_partial_page
void cancel_dirty_page(struct page *page, unsigned int account_size)
{
if (TestClearPageDirty(page)) {
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
if (mapping && mapping_cap_account_dirty(mapping)) {
dec_zone_page_state(page, NR_FILE_DIRTY);
if (account_size)
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(cancel_dirty_page);
static void
truncate_complete_page(struct address_space *mapping, struct page *page)
{
- if (page->mapping != mapping)
+ if (!pagecache_consistent(page, mapping))
return;

cancel_dirty_page(page, PAGE_CACHE_SIZE);
@@ -120,7 +120,7 @@ invalidate_complete_page(struct address_
{
int ret;

- if (page->mapping != mapping)
+ if (!pagecache_consistent(page, mapping))
return 0;

if (PagePrivate(page) && !try_to_release_page(page, 0))
@@ -342,7 +342,7 @@ EXPORT_SYMBOL(invalidate_mapping_pages);
static int
invalidate_complete_page2(struct address_space *mapping, struct page *page)
{
- if (page->mapping != mapping)
+ if (!pagecache_consistent(page, mapping))
return 0;

if (PagePrivate(page) && !try_to_release_page(page, GFP_KERNEL))
@@ -367,7 +367,8 @@ static int do_launder_page(struct addres
{
if (!PageDirty(page))
return 0;
- if (page->mapping != mapping || mapping->a_ops->launder_page == NULL)
+ if (!pagecache_consistent(page, mapping) ||
+ mapping->a_ops->launder_page == NULL)
return 0;
return mapping->a_ops->launder_page(page);
}
@@ -403,7 +404,7 @@ int invalidate_inode_pages2_range(struct
pgoff_t page_index;

lock_page(page);
- if (page->mapping != mapping) {
+ if (!pagecache_consistent(page, mapping)) {
unlock_page(page);
continue;
}

2007-09-10 09:42:57

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [3/35] changes in generic parts

Changes page->mapping hanlding of generic fs routine and kexec.
(other than mm layer..)

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


---
fs/buffer.c | 43 ++++++++++++++++++++++---------------------
fs/libfs.c | 2 +-
fs/mpage.c | 13 +++++++------
kernel/kexec.c | 2 +-
4 files changed, 31 insertions(+), 29 deletions(-)

Index: test-2.6.23-rc4-mm1/kernel/kexec.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/kernel/kexec.c
+++ test-2.6.23-rc4-mm1/kernel/kexec.c
@@ -347,7 +347,7 @@ static struct page *kimage_alloc_pages(g
pages = alloc_pages(gfp_mask, order);
if (pages) {
unsigned int count, i;
- pages->mapping = NULL;
+ pages->mapping = 0;
set_page_private(pages, order);
count = 1 << order;
for (i = 0; i < count; i++)
Index: test-2.6.23-rc4-mm1/fs/buffer.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/buffer.c
+++ test-2.6.23-rc4-mm1/fs/buffer.c
@@ -467,7 +467,7 @@ static void end_buffer_async_write(struc
"I/O error on %s\n",
bdevname(bh->b_bdev, b));
}
- set_bit(AS_EIO, &page->mapping->flags);
+ set_bit(AS_EIO, &page_mapping_cache(page)->flags);
set_buffer_write_io_error(bh);
clear_buffer_uptodate(bh);
SetPageError(page);
@@ -678,7 +678,7 @@ void write_boundary_block(struct block_d
void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
{
struct address_space *mapping = inode->i_mapping;
- struct address_space *buffer_mapping = bh->b_page->mapping;
+ struct address_space *buffer_mapping = page_mapping_cache(bh->b_page);

mark_buffer_dirty(bh);
if (!mapping->assoc_mapping) {
@@ -713,7 +713,7 @@ static int __set_page_dirty(struct page
return 0;

write_lock_irq(&mapping->tree_lock);
- if (page->mapping) { /* Race with truncate? */
+ if (page_is_pagecache(page)) { /* Race with truncate? */
WARN_ON_ONCE(warn && !PageUptodate(page));

if (mapping_cap_account_dirty(mapping)) {
@@ -1202,7 +1202,8 @@ void __bforget(struct buffer_head *bh)
{
clear_buffer_dirty(bh);
if (!list_empty(&bh->b_assoc_buffers)) {
- struct address_space *buffer_mapping = bh->b_page->mapping;
+ struct address_space *buffer_mapping =
+ page_mapping_cache(bh->b_page);

spin_lock(&buffer_mapping->private_lock);
list_del_init(&bh->b_assoc_buffers);
@@ -1542,7 +1543,7 @@ void create_empty_buffers(struct page *p
} while (bh);
tail->b_this_page = head;

- spin_lock(&page->mapping->private_lock);
+ spin_lock(&page_mapping_cache(page)->private_lock);
if (PageUptodate(page) || PageDirty(page)) {
bh = head;
do {
@@ -1554,7 +1555,7 @@ void create_empty_buffers(struct page *p
} while (bh != head);
}
attach_page_buffers(page, head);
- spin_unlock(&page->mapping->private_lock);
+ spin_unlock(&page_mapping_cache(page)->private_lock);
}
EXPORT_SYMBOL(create_empty_buffers);

@@ -1761,7 +1762,7 @@ recover:
} while ((bh = bh->b_this_page) != head);
SetPageError(page);
BUG_ON(PageWriteback(page));
- mapping_set_error(page->mapping, err);
+ mapping_set_error(page_mapping_cache(page), err);
set_page_writeback(page);
do {
struct buffer_head *next = bh->b_this_page;
@@ -2075,7 +2076,7 @@ EXPORT_SYMBOL(generic_write_end);
*/
int block_read_full_page(struct page *page, get_block_t *get_block)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
sector_t iblock, lblock;
struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
unsigned int blocksize;
@@ -2296,7 +2297,7 @@ out:
int block_prepare_write(struct page *page, unsigned from, unsigned to,
get_block_t *get_block)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int err = __block_prepare_write(inode, page, from, to, get_block);
if (err)
ClearPageUptodate(page);
@@ -2305,7 +2306,7 @@ int block_prepare_write(struct page *pag

int block_commit_write(struct page *page, unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
__block_commit_write(inode,page,from,to);
return 0;
}
@@ -2313,7 +2314,7 @@ int block_commit_write(struct page *page
int generic_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
__block_commit_write(inode,page,from,to);
/*
@@ -2353,7 +2354,7 @@ block_page_mkwrite(struct vm_area_struct

lock_page(page);
size = i_size_read(inode);
- if ((page->mapping != inode->i_mapping) ||
+ if ((!pagecache_consistent(page, inode->i_mapping)) ||
(page_offset(page) > size)) {
/* page got truncated out from underneath us */
goto out_unlock;
@@ -2391,7 +2392,7 @@ static void end_buffer_read_nobh(struct
int nobh_prepare_write(struct page *page, unsigned from, unsigned to,
get_block_t *get_block)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
const unsigned blkbits = inode->i_blkbits;
const unsigned blocksize = 1 << blkbits;
struct buffer_head *head, *bh;
@@ -2505,7 +2506,7 @@ failed:
* the handling of potential IO errors during writeout would be hard
* (could try doing synchronous writeout, but what if that fails too?)
*/
- spin_lock(&page->mapping->private_lock);
+ spin_lock(&page_mapping_cache(page)->private_lock);
bh = head;
block_start = 0;
do {
@@ -2535,7 +2536,7 @@ next:
bh = bh->b_this_page;
} while (bh != head);
attach_page_buffers(page, head);
- spin_unlock(&page->mapping->private_lock);
+ spin_unlock(&page_mapping_cache(page)->private_lock);

return ret;
}
@@ -2548,7 +2549,7 @@ EXPORT_SYMBOL(nobh_prepare_write);
int nobh_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;

if (page_has_buffers(page))
@@ -2572,7 +2573,7 @@ EXPORT_SYMBOL(nobh_commit_write);
int nobh_writepage(struct page *page, get_block_t *get_block,
struct writeback_control *wbc)
{
- struct inode * const inode = page->mapping->host;
+ struct inode * const inode = page_inode(page);
loff_t i_size = i_size_read(inode);
const pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
unsigned offset;
@@ -2737,7 +2738,7 @@ out:
int block_write_full_page(struct page *page, get_block_t *get_block,
struct writeback_control *wbc)
{
- struct inode * const inode = page->mapping->host;
+ struct inode * const inode = page_inode(page);
loff_t i_size = i_size_read(inode);
const pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
unsigned offset;
@@ -2966,8 +2967,8 @@ drop_buffers(struct page *page, struct b

bh = head;
do {
- if (buffer_write_io_error(bh) && page->mapping)
- set_bit(AS_EIO, &page->mapping->flags);
+ if (buffer_write_io_error(bh) && page_is_pagecache(page))
+ set_bit(AS_EIO, &page_mapping_cache(page)->flags);
if (buffer_busy(bh))
goto failed;
bh = bh->b_this_page;
@@ -2989,7 +2990,7 @@ failed:

int try_to_free_buffers(struct page *page)
{
- struct address_space * const mapping = page->mapping;
+ struct address_space * const mapping = page_mapping_cache(page);
struct buffer_head *buffers_to_free = NULL;
int ret = 0;

Index: test-2.6.23-rc4-mm1/fs/libfs.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/libfs.c
+++ test-2.6.23-rc4-mm1/fs/libfs.c
@@ -374,7 +374,7 @@ int simple_write_begin(struct file *file
static int simple_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;

if (!PageUptodate(page))
Index: test-2.6.23-rc4-mm1/fs/mpage.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/mpage.c
+++ test-2.6.23-rc4-mm1/fs/mpage.c
@@ -81,8 +81,9 @@ static int mpage_end_io_write(struct bio

if (!uptodate){
SetPageError(page);
- if (page->mapping)
- set_bit(AS_EIO, &page->mapping->flags);
+ if (page_is_pagecache(page))
+ set_bit(AS_EIO,
+ &page_mapping_cache(page)->flags);
}
end_page_writeback(page);
} while (bvec >= bio->bi_io_vec);
@@ -133,7 +134,7 @@ mpage_alloc(struct block_device *bdev,
static void
map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct buffer_head *page_bh, *head;
int block = 0;

@@ -177,7 +178,7 @@ do_mpage_readpage(struct bio *bio, struc
sector_t *last_block_in_bio, struct buffer_head *map_bh,
unsigned long *first_logical_block, get_block_t get_block)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
const unsigned blkbits = inode->i_blkbits;
const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits;
const unsigned blocksize = 1 << blkbits;
@@ -460,8 +461,8 @@ static int __mpage_writepage(struct page
{
struct mpage_data *mpd = data;
struct bio *bio = mpd->bio;
- struct address_space *mapping = page->mapping;
- struct inode *inode = page->mapping->host;
+ struct address_space *mapping = page_mapping_cache(page);
+ struct inode *inode = page_inode(page);
const unsigned blkbits = inode->i_blkbits;
unsigned long end_index;
const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits;

2007-09-10 09:45:14

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [4/35] changes in AFFS

use page_inode() in AFFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/affs/file.c | 4 ++--
fs/affs/symlink.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/affs/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/affs/file.c
+++ test-2.6.23-rc4-mm1/fs/affs/file.c
@@ -485,7 +485,7 @@ affs_getemptyblk_ino(struct inode *inode
static int
affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct super_block *sb = inode->i_sb;
struct buffer_head *bh;
char *data;
@@ -593,7 +593,7 @@ out:
static int
affs_readpage_ofs(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
u32 to;
int err;

Index: test-2.6.23-rc4-mm1/fs/affs/symlink.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/affs/symlink.c
+++ test-2.6.23-rc4-mm1/fs/affs/symlink.c
@@ -13,7 +13,7 @@
static int affs_symlink_readpage(struct file *file, struct page *page)
{
struct buffer_head *bh;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
char *link = kmap(page);
struct slink_front *lf;
int err;

2007-09-10 09:47:24

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [5/35] changes in AFS

Use page->mapping interface in AFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/afs/file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/afs/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/afs/file.c
+++ test-2.6.23-rc4-mm1/fs/afs/file.c
@@ -145,7 +145,7 @@ static int afs_readpage(struct file *fil
off_t offset;
int ret;

- inode = page->mapping->host;
+ inode = page_inode(page);

ASSERT(file != NULL);
key = file->private_data;
@@ -253,8 +253,7 @@ static void afs_invalidatepage(struct pa

ret = 0;
if (!PageWriteback(page))
- ret = page->mapping->a_ops->releasepage(page,
- 0);
+ ret = page_mapping_cache(page)->a_ops->releasepage(page, 0);
/* possibly should BUG_ON(!ret); - neilb */
}
}
@@ -277,7 +276,7 @@ static int afs_launder_page(struct page
*/
static int afs_releasepage(struct page *page, gfp_t gfp_flags)
{
- struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
+ struct afs_vnode *vnode = AFS_FS_I(page_inode(page));
struct afs_writeback *wb;

_enter("{{%x:%u}[%lu],%lx},%x",

2007-09-10 09:48:50

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [6/35] changes in CIFS

Change page->mapping handling in CIFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


---
fs/cifs/file.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/cifs/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/cifs/file.c
+++ test-2.6.23-rc4-mm1/fs/cifs/file.c
@@ -1056,7 +1056,7 @@ struct cifsFileInfo *find_writable_file(

static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
char *write_data;
int rc = -EFAULT;
@@ -1069,7 +1069,7 @@ static int cifs_partialpagewrite(struct
if (!mapping || !mapping->host)
return -EFAULT;

- inode = page->mapping->host;
+ inode = page_inode(page);
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;

@@ -1209,7 +1209,7 @@ retry:
else if (TestSetPageLocked(page))
break;

- if (unlikely(page->mapping != mapping)) {
+ if (unlikely(pagecache_consistent(page, mapping))) {
unlock_page(page);
break;
}
@@ -1371,7 +1371,7 @@ static int cifs_commit_write(struct file
{
int xid;
int rc = 0;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
char *page_data;

@@ -1973,7 +1973,7 @@ static int cifs_prepare_write(struct fil
}

offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
- i_size = i_size_read(page->mapping->host);
+ i_size = i_size_read(page_inode(page));

if ((offset >= i_size) ||
((from == 0) && (offset + to) >= i_size)) {

2007-09-10 09:49:51

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [7/35] changes in CODA

Change page->mapping handling in CODA

Singed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/coda/symlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/coda/symlink.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/coda/symlink.c
+++ test-2.6.23-rc4-mm1/fs/coda/symlink.c
@@ -23,7 +23,7 @@

static int coda_symlink_filler(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int error;
struct coda_inode_info *cii;
unsigned int len = PAGE_SIZE;

2007-09-10 09:52:18

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [8/35] changes in CRAMFS

patches for handling page->mapping in CRAMFS.

Signed-off-by : KAMEZAWA Hiroyuki <[email protected]>

---
fs/cramfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/cramfs/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/cramfs/inode.c
+++ test-2.6.23-rc4-mm1/fs/cramfs/inode.c
@@ -469,7 +469,7 @@ static struct dentry * cramfs_lookup(str

static int cramfs_readpage(struct file *file, struct page * page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
u32 maxblock, bytes_filled;
void *pgdata;


2007-09-10 09:53:50

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [9/35] changes in ECRYPTFS

Change page->mapping handling in ecryptfs

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


---
fs/ecryptfs/crypto.c | 9 ++++-----
fs/ecryptfs/mmap.c | 14 +++++++-------
2 files changed, 11 insertions(+), 12 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ecryptfs/crypto.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ecryptfs/crypto.c
+++ test-2.6.23-rc4-mm1/fs/ecryptfs/crypto.c
@@ -504,8 +504,8 @@ int ecryptfs_encrypt_page(struct ecryptf
#define ECRYPTFS_PAGE_STATE_WRITTEN 3
int page_state;

- lower_inode = ecryptfs_inode_to_lower(ctx->page->mapping->host);
- inode_info = ecryptfs_inode_to_private(ctx->page->mapping->host);
+ lower_inode = ecryptfs_inode_to_lower(page_inode(ctx->page));
+ inode_info = ecryptfs_inode_to_private(page_inode(ctx->page));
crypt_stat = &inode_info->crypt_stat;
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_copy_page_to_lower(ctx->page, lower_inode,
@@ -636,9 +636,8 @@ int ecryptfs_decrypt_page(struct file *f
int num_extents_per_page;
int page_state;

- crypt_stat = &(ecryptfs_inode_to_private(
- page->mapping->host)->crypt_stat);
- lower_inode = ecryptfs_inode_to_lower(page->mapping->host);
+ crypt_stat = &(ecryptfs_inode_to_private(page_inode(page))->crypt_stat);
+ lower_inode = ecryptfs_inode_to_lower(page_inode(page));
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_do_readpage(file, page, page->index);
if (rc)
Index: test-2.6.23-rc4-mm1/fs/ecryptfs/mmap.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ecryptfs/mmap.c
+++ test-2.6.23-rc4-mm1/fs/ecryptfs/mmap.c
@@ -363,7 +363,7 @@ out:
*/
static int fill_zeros_to_end_of_page(struct page *page, unsigned int to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int end_byte_in_page;

if ((i_size_read(inode) / PAGE_CACHE_SIZE) != page->index)
@@ -411,7 +411,7 @@ static int ecryptfs_prepare_write(struct
if (page->index != 0) {
loff_t end_of_prev_pg_pos = page_offset(page) - 1;

- if (end_of_prev_pg_pos > i_size_read(page->mapping->host)) {
+ if (end_of_prev_pg_pos > i_size_read(page_inode(page))) {
rc = ecryptfs_truncate(file->f_path.dentry,
end_of_prev_pg_pos);
if (rc) {
@@ -421,7 +421,7 @@ static int ecryptfs_prepare_write(struct
goto out;
}
}
- if (end_of_prev_pg_pos + 1 > i_size_read(page->mapping->host))
+ if (end_of_prev_pg_pos + 1 > i_size_read(page_inode(page)))
zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
}
out:
@@ -683,7 +683,7 @@ static int ecryptfs_commit_write(struct
struct ecryptfs_crypt_stat *crypt_stat;
int rc;

- inode = page->mapping->host;
+ inode = page_inode(page);
lower_inode = ecryptfs_inode_to_lower(inode);
lower_file = ecryptfs_file_to_lower(file);
mutex_lock(&lower_inode->i_mutex);
@@ -805,7 +805,7 @@ static void ecryptfs_sync_page(struct pa
struct inode *lower_inode;
struct page *lower_page;

- inode = page->mapping->host;
+ inode = page_inode(page);
lower_inode = ecryptfs_inode_to_lower(inode);
/* NOTE: Recently swapped with grab_cache_page(), since
* sync_page() just makes sure that pending I/O gets done. */
@@ -814,8 +814,8 @@ static void ecryptfs_sync_page(struct pa
ecryptfs_printk(KERN_DEBUG, "find_lock_page failed\n");
return;
}
- if (lower_page->mapping->a_ops->sync_page)
- lower_page->mapping->a_ops->sync_page(lower_page);
+ if (page_mapping_cache(lower_page)->a_ops->sync_page)
+ page_mapping_cache(lower_page)->a_ops->sync_page(lower_page);
ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16x]\n",
lower_page->index);
unlock_page(lower_page);

2007-09-10 09:55:00

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [10/35] changes in EFS


Change page->mapping handling in EFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


Index: test-2.6.23-rc4-mm1/fs/efs/symlink.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/efs/symlink.c
+++ test-2.6.23-rc4-mm1/fs/efs/symlink.c
@@ -16,7 +16,7 @@ static int efs_symlink_readpage(struct f
{
char *link = kmap(page);
struct buffer_head * bh;
- struct inode * inode = page->mapping->host;
+ struct inode * inode = page_inode(page);
efs_block_t size = inode->i_size;
int err;


2007-09-10 09:56:34

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [11/35] changes in EXT2

Change page->mapping handling in ext2

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ext2/dir.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ext2/dir.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ext2/dir.c
+++ test-2.6.23-rc4-mm1/fs/ext2/dir.c
@@ -65,7 +65,7 @@ ext2_last_byte(struct inode *inode, unsi

static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
int err = 0;

@@ -87,7 +87,7 @@ static int ext2_commit_chunk(struct page

static void ext2_check_page(struct page *page)
{
- struct inode *dir = page->mapping->host;
+ struct inode *dir = page_inode(page);
struct super_block *sb = dir->i_sb;
unsigned chunk_size = ext2_chunk_size(dir);
char *kaddr = page_address(page);
@@ -429,7 +429,7 @@ void ext2_set_link(struct inode *dir, st
int err;

lock_page(page);
- err = __ext2_write_begin(NULL, page->mapping, pos, len,
+ err = __ext2_write_begin(NULL, page_mapping_cache(page), pos, len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err);
de->inode = cpu_to_le32(inode->i_ino);
@@ -512,8 +512,8 @@ int ext2_add_link (struct dentry *dentry
got_it:
pos = page_offset(page) +
(char*)de - (char*)page_address(page);
- err = __ext2_write_begin(NULL, page->mapping, pos, rec_len, 0,
- &page, NULL);
+ err = __ext2_write_begin(NULL, page_mapping_cache(page), pos, rec_len,
+ 0, &page, NULL);
if (err)
goto out_unlock;
if (de->inode) {
@@ -546,7 +546,7 @@ out_unlock:
*/
int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *inode = mapping->host;
char *kaddr = page_address(page);
unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1);
@@ -570,8 +570,8 @@ int ext2_delete_entry (struct ext2_dir_e
from = (char*)pde - (char*)page_address(page);
pos = page_offset(page) + from;
lock_page(page);
- err = __ext2_write_begin(NULL, page->mapping, pos, to - from, 0,
- &page, NULL);
+ err = __ext2_write_begin(NULL, page_mapping_cache(page), pos,
+ to - from, 0, &page, NULL);
BUG_ON(err);
if (pde)
pde->rec_len = cpu_to_le16(to - from);
@@ -600,8 +600,8 @@ int ext2_make_empty(struct inode *inode,
if (!page)
return -ENOMEM;

- err = __ext2_write_begin(NULL, page->mapping, 0, chunk_size, 0,
- &page, NULL);
+ err = __ext2_write_begin(NULL, page_mapping_cache(page), 0, chunk_size,
+ 0, &page, NULL);
if (err) {
unlock_page(page);
goto fail;

2007-09-10 09:58:03

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [12/35] changes in EXT3

Change page->mapping handling in EXT3

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ext3/inode.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ext3/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ext3/inode.c
+++ test-2.6.23-rc4-mm1/fs/ext3/inode.c
@@ -1484,7 +1484,7 @@ static int journal_dirty_data_fn(handle_
static int ext3_ordered_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct buffer_head *page_bufs;
handle_t *handle = NULL;
int ret = 0;
@@ -1550,7 +1550,7 @@ out_fail:
static int ext3_writeback_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
handle_t *handle = NULL;
int ret = 0;
int err;
@@ -1583,7 +1583,7 @@ out_fail:
static int ext3_journalled_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
handle_t *handle = NULL;
int ret = 0;
int err;
@@ -1653,7 +1653,7 @@ ext3_readpages(struct file *file, struct

static void ext3_invalidatepage(struct page *page, unsigned long offset)
{
- journal_t *journal = EXT3_JOURNAL(page->mapping->host);
+ journal_t *journal = EXT3_JOURNAL(page_inode(page));

/*
* If it's a full truncate we just forget about the pending dirtying
@@ -1666,7 +1666,7 @@ static void ext3_invalidatepage(struct p

static int ext3_releasepage(struct page *page, gfp_t wait)
{
- journal_t *journal = EXT3_JOURNAL(page->mapping->host);
+ journal_t *journal = EXT3_JOURNAL(page_inode(page));

WARN_ON(PageChecked(page));
if (!page_has_buffers(page))

2007-09-10 09:59:02

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [13/35] changes in EXT4

Changes page->mapping handling in EXT4

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ext4/inode.c | 10 +++++-----
fs/ext4/writeback.c | 24 ++++++++++++------------
2 files changed, 17 insertions(+), 17 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ext4/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ext4/inode.c
+++ test-2.6.23-rc4-mm1/fs/ext4/inode.c
@@ -1482,7 +1482,7 @@ static int jbd2_journal_dirty_data_fn(ha
static int ext4_ordered_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct buffer_head *page_bufs;
handle_t *handle = NULL;
int ret = 0;
@@ -1548,7 +1548,7 @@ out_fail:
static int ext4_writeback_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
handle_t *handle = NULL;
int ret = 0;
int err;
@@ -1581,7 +1581,7 @@ out_fail:
static int ext4_journalled_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
handle_t *handle = NULL;
int ret = 0;
int err;
@@ -1651,7 +1651,7 @@ ext4_readpages(struct file *file, struct

static void ext4_invalidatepage(struct page *page, unsigned long offset)
{
- journal_t *journal = EXT4_JOURNAL(page->mapping->host);
+ journal_t *journal = EXT4_JOURNAL(page_inode(page));

/*
* If it's a full truncate we just forget about the pending dirtying
@@ -1664,7 +1664,7 @@ static void ext4_invalidatepage(struct p

static int ext4_releasepage(struct page *page, gfp_t wait)
{
- journal_t *journal = EXT4_JOURNAL(page->mapping->host);
+ journal_t *journal = EXT4_JOURNAL(page_inode(page));

WARN_ON(PageChecked(page));
if (!page_has_buffers(page))
Index: test-2.6.23-rc4-mm1/fs/ext4/writeback.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ext4/writeback.c
+++ test-2.6.23-rc4-mm1/fs/ext4/writeback.c
@@ -175,7 +175,7 @@ static struct bio *ext4_wb_bio_submit(st

int inline ext4_wb_reserve_space_page(struct page *page, int blocks)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int total, mdb, err;

wb_debug("reserve %d blocks for page %lu from inode %lu\n",
@@ -263,7 +263,7 @@ static inline int ext4_wb_drop_page_rese
* reserved blocks. we could release reserved blocks right
* now, but I'd prefer to make this once per several blocks */
wb_debug("drop reservation from page %lu from inode %lu\n",
- page->index, page->mapping->host->i_ino);
+ page->index, page_inode(page)->i_ino);
BUG_ON(!PageBooked(page));
ClearPageBooked(page);
return 0;
@@ -711,7 +711,7 @@ int ext4_wb_writepages(struct address_sp
if (wbc->sync_mode != WB_SYNC_NONE)
wait_on_page_writeback(page);

- if (page->mapping != mapping) {
+ if (pagecache_consistent(page, mapping)) {
unlock_page(page);
continue;
}
@@ -853,12 +853,12 @@ static void ext4_wb_clear_page(struct pa
int ext4_wb_prepare_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct buffer_head bh, *bhw = &bh;
int err = 0;

wb_debug("prepare page %lu (%u-%u) for inode %lu\n",
- page->index, from, to, page->mapping->host->i_ino);
+ page->index, from, to, page_inode(page)->i_ino);

/* if page is uptodate this means that ->prepare_write() has
* been called on page before and page is mapped to disk or
@@ -912,7 +912,7 @@ int ext4_wb_commit_write(struct file *fi
unsigned from, unsigned to)
{
loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int err = 0;

wb_debug("commit page %lu (%u-%u) for inode %lu\n",
@@ -952,7 +952,7 @@ int ext4_wb_commit_write(struct file *fi
int ext4_wb_write_single_page(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct ext4_wb_control wc;
int err;

@@ -964,7 +964,7 @@ int ext4_wb_write_single_page(struct pag
atomic_inc(&EXT4_SB(inode->i_sb)->s_wb_collisions_sp);
#endif

- ext4_wb_init_control(&wc, page->mapping);
+ ext4_wb_init_control(&wc, page_mapping_cache(page));

BUG_ON(PageWriteback(page));
set_page_writeback(page);
@@ -988,7 +988,7 @@ int ext4_wb_write_single_page(struct pag

int ext4_wb_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t i_size = i_size_read(inode);
pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
unsigned offset;
@@ -1002,7 +1002,7 @@ int ext4_wb_writepage(struct page *page,
* hasn't space on a disk yet, leave it for that thread
*/
#if 1
- if (atomic_read(&EXT4_I(page->mapping->host)->i_wb_writers)
+ if (atomic_read(&EXT4_I(page_inode(page))->i_wb_writers)
&& !PageMappedToDisk(page)) {
__set_page_dirty_nobuffers(page);
unlock_page(page);
@@ -1054,7 +1054,7 @@ int ext4_wb_releasepage(struct page *pag
wb_debug("release %sM%sR page %lu from inode %lu (wait %d)\n",
PageMappedToDisk(page) ? "" : "!",
PageBooked(page) ? "" : "!",
- page->index, page->mapping->host->i_ino, wait);
+ page->index, page_inode(page)->i_ino, wait);

if (PageWriteback(page))
return 0;
@@ -1066,7 +1066,7 @@ int ext4_wb_releasepage(struct page *pag

void ext4_wb_invalidatepage(struct page *page, unsigned long offset)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int ret = 0;

/* ->invalidatepage() is called when page is marked Private.

2007-09-10 10:01:20

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [14/35] changes in freevxfs

Changes page->mapping handling in freevxfs.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/freevxfs/vxfs_immed.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/freevxfs/vxfs_immed.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/freevxfs/vxfs_immed.c
+++ test-2.6.23-rc4-mm1/fs/freevxfs/vxfs_immed.c
@@ -98,7 +98,7 @@ vxfs_immed_follow_link(struct dentry *dp
static int
vxfs_immed_readpage(struct file *fp, struct page *pp)
{
- struct vxfs_inode_info *vip = VXFS_INO(pp->mapping->host);
+ struct vxfs_inode_info *vip = VXFS_INO(page_inode(pp));
u_int64_t offset = (u_int64_t)pp->index << PAGE_CACHE_SHIFT;
caddr_t kaddr;


2007-09-10 10:04:56

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [15/35] changes in FUSE

Changes page->mapping handling in FUSE

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
---
fs/fuse/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/fuse/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/fuse/file.c
+++ test-2.6.23-rc4-mm1/fs/fuse/file.c
@@ -310,7 +310,7 @@ static size_t fuse_send_read(struct fuse

static int fuse_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_req *req;
int err;
@@ -342,7 +342,7 @@ static void fuse_readpages_end(struct fu
{
int i;

- fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */
+ fuse_invalidate_attr(page_inode(req->pages[0])); /* atime changed */

for (i = 0; i < req->num_pages; i++) {
struct page *page = req->pages[i];

2007-09-10 10:05:24

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [16/35] changes in GFS2

Changes page->mapping handling in GFS2

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/gfs2/log.c | 4 ++--
fs/gfs2/lops.c | 2 +-
fs/gfs2/meta_io.c | 2 +-
fs/gfs2/ops_address.c | 16 ++++++++--------
4 files changed, 12 insertions(+), 12 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/gfs2/log.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/gfs2/log.c
+++ test-2.6.23-rc4-mm1/fs/gfs2/log.c
@@ -229,8 +229,8 @@ static void gfs2_ail2_empty_one(struct g
list_del(&bd->bd_ail_st_list);
list_del(&bd->bd_ail_gl_list);
atomic_dec(&bd->bd_gl->gl_ail_count);
- if (bd->bd_bh->b_page->mapping) {
- bh_ip = GFS2_I(bd->bd_bh->b_page->mapping->host);
+ if (page_is_pagecache(bd->bd_bh->b_page)) {
+ bh_ip = GFS2_I(page_inode(bd->bd_bh->b_page));
gfs2_meta_cache_flush(bh_ip);
}
brelse(bd->bd_bh);
Index: test-2.6.23-rc4-mm1/fs/gfs2/lops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/gfs2/lops.c
+++ test-2.6.23-rc4-mm1/fs/gfs2/lops.c
@@ -473,7 +473,7 @@ static void databuf_lo_add(struct gfs2_s
{
struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
struct gfs2_trans *tr = current->journal_info;
- struct address_space *mapping = bd->bd_bh->b_page->mapping;
+ struct address_space *mapping = page_mapping_cache(bd->bd_bh->b_page);
struct gfs2_inode *ip = GFS2_I(mapping->host);

gfs2_log_lock(sdp);
Index: test-2.6.23-rc4-mm1/fs/gfs2/meta_io.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/gfs2/meta_io.c
+++ test-2.6.23-rc4-mm1/fs/gfs2/meta_io.c
@@ -388,7 +388,7 @@ void gfs2_meta_wipe(struct gfs2_inode *i
if (test_clear_buffer_pinned(bh)) {
struct gfs2_trans *tr = current->journal_info;
struct gfs2_inode *bh_ip =
- GFS2_I(bh->b_page->mapping->host);
+ GFS2_I(page_inode(bh->b_page));

gfs2_log_lock(sdp);
list_del_init(&bd->bd_le.le_list);
Index: test-2.6.23-rc4-mm1/fs/gfs2/ops_address.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/gfs2/ops_address.c
+++ test-2.6.23-rc4-mm1/fs/gfs2/ops_address.c
@@ -114,7 +114,7 @@ static int gfs2_get_block_direct(struct

static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
loff_t i_size = i_size_read(inode);
@@ -133,7 +133,7 @@ static int gfs2_writepage(struct page *p
/* Is the page fully outside i_size? (truncate in progress) */
offset = i_size & (PAGE_CACHE_SIZE-1);
if (page->index > end_index || (page->index == end_index && !offset)) {
- page->mapping->a_ops->invalidatepage(page, 0);
+ page_mapping_cache(page)->a_ops->invalidatepage(page, 0);
unlock_page(page);
return 0; /* don't care */
}
@@ -241,8 +241,8 @@ static int stuffed_readpage(struct gfs2_

static int gfs2_readpage(struct file *file, struct page *page)
{
- struct gfs2_inode *ip = GFS2_I(page->mapping->host);
- struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
+ struct gfs2_inode *ip = GFS2_I(page_inode(page));
+ struct gfs2_sbd *sdp = GFS2_SB(page_inode(page));
struct gfs2_file *gf = NULL;
struct gfs2_holder gh;
int error;
@@ -560,7 +560,7 @@ static int gfs2_write_end(struct file *f
loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
struct buffer_head *dibh;
@@ -624,8 +624,8 @@ failed:

static int gfs2_set_page_dirty(struct page *page)
{
- struct gfs2_inode *ip = GFS2_I(page->mapping->host);
- struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
+ struct gfs2_inode *ip = GFS2_I(page_inode(page));
+ struct gfs2_sbd *sdp = GFS2_SB(page_inode(page));

if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
SetPageChecked(page);
@@ -746,7 +746,7 @@ out:

int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
{
- struct inode *aspace = page->mapping->host;
+ struct inode *aspace = page_inode(page);
struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info;
struct buffer_head *bh, *head;
struct gfs2_bufdata *bd;

2007-09-10 10:06:24

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [17/35] changes in HFS

Changes page->mapping handling in HFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/hfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/hfs/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/hfs/inode.c
+++ test-2.6.23-rc4-mm1/fs/hfs/inode.c
@@ -52,7 +52,7 @@ static sector_t hfs_bmap(struct address_

static int hfs_releasepage(struct page *page, gfp_t mask)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct super_block *sb = inode->i_sb;
struct hfs_btree *tree;
struct hfs_bnode *node;

2007-09-10 10:08:59

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [18/35] changes in HFSPLUS

Changes page->mapping handling in HFSPLUS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/hfsplus/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/hfsplus/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/hfsplus/inode.c
+++ test-2.6.23-rc4-mm1/fs/hfsplus/inode.c
@@ -44,7 +44,7 @@ static sector_t hfsplus_bmap(struct addr

static int hfsplus_releasepage(struct page *page, gfp_t mask)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct super_block *sb = inode->i_sb;
struct hfs_btree *tree;
struct hfs_bnode *node;

2007-09-10 10:09:29

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [19/35] changes in HPFS

Changes page->mapping handling in HPFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/hpfs/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/hpfs/namei.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/hpfs/namei.c
+++ test-2.6.23-rc4-mm1/fs/hpfs/namei.c
@@ -511,7 +511,7 @@ out:
static int hpfs_symlink_readpage(struct file *file, struct page *page)
{
char *link = kmap(page);
- struct inode *i = page->mapping->host;
+ struct inode *i = page_inode(page);
struct fnode *fnode;
struct buffer_head *bh;
int err;

2007-09-10 10:12:29

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [20/35] changes in ISOFS

Changes page->mapping handling in ISOFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/isofs/rock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/isofs/rock.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/isofs/rock.c
+++ test-2.6.23-rc4-mm1/fs/isofs/rock.c
@@ -640,7 +640,7 @@ int parse_rock_ridge_inode(struct iso_di
*/
static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct iso_inode_info *ei = ISOFS_I(inode);
char *link = kmap(page);
unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);

2007-09-10 10:13:35

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [21/35] changes in JBD


Changes page->mapping handling in JBD

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/jbd/journal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/jbd/journal.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/jbd/journal.c
+++ test-2.6.23-rc4-mm1/fs/jbd/journal.c
@@ -1822,7 +1822,7 @@ repeat:
jh = bh2jh(bh);
} else {
if (!(atomic_read(&bh->b_count) > 0 ||
- (bh->b_page && bh->b_page->mapping))) {
+ (bh->b_page && page_mapping_cache(bh->b_page)))) {
printk(KERN_EMERG "%s: bh->b_count=%d\n",
__FUNCTION__, atomic_read(&bh->b_count));
printk(KERN_EMERG "%s: bh->b_page=%p\n",
@@ -1830,7 +1830,7 @@ repeat:
if (bh->b_page)
printk(KERN_EMERG "%s: "
"bh->b_page->mapping=%p\n",
- __FUNCTION__, bh->b_page->mapping);
+ __FUNCTION__, page_mapping_cache(bh->b_page));
}

if (!new_jh) {

2007-09-10 10:14:39

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [22/35] changes in JFFS2

Changes page->mapping handling in JFFS2

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/jffs2/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/jffs2/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/jffs2/file.c
+++ test-2.6.23-rc4-mm1/fs/jffs2/file.c
@@ -111,11 +111,11 @@ int jffs2_do_readpage_unlock(struct inod

static int jffs2_readpage (struct file *filp, struct page *pg)
{
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
+ struct jffs2_inode_info *f = JFFS2_INODE_INFO(page_inode(pg));
int ret;

down(&f->sem);
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
+ ret = jffs2_do_readpage_unlock(page_inode(pg), pg);
up(&f->sem);
return ret;
}

2007-09-10 10:17:31

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [24/35] changes in MINIX FS

Changes page->mapping handling in MINIXFS


Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
---
fs/minix/dir.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/minix/dir.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/minix/dir.c
+++ test-2.6.23-rc4-mm1/fs/minix/dir.c
@@ -52,7 +52,7 @@ static inline unsigned long dir_pages(st

static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
int err = 0;
block_write_end(NULL, mapping, pos, len, len, page, NULL);
@@ -281,7 +281,8 @@ int minix_add_link(struct dentry *dentry

got_it:
pos = (page->index >> PAGE_CACHE_SHIFT) + p - (char*)page_address(page);
- err = __minix_write_begin(NULL, page->mapping, pos, sbi->s_dirsize,
+ err = __minix_write_begin(NULL,
+ page_mapping_cache(page), pos, sbi->s_dirsize,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err)
goto out_unlock;
@@ -307,7 +308,7 @@ out_unlock:

int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *inode = (struct inode*)mapping->host;
char *kaddr = page_address(page);
loff_t pos = page_offset(page) + (char*)de - kaddr;
@@ -431,7 +432,7 @@ not_empty:
void minix_set_link(struct minix_dir_entry *de, struct page *page,
struct inode *inode)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
struct minix_sb_info *sbi = minix_sb(dir->i_sb);
loff_t pos = page_offset(page) +

2007-09-10 10:18:27

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [25/35] changes in NCPFS

Changes page->mapping handling in NCPFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ncpfs/symlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/ncpfs/symlink.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ncpfs/symlink.c
+++ test-2.6.23-rc4-mm1/fs/ncpfs/symlink.c
@@ -42,7 +42,7 @@

static int ncp_symlink_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int error, length, len;
char *link, *rawlink;
char *buf = kmap(page);

2007-09-10 10:19:24

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [23/35] changes in JFS

Changes page->mapping handling in JFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/jfs/jfs_metapage.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/jfs/jfs_metapage.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/jfs/jfs_metapage.c
+++ test-2.6.23-rc4-mm1/fs/jfs/jfs_metapage.c
@@ -113,7 +113,7 @@ static inline int insert_metapage(struct
}

if (mp) {
- l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
+ l2mp_blocks = L2PSIZE - page_inode(page)->i_blkbits;
index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
a->mp_count++;
a->mp[index] = mp;
@@ -125,7 +125,7 @@ static inline int insert_metapage(struct
static inline void remove_metapage(struct page *page, struct metapage *mp)
{
struct meta_anchor *a = mp_anchor(page);
- int l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
+ int l2mp_blocks = L2PSIZE - page_inode(page)->i_blkbits;
int index;

index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
@@ -364,7 +364,7 @@ static int metapage_writepage(struct pag
{
struct bio *bio = NULL;
unsigned int block_offset; /* block offset of mp within page */
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
unsigned int len;
unsigned int xlen;
@@ -484,7 +484,7 @@ skip:

static int metapage_readpage(struct file *fp, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct bio *bio = NULL;
unsigned int block_offset;
unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;

2007-09-10 10:20:07

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH] add page->mapping handling interface [22/35] changes in JFFS2

On Mon, 2007-09-10 at 19:16 +0900, KAMEZAWA Hiroyuki wrote:
> Changes page->mapping handling in JFFS2
>
> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

Looks reasonable to me; I assume it's not intended for me to take it and
apply it yet, before the core parts are merged? I'll let you shepherd it
upstream...

--
dwmw2

2007-09-10 10:21:16

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [26/35] changes in NFS

Changes page->mapping handling in NFS

Singed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/nfs/file.c | 11 ++++++-----
fs/nfs/internal.h | 2 +-
fs/nfs/pagelist.c | 2 +-
fs/nfs/read.c | 4 ++--
fs/nfs/write.c | 35 ++++++++++++++++++-----------------
5 files changed, 28 insertions(+), 26 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/nfs/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/nfs/file.c
+++ test-2.6.23-rc4-mm1/fs/nfs/file.c
@@ -357,7 +357,7 @@ static void nfs_invalidate_page(struct p
if (offset != 0)
return;
/* Cancel any unstarted writes on this page */
- nfs_wb_page_cancel(page->mapping->host, page);
+ nfs_wb_page_cancel(page_inode(page), page);
}

static int nfs_release_page(struct page *page, gfp_t gfp)
@@ -368,7 +368,7 @@ static int nfs_release_page(struct page

static int nfs_launder_page(struct page *page)
{
- return nfs_wb_page(page->mapping->host, page);
+ return nfs_wb_page(page_inode(page), page);
}

const struct address_space_operations nfs_file_aops = {
@@ -395,16 +395,17 @@ static int nfs_vm_page_mkwrite(struct vm
void *fsdata;

lock_page(page);
- if (page->mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping)
+ if (!pagecache_consistent(page,
+ vma->vm_file->f_path.dentry->d_inode->i_mapping))
goto out_unlock;
pagelen = nfs_page_length(page);
if (pagelen == 0)
goto out_unlock;
- ret = nfs_write_begin(filp, page->mapping,
+ ret = nfs_write_begin(filp, page_mapping_cache(page),
(loff_t)page->index << PAGE_CACHE_SHIFT,
pagelen, 0, &page, &fsdata);
if (!ret)
- ret = nfs_write_end(filp, page->mapping,
+ ret = nfs_write_end(filp, page_mapping_cache(page),
(loff_t)page->index << PAGE_CACHE_SHIFT,
pagelen, pagelen, page, fsdata);
out_unlock:
Index: test-2.6.23-rc4-mm1/fs/nfs/internal.h
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/nfs/internal.h
+++ test-2.6.23-rc4-mm1/fs/nfs/internal.h
@@ -220,7 +220,7 @@ void nfs_super_set_maxbytes(struct super
static inline
unsigned int nfs_page_length(struct page *page)
{
- loff_t i_size = i_size_read(page->mapping->host);
+ loff_t i_size = i_size_read(page_inode(page));

if (i_size > 0) {
pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
Index: test-2.6.23-rc4-mm1/fs/nfs/read.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/nfs/read.c
+++ test-2.6.23-rc4-mm1/fs/nfs/read.c
@@ -466,7 +466,7 @@ static const struct rpc_call_ops nfs_rea
int nfs_readpage(struct file *file, struct page *page)
{
struct nfs_open_context *ctx;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int error;

dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
@@ -517,7 +517,7 @@ static int
readpage_async_filler(void *data, struct page *page)
{
struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct nfs_page *new;
unsigned int len;
int error;
Index: test-2.6.23-rc4-mm1/fs/nfs/write.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/nfs/write.c
+++ test-2.6.23-rc4-mm1/fs/nfs/write.c
@@ -131,7 +131,7 @@ static struct nfs_page *nfs_page_find_re

static struct nfs_page *nfs_page_find_request(struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct nfs_page *req = NULL;

spin_lock(&inode->i_lock);
@@ -143,7 +143,7 @@ static struct nfs_page *nfs_page_find_re
/* Adjust the file length if we're writing beyond the end */
static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t end, i_size = i_size_read(inode);
pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;

@@ -160,7 +160,7 @@ static void nfs_grow_file(struct page *p
static void nfs_set_pageerror(struct page *page)
{
SetPageError(page);
- nfs_zap_mapping(page->mapping->host, page->mapping);
+ nfs_zap_mapping(page_inode(page), page_mapping_cache(page));
}

/* We can set the PG_uptodate flag if we see that a write request
@@ -192,7 +192,7 @@ static int nfs_writepage_setup(struct nf
ret = PTR_ERR(req);
if (ret != -EBUSY)
return ret;
- ret = nfs_wb_page(page->mapping->host, page);
+ ret = nfs_wb_page(page_inode(page), page);
if (ret != 0)
return ret;
}
@@ -226,7 +226,7 @@ static int nfs_set_page_writeback(struct
int ret = test_set_page_writeback(page);

if (!ret) {
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct nfs_server *nfss = NFS_SERVER(inode);

if (atomic_long_inc_return(&nfss->writeback) >
@@ -238,7 +238,7 @@ static int nfs_set_page_writeback(struct

static void nfs_end_page_writeback(struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct nfs_server *nfss = NFS_SERVER(inode);

end_page_writeback(page);
@@ -255,7 +255,7 @@ static void nfs_end_page_writeback(struc
static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct nfs_inode *nfsi = NFS_I(inode);
struct nfs_page *req;
int ret;
@@ -301,7 +301,7 @@ static int nfs_page_async_flush(struct n

static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);

nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
@@ -318,7 +318,7 @@ static int nfs_writepage_locked(struct p
struct nfs_pageio_descriptor pgio;
int err;

- nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc));
+ nfs_pageio_init_write(&pgio, page_inode(page), wb_priority(wbc));
err = nfs_do_writepage(page, wbc, &pgio);
nfs_pageio_complete(&pgio);
if (err < 0)
@@ -585,7 +585,7 @@ static inline int nfs_scan_commit(struct
static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
struct page *page, unsigned int offset, unsigned int bytes)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *inode = mapping->host;
struct nfs_page *req, *new = NULL;
pgoff_t rqend, end;
@@ -687,7 +687,7 @@ int nfs_flush_incompatible(struct file *
nfs_release_request(req);
if (!do_flush)
return 0;
- status = nfs_wb_page(page->mapping->host, page);
+ status = nfs_wb_page(page_inode(page), page);
} while (status == 0);
return status;
}
@@ -702,7 +702,7 @@ int nfs_updatepage(struct file *file, st
unsigned int offset, unsigned int count)
{
struct nfs_open_context *ctx = nfs_file_open_context(file);
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int status = 0;

nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
@@ -958,7 +958,7 @@ static void nfs_writeback_done_partial(s
}

if (nfs_write_need_commit(data)) {
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);

spin_lock(&inode->i_lock);
if (test_bit(PG_NEED_RESCHED, &req->wb_flags)) {
@@ -1386,7 +1386,7 @@ int nfs_wb_page_cancel(struct inode *ino
loff_t range_start = page_offset(page);
loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
struct writeback_control wbc = {
- .bdi = page->mapping->backing_dev_info,
+ .bdi = page_mapping_cache(page)->backing_dev_info,
.sync_mode = WB_SYNC_ALL,
.nr_to_write = LONG_MAX,
.range_start = range_start,
@@ -1419,7 +1419,8 @@ int nfs_wb_page_cancel(struct inode *ino
}
if (!PagePrivate(page))
return 0;
- ret = nfs_sync_mapping_wait(page->mapping, &wbc, FLUSH_INVALIDATE);
+ ret = nfs_sync_mapping_wait(page_mapping_cache(page),
+ &wbc, FLUSH_INVALIDATE);
out:
return ret;
}
@@ -1429,7 +1430,7 @@ int nfs_wb_page_priority(struct inode *i
loff_t range_start = page_offset(page);
loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
struct writeback_control wbc = {
- .bdi = page->mapping->backing_dev_info,
+ .bdi = page_mapping_cache(page)->backing_dev_info,
.sync_mode = WB_SYNC_ALL,
.nr_to_write = LONG_MAX,
.range_start = range_start,
@@ -1445,7 +1446,7 @@ int nfs_wb_page_priority(struct inode *i
}
if (!PagePrivate(page))
return 0;
- ret = nfs_sync_mapping_wait(page->mapping, &wbc, how);
+ ret = nfs_sync_mapping_wait(page_mapping_cache(page), &wbc, how);
if (ret >= 0)
return 0;
out:
Index: test-2.6.23-rc4-mm1/fs/nfs/pagelist.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/nfs/pagelist.c
+++ test-2.6.23-rc4-mm1/fs/nfs/pagelist.c
@@ -81,7 +81,7 @@ nfs_create_request(struct nfs_open_conte
page_cache_get(page);
BUG_ON(PagePrivate(page));
BUG_ON(!PageLocked(page));
- BUG_ON(page->mapping->host != inode);
+ BUG_ON(page_inode(page) != inode);
req->wb_offset = offset;
req->wb_pgbase = offset;
req->wb_bytes = count;

2007-09-10 10:22:11

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [27/35] changes in NTFS


Changes page->mapping handling in NTFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ntfs/aops.c | 14 +++++++-------
fs/ntfs/compress.c | 2 +-
fs/ntfs/file.c | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ntfs/aops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ntfs/aops.c
+++ test-2.6.23-rc4-mm1/fs/ntfs/aops.c
@@ -65,7 +65,7 @@ static void ntfs_end_buffer_async_read(s
int page_uptodate = 1;

page = bh->b_page;
- vi = page->mapping->host;
+ vi = page_inode(page);
ni = NTFS_I(vi);

if (likely(uptodate)) {
@@ -194,7 +194,7 @@ static int ntfs_read_block(struct page *
int i, nr;
unsigned char blocksize_bits;

- vi = page->mapping->host;
+ vi = page_inode(page);
ni = NTFS_I(vi);
vol = ni->vol;

@@ -413,7 +413,7 @@ retry_readpage:
unlock_page(page);
return 0;
}
- vi = page->mapping->host;
+ vi = page_inode(page);
ni = NTFS_I(vi);
/*
* Only $DATA attributes can be encrypted and only unnamed $DATA
@@ -553,7 +553,7 @@ static int ntfs_write_block(struct page
bool need_end_writeback;
unsigned char blocksize_bits;

- vi = page->mapping->host;
+ vi = page_inode(page);
ni = NTFS_I(vi);
vol = ni->vol;

@@ -909,7 +909,7 @@ static int ntfs_write_mst_block(struct p
struct writeback_control *wbc)
{
sector_t block, dblock, rec_block;
- struct inode *vi = page->mapping->host;
+ struct inode *vi = page_inode(page);
ntfs_inode *ni = NTFS_I(vi);
ntfs_volume *vol = ni->vol;
u8 *kaddr;
@@ -1342,7 +1342,7 @@ done:
static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
{
loff_t i_size;
- struct inode *vi = page->mapping->host;
+ struct inode *vi = page_inode(page);
ntfs_inode *base_ni = NULL, *ni = NTFS_I(vi);
char *kaddr;
ntfs_attr_search_ctx *ctx = NULL;
@@ -1579,7 +1579,7 @@ const struct address_space_operations nt
* need the lock since try_to_free_buffers() does not free dirty buffers.
*/
void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
ntfs_inode *ni = NTFS_I(mapping->host);
struct buffer_head *bh, *head, *buffers_to_free = NULL;
unsigned int end, bh_size, bh_ofs;
Index: test-2.6.23-rc4-mm1/fs/ntfs/compress.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ntfs/compress.c
+++ test-2.6.23-rc4-mm1/fs/ntfs/compress.c
@@ -482,7 +482,7 @@ int ntfs_read_compressed_block(struct pa
{
loff_t i_size;
s64 initialized_size;
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
ntfs_inode *ni = NTFS_I(mapping->host);
ntfs_volume *vol = ni->vol;
struct super_block *sb = vol->sb;
Index: test-2.6.23-rc4-mm1/fs/ntfs/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ntfs/file.c
+++ test-2.6.23-rc4-mm1/fs/ntfs/file.c
@@ -520,7 +520,7 @@ static int ntfs_prepare_pages_for_non_re
BUG_ON(!nr_pages);
BUG_ON(!pages);
BUG_ON(!*pages);
- vi = pages[0]->mapping->host;
+ vi = page_inode(pages[0]);
ni = NTFS_I(vi);
vol = ni->vol;
ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, start page "
@@ -1494,7 +1494,7 @@ static inline int ntfs_commit_pages_afte
unsigned blocksize, u;
int err;

- vi = pages[0]->mapping->host;
+ vi = page_inode(pages[0]);
ni = NTFS_I(vi);
blocksize = vi->i_sb->s_blocksize;
end = pos + bytes;
@@ -1654,7 +1654,7 @@ static int ntfs_commit_pages_after_write
BUG_ON(!pages);
page = pages[0];
BUG_ON(!page);
- vi = page->mapping->host;
+ vi = page_inode(page);
ni = NTFS_I(vi);
ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, start page "
"index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.",

2007-09-10 10:24:33

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [28/35] changes in OCFS2

Changes page->mapping handling in OCFS2

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ocfs2/aops.c | 8 ++++----
fs/ocfs2/mmap.c | 3 ++-
2 files changed, 6 insertions(+), 5 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ocfs2/aops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ocfs2/aops.c
+++ test-2.6.23-rc4-mm1/fs/ocfs2/aops.c
@@ -208,7 +208,7 @@ bail:

static int ocfs2_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t start = (loff_t)page->index << PAGE_CACHE_SHIFT;
int ret, unlock = 1;

@@ -540,14 +540,14 @@ static void ocfs2_dio_end_io(struct kioc
*/
static void ocfs2_invalidatepage(struct page *page, unsigned long offset)
{
- journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
+ journal_t *journal = OCFS2_SB(page_inode(page)->i_sb)->journal->j_journal;

journal_invalidatepage(journal, page, offset);
}

static int ocfs2_releasepage(struct page *page, gfp_t wait)
{
- journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
+ journal_t *journal = OCFS2_SB(page_inode(page)->i_sb)->journal->j_journal;

if (!page_has_buffers(page))
return 0;
@@ -1065,7 +1065,7 @@ static int ocfs2_grab_pages_for_write(st
*/
lock_page(mmap_page);

- if (mmap_page->mapping != mapping) {
+ if (!pagecache_consistent(mmap_page, mapping)) {
unlock_page(mmap_page);
/*
* Sanity check - the locking in
Index: test-2.6.23-rc4-mm1/fs/ocfs2/mmap.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ocfs2/mmap.c
+++ test-2.6.23-rc4-mm1/fs/ocfs2/mmap.c
@@ -112,7 +112,8 @@ static int __ocfs2_page_mkwrite(struct i
* page mapping after taking the page lock inside of
* ocfs2_write_begin_nolock().
*/
- if (!PageUptodate(page) || page->mapping != inode->i_mapping) {
+ if (!PageUptodate(page) ||
+ !pagecache_consistent(page, inode->i_mapping)) {
ret = -EINVAL;
goto out;
}

2007-09-10 10:26:19

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [29/35] changes in REISER4/REISERFS

Changes page->mapping handling in reiser4
(sorry, changes for /reiserfs is also included.)

Todo:
Fix this warning caused by this patch(set). does anyone have an adivce ?
fs/reiser4/page_cache.c: In function ‘reiser4_tree_by_page’:
fs/reiser4/page_cache.c:315: warning: passing argument 1 of ‘page_inode’ discards qualifiers from pointer target type

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/reiser4/as_ops.c | 34 ++++++++++++++++---------------
fs/reiser4/entd.c | 6 ++---
fs/reiser4/jnode.c | 18 +++++++++-------
fs/reiser4/page_cache.c | 10 ++++-----
fs/reiser4/plugin/cluster.h | 14 ++++++------
fs/reiser4/plugin/file/cryptcompress.c | 15 +++++++------
fs/reiser4/plugin/file/file.c | 22 ++++++++++----------
fs/reiser4/plugin/file_ops.c | 8 +++----
fs/reiser4/plugin/item/ctail.c | 16 +++++++-------
fs/reiser4/plugin/item/extent_file_ops.c | 6 ++---
fs/reiser4/plugin/item/tail.c | 6 ++---
fs/reiser4/wander.c | 2 -
fs/reiserfs/inode.c | 16 +++++++-------
fs/reiserfs/journal.c | 3 +-
fs/reiserfs/tail_conversion.c | 2 -
15 files changed, 92 insertions(+), 86 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/reiser4/as_ops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/as_ops.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/as_ops.c
@@ -64,24 +64,25 @@
int reiser4_set_page_dirty(struct page *page)
{
/* this page can be unformatted only */
- assert("vs-1734", (page->mapping &&
- page->mapping->host &&
- reiser4_get_super_fake(page->mapping->host->i_sb) !=
- page->mapping->host
- && reiser4_get_cc_fake(page->mapping->host->i_sb) !=
- page->mapping->host
- && reiser4_get_bitmap_fake(page->mapping->host->i_sb) !=
- page->mapping->host));
+ assert("vs-1734", (page_mapping_cache(page) &&
+ page_inode(page) &&
+ reiser4_get_super_fake(page_inode(page)->i_sb) !=
+ page_inode(page)
+ && reiser4_get_cc_fake(page_inode(page)->i_sb) !=
+ page_inode(page)
+ && reiser4_get_bitmap_fake(page_inode(page)->i_sb) !=
+ page_inode(page)));

if (!TestSetPageDirty(page)) {
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);

if (mapping) {
write_lock_irq(&mapping->tree_lock);

/* check for race with truncate */
- if (page->mapping) {
- assert("vs-1652", page->mapping == mapping);
+ if (page_is_pagecache(page)) {
+ assert("vs-1652",
+ page_mapping_cache(page) == mapping);
if (mapping_cap_account_dirty(mapping))
inc_zone_page_state(page,
NR_FILE_DIRTY);
@@ -140,7 +141,7 @@ void reiser4_invalidatepage(struct page

assert("nikita-3137", PageLocked(page));
assert("nikita-3138", !PageWriteback(page));
- inode = page->mapping->host;
+ inode = page_inode(page);

/*
* ->invalidatepage() should only be called for the unformatted
@@ -157,7 +158,8 @@ void reiser4_invalidatepage(struct page
return;
assert("vs-1426", PagePrivate(page));
assert("vs-1427",
- page->mapping == jnode_get_mapping(jnode_by_page(page)));
+ pagecache_consistent(page,
+ jnode_get_mapping(jnode_by_page(page))));
assert("", jprivate(page) != NULL);
assert("", ergo(inode_file_plugin(inode) !=
file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID),
@@ -287,8 +289,8 @@ int reiser4_releasepage(struct page *pag

node = jnode_by_page(page);
assert("nikita-2258", node != NULL);
- assert("reiser4-4", page->mapping != NULL);
- assert("reiser4-5", page->mapping->host != NULL);
+ assert("reiser4-4", page_mapping_cache(page) != NULL);
+ assert("reiser4-5", page_inode(page) != NULL);

if (PageDirty(page))
return 0;
@@ -305,7 +307,7 @@ int reiser4_releasepage(struct page *pag
if (jnode_is_releasable(node)) {
struct address_space *mapping;

- mapping = page->mapping;
+ mapping = page_mapping_cache(page);
jref(node);
/* there is no need to synchronize against
* jnode_extent_write() here, because pages seen by
Index: test-2.6.23-rc4-mm1/fs/reiser4/entd.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/entd.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/entd.c
@@ -266,9 +266,9 @@ int write_page_by_ent(struct page *page,
struct wbq rq;

assert("", PageLocked(page));
- assert("", page->mapping != NULL);
+ assert("", page_mapping_cache(page) != NULL);

- sb = page->mapping->host->i_sb;
+ sb = page_inode(page)->i_sb;
ent = get_entd_context(sb);
assert("", ent && ent->done == 0);

@@ -283,7 +283,7 @@ int write_page_by_ent(struct page *page,
* pin inode in memory, unlock page, entd_flush will iput. We can not
* iput here becasue we can not allow delete_inode to be called here
*/
- inode = igrab(page->mapping->host);
+ inode = igrab(page_inode(page));
unlock_page(page);
if (inode == NULL)
/* inode is getting freed */
Index: test-2.6.23-rc4-mm1/fs/reiser4/jnode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/jnode.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/jnode.c
@@ -594,7 +594,7 @@ static jnode *do_jget(reiser4_tree * tre
*/

jnode *result;
- oid_t oid = get_inode_oid(pg->mapping->host);
+ oid_t oid = get_inode_oid(page_inode(pg));

assert("umka-176", pg != NULL);
assert("nikita-2394", PageLocked(pg));
@@ -606,18 +606,18 @@ static jnode *do_jget(reiser4_tree * tre
tree = reiser4_tree_by_page(pg);

/* check hash-table first */
- result = jfind(pg->mapping, pg->index);
+ result = jfind(page_mapping_cache(pg), pg->index);
if (unlikely(result != NULL)) {
spin_lock_jnode(result);
jnode_attach_page(result, pg);
spin_unlock_jnode(result);
- result->key.j.mapping = pg->mapping;
+ result->key.j.mapping = page_mapping_cache(pg);
return result;
}

/* since page is locked, jnode should be allocated with GFP_NOFS flag */
reiser4_ctx_gfp_mask_force(GFP_NOFS);
- result = find_get_jnode(tree, pg->mapping, oid, pg->index);
+ result = find_get_jnode(tree, page_mapping_cache(pg), oid, pg->index);
if (unlikely(IS_ERR(result)))
return result;
/* attach jnode to page */
@@ -646,13 +646,14 @@ jnode *jnode_of_page(struct page * pg)
assert("nikita-2364",
jprivate(pg)->key.j.index == pg->index);
assert("nikita-2367",
- jprivate(pg)->key.j.mapping == pg->mapping);
+ jprivate(pg)->key.j.mapping ==
+ page_mapping_cache(pg));
assert("nikita-2365",
jprivate(pg)->key.j.objectid ==
- get_inode_oid(pg->mapping->host));
+ get_inode_oid(page_inode(pg)));
assert("vs-1200",
jprivate(pg)->key.j.objectid ==
- pg->mapping->host->i_ino);
+ page_inode(pg)->i_ino);
assert("nikita-2356",
jnode_is_unformatted(jnode_by_page(pg)));
}
@@ -812,7 +813,8 @@ static struct page *jnode_get_page_locke
page_cache_get(page);
spin_unlock_jnode(node);
lock_page(page);
- assert("nikita-3134", page->mapping == jnode_get_mapping(node));
+ assert("nikita-3134",
+ page_mapping_cache(page) == jnode_get_mapping(node));
}

spin_lock_jnode(node);
Index: test-2.6.23-rc4-mm1/fs/reiser4/page_cache.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/page_cache.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/page_cache.c
@@ -312,7 +312,7 @@ void reiser4_wait_page_writeback(struct
reiser4_tree *reiser4_tree_by_page(const struct page *page /* page to query */ )
{
assert("nikita-2461", page != NULL);
- return &get_super_private(page->mapping->host->i_sb)->tree;
+ return &get_super_private(page_inode(page)->i_sb)->tree;
}

/* completion handler for single page bio-based read.
@@ -400,7 +400,7 @@ int reiser4_page_io(struct page *page, j
assert("nikita-2893", rw == READ || rw == WRITE);

if (rw) {
- if (unlikely(page->mapping->host->i_sb->s_flags & MS_RDONLY)) {
+ if (unlikely(page_inode(page)->i_sb->s_flags & MS_RDONLY)) {
unlock_page(page);
return 0;
}
@@ -441,7 +441,7 @@ static struct bio *page_bio(struct page
struct super_block *super;
reiser4_block_nr blocknr;

- super = page->mapping->host->i_sb;
+ super = page_inode(page)->i_sb;
assert("nikita-2029", super != NULL);
blksz = super->s_blocksize;
assert("nikita-2028", blksz == (int)PAGE_CACHE_SIZE);
@@ -479,7 +479,7 @@ int reiser4_set_page_dirty_internal(stru
{
struct address_space *mapping;

- mapping = page->mapping;
+ mapping = page_mapping_cache(page);
BUG_ON(mapping == NULL);

if (!TestSetPageDirty(page)) {
@@ -528,7 +528,7 @@ int reiser4_writepage(struct page *page,

assert("vs-828", PageLocked(page));

- s = page->mapping->host->i_sb;
+ s = page_inode(page)->i_sb;
ctx = get_current_context_check();

//assert("", can_hit_entd(ctx, s));
Index: test-2.6.23-rc4-mm1/fs/reiser4/wander.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/wander.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/wander.c
@@ -765,7 +765,7 @@ static int write_jnodes_to_disk_extent(

spin_lock_jnode(cur);
assert("nikita-3166",
- pg->mapping == jnode_get_mapping(cur));
+ page_mapping_cache(pg) == jnode_get_mapping(cur));
assert("zam-912", !JF_ISSET(cur, JNODE_WRITEBACK));
#if REISER4_DEBUG
spin_lock(&cur->load);
Index: test-2.6.23-rc4-mm1/fs/reiserfs/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiserfs/inode.c
+++ test-2.6.23-rc4-mm1/fs/reiserfs/inode.c
@@ -2331,7 +2331,7 @@ static int map_block_for_writepage(struc
static int reiserfs_write_full_page(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
int error = 0;
unsigned long block;
@@ -2546,7 +2546,7 @@ static int reiserfs_readpage(struct file

static int reiserfs_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
reiserfs_wait_on_write_block(inode->i_sb);
return reiserfs_write_full_page(page, wbc);
}
@@ -2624,7 +2624,7 @@ static int reiserfs_write_begin(struct f
int reiserfs_prepare_write(struct file *f, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int ret;
int old_ref = 0;

@@ -2679,7 +2679,7 @@ static int reiserfs_write_end(struct fil
loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int ret = 0;
int update_sd = 0;
struct reiserfs_transaction_handle *th;
@@ -2772,7 +2772,7 @@ static int reiserfs_write_end(struct fil
int reiserfs_commit_write(struct file *f, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + to;
int ret = 0;
int update_sd = 0;
@@ -2951,7 +2951,7 @@ static int invalidatepage_can_drop(struc
static void reiserfs_invalidatepage(struct page *page, unsigned long offset)
{
struct buffer_head *head, *bh, *next;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
unsigned int curr_off = 0;
int ret = 1;

@@ -2997,7 +2997,7 @@ static void reiserfs_invalidatepage(stru

static int reiserfs_set_page_dirty(struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
if (reiserfs_file_data_log(inode)) {
SetPageChecked(page);
return __set_page_dirty_nobuffers(page);
@@ -3016,7 +3016,7 @@ static int reiserfs_set_page_dirty(struc
*/
static int reiserfs_releasepage(struct page *page, gfp_t unused_gfp_flags)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
struct buffer_head *head;
struct buffer_head *bh;
Index: test-2.6.23-rc4-mm1/fs/reiserfs/journal.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiserfs/journal.c
+++ test-2.6.23-rc4-mm1/fs/reiserfs/journal.c
@@ -889,7 +889,8 @@ static int write_ordered_buffers(spinloc
* the buffer. We're safe if we write the page one last time
* after freeing the journal header.
*/
- if (buffer_dirty(bh) && unlikely(bh->b_page->mapping == NULL)) {
+ if (buffer_dirty(bh) &&
+ unlikely(!page_mapping_cache(bh->b_page))) {
spin_unlock(lock);
ll_rw_block(WRITE, 1, &bh);
spin_lock(lock);
Index: test-2.6.23-rc4-mm1/fs/reiserfs/tail_conversion.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiserfs/tail_conversion.c
+++ test-2.6.23-rc4-mm1/fs/reiserfs/tail_conversion.c
@@ -151,7 +151,7 @@ void reiserfs_unmap_buffer(struct buffer
interested in removing it from per-sb j_dirty_buffers list, to avoid
BUG() on attempt to write not mapped buffer */
if ((!list_empty(&bh->b_assoc_buffers) || bh->b_private) && bh->b_page) {
- struct inode *inode = bh->b_page->mapping->host;
+ struct inode *inode = page_inode(bh->b_page);
struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
spin_lock(&j->j_dirty_buffers_lock);
list_del_init(&bh->b_assoc_buffers);
Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/cluster.h
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/cluster.h
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/cluster.h
@@ -92,9 +92,9 @@ static inline unsigned off_to_cloff(loff
static inline pgoff_t offset_in_clust(struct page * page)
{
assert("edward-1488", page != NULL);
- assert("edward-1489", page->mapping != NULL);
+ assert("edward-1489", page_mapping_cache(page) != NULL);

- return page_index(page) & ((cluster_nrpages(page->mapping->host)) - 1);
+ return page_index(page) & ((cluster_nrpages(page_inode(page))) - 1);
}

static inline int first_page_in_cluster(struct page * page)
@@ -105,7 +105,7 @@ static inline int first_page_in_cluster(
static inline int last_page_in_cluster(struct page * page)
{
return offset_in_clust(page) ==
- cluster_nrpages(page->mapping->host) - 1;
+ cluster_nrpages(page_inode(page)) - 1;
}

static inline unsigned
@@ -200,11 +200,11 @@ static inline int same_page_cluster(stru
{
assert("edward-1490", p1 != NULL);
assert("edward-1491", p2 != NULL);
- assert("edward-1492", p1->mapping != NULL);
- assert("edward-1493", p2->mapping != NULL);
+ assert("edward-1492", page_is_pagecache(p1));
+ assert("edward-1493", page_is_pagecache(p2));

- return (pg_to_clust(page_index(p1), p1->mapping->host) ==
- pg_to_clust(page_index(p2), p2->mapping->host));
+ return (pg_to_clust(page_index(p1), page_inode(p1)) ==
+ pg_to_clust(page_index(p2), page_inode(p2)));
}

static inline int cluster_is_complete(struct cluster_handle * clust,
Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/file/cryptcompress.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/file/cryptcompress.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/file/cryptcompress.c
@@ -1233,16 +1233,16 @@ int readpage_cryptcompress(struct file *

assert("edward-88", PageLocked(page));
assert("vs-976", !PageUptodate(page));
- assert("edward-89", page->mapping && page->mapping->host);
+ assert("edward-89", page_mapping_cache(page) && page_inode(page));

- ctx = reiser4_init_context(page->mapping->host->i_sb);
+ ctx = reiser4_init_context(page_inode(page)->i_sb);
if (IS_ERR(ctx)) {
unlock_page(page);
return PTR_ERR(ctx);
}
assert("edward-113",
ergo(file != NULL,
- page->mapping == file->f_dentry->d_inode->i_mapping));
+ pagecache_consistent(page, file->f_dentry->d_inode->i_mapping)));

if (PageUptodate(page)) {
warning("edward-1338", "page is already uptodate\n");
@@ -1873,7 +1873,8 @@ static void checkout_page_cluster(struct
assert("edward-1480",
i_size_read(inode) <= page_offset(clust->pages[i]));
assert("edward-1481",
- clust->pages[i]->mapping != inode->i_mapping);
+ !pagecache_consistent(clust->pages[i],
+ inode->i_mapping));
unlock_page(clust->pages[i]);
break;
}
@@ -2651,13 +2652,13 @@ int set_cluster_by_page(struct cluster_h

assert("edward-1358", clust != NULL);
assert("edward-1359", page != NULL);
- assert("edward-1360", page->mapping != NULL);
- assert("edward-1361", page->mapping->host != NULL);
+ assert("edward-1360", page_mapping_cache(page) != NULL);
+ assert("edward-1361", page_inode(page) != NULL);

setting_actor =
(clust->pages ? reset_cluster_pgset : alloc_cluster_pgset);
result = setting_actor(clust, count);
- clust->index = pg_to_clust(page->index, page->mapping->host);
+ clust->index = pg_to_clust(page->index, page_inode(page));
return result;
}

Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/file/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/file/file.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/file/file.c
@@ -790,8 +790,8 @@ int find_or_create_extent(struct page *p

jnode *node;

- assert("vs-1065", page->mapping && page->mapping->host);
- inode = page->mapping->host;
+ assert("vs-1065", page_mapping_cache(page) && page_inode(page));
+ inode = page_inode(page);

lock_page(page);
node = jnode_of_page(page);
@@ -866,8 +866,8 @@ static int capture_page_and_create_exten
int result;
struct inode *inode;

- assert("vs-1084", page->mapping && page->mapping->host);
- inode = page->mapping->host;
+ assert("vs-1084", page_mapping_cache(page) && page_inode(page));
+ inode = page_inode(page);
assert("vs-1139",
unix_file_inode_data(inode)->container == UF_CONTAINER_EXTENTS);
/* page belongs to file */
@@ -905,8 +905,8 @@ commit_write_unix_file(struct file *file

SetPageUptodate(page);

- inode = page->mapping->host;
- ctx = reiser4_init_context(page->mapping->host->i_sb);
+ inode = page_inode(page);
+ ctx = reiser4_init_context(page_inode(page)->i_sb);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
page_cache_get(page);
@@ -1433,9 +1433,9 @@ int readpage_unix_file(struct file *file

assert("vs-1062", PageLocked(page));
assert("vs-976", !PageUptodate(page));
- assert("vs-1061", page->mapping && page->mapping->host);
+ assert("vs-1061", page_mapping_cache(page) && page_inode(page));

- if (page->mapping->host->i_size <= page_offset(page)) {
+ if (page_inode(page)->i_size <= page_offset(page)) {
/* page is out of file */
zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
SetPageUptodate(page);
@@ -1443,7 +1443,7 @@ int readpage_unix_file(struct file *file
return 0;
}

- inode = page->mapping->host;
+ inode = page_inode(page);
ctx = reiser4_init_context(inode->i_sb);
if (IS_ERR(ctx)) {
unlock_page(page);
@@ -1476,7 +1476,7 @@ int readpage_unix_file(struct file *file
lock_page(page);
page_cache_release(page);

- if (page->mapping == NULL) {
+ if (!page_is_pagecache(page)) {
/*
* readpage allows truncate to run concurrently. Page was
* truncated while it was not locked
@@ -1604,7 +1604,7 @@ static int uf_readpages_filler(void * da
reiser4_extent *ext;
__u64 ext_index;
int cbk_done = 0;
- struct address_space * mapping = page->mapping;
+ struct address_space * mapping = page_mapping_cache(page);

if (PageUptodate(page)) {
unlock_page(page);
Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/file_ops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/file_ops.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/file_ops.c
@@ -93,7 +93,7 @@ prepare_write_common(struct file *file,
reiser4_context *ctx;
int result;

- ctx = reiser4_init_context(page->mapping->host->i_sb);
+ ctx = reiser4_init_context(page_inode(page)->i_sb);
result = do_prepare_write(file, page, from, to);

/* don't commit transaction under inode semaphore */
@@ -120,13 +120,13 @@ do_prepare_write(struct file *file, stru
if (to - from == PAGE_CACHE_SIZE || PageUptodate(page))
return 0;

- inode = page->mapping->host;
+ inode = page_inode(page);
fplug = inode_file_plugin(inode);

- if (page->mapping->a_ops->readpage == NULL)
+ if (page_mapping_cache(page)->a_ops->readpage == NULL)
return RETERR(-EINVAL);

- result = page->mapping->a_ops->readpage(file, page);
+ result = page_mapping_cache(page)->a_ops->readpage(file, page);
if (result != 0) {
SetPageError(page);
ClearPageUptodate(page);
Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/ctail.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/item/ctail.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/ctail.c
@@ -580,7 +580,7 @@ static int ctail_read_disk_cluster(struc
*/
assert("edward-1528", znode_is_any_locked(clust->hint->lh.node));

- if (page->mapping != inode->i_mapping) {
+ if (pagecache_consistent(page, inode->i_mapping)) {
/* page was truncated */
reiser4_unset_hint(clust->hint);
reset_cluster_params(clust);
@@ -632,7 +632,7 @@ int do_readpage_ctail(struct inode * ino

assert("edward-212", PageLocked(page));

- if (unlikely(page->mapping != inode->i_mapping))
+ if (unlikely(pagecache_consistent(page, inode->i_mapping)))
return AOP_TRUNCATED_PAGE;
if (PageUptodate(page))
goto exit;
@@ -713,7 +713,7 @@ int readpage_ctail(void *vp, struct page
assert("edward-114", clust != NULL);
assert("edward-115", PageLocked(page));
assert("edward-116", !PageUptodate(page));
- assert("edward-118", page->mapping && page->mapping->host);
+ assert("edward-118", page_mapping_cache(page) && page_inode(page));
assert("edward-867", !tfm_cluster_is_uptodate(&clust->tc));

hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get());
@@ -730,7 +730,7 @@ int readpage_ctail(void *vp, struct page
}
assert("vs-25", hint->ext_coord.lh == &hint->lh);

- result = do_readpage_ctail(page->mapping->host, clust, page,
+ result = do_readpage_ctail(page_inode(page), clust, page,
ZNODE_READ_LOCK);
assert("edward-213", PageLocked(page));
assert("edward-1163", ergo(!result, PageUptodate(page)));
@@ -781,7 +781,7 @@ static int ctail_readpages_filler(void *
struct cluster_handle * clust = data;
struct inode * inode = clust->file->f_dentry->d_inode;

- assert("edward-1525", page->mapping == inode->i_mapping);
+ assert("edward-1525", pagecache_consistent(page, inode->i_mapping));

if (PageUptodate(page)) {
unlock_page(page);
@@ -1110,7 +1110,7 @@ int scan_ctail(flush_scan * scan)
assert("edward-639", znode_is_write_locked(scan->parent_lock.node));

page = jnode_page(node);
- inode = page->mapping->host;
+ inode = page_inode(page);

if (!reiser4_scanning_left(scan))
return result;
@@ -1516,9 +1516,9 @@ int convert_ctail(flush_pos_t * pos)
assert("edward-264", pos->child != NULL);
assert("edward-265", jnode_page(pos->child) != NULL);
assert("edward-266",
- jnode_page(pos->child)->mapping != NULL);
+ page_mapping_cache(jnode_page(pos->child)) != NULL);

- inode = jnode_page(pos->child)->mapping->host;
+ inode = page_inode(jnode_page(pos->child));

assert("edward-267", inode != NULL);

Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/extent_file_ops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/item/extent_file_ops.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/extent_file_ops.c
@@ -1124,7 +1124,7 @@ int reiser4_do_readpage_extent(reiser4_e
oid_t oid;
reiser4_block_nr block;

- mapping = page->mapping;
+ mapping = page_mapping_cache(page);
oid = get_inode_oid(mapping->host);
index = page->index;

@@ -1324,14 +1324,14 @@ int reiser4_readpage_extent(void *vp, st

assert("vs-1040", PageLocked(page));
assert("vs-1050", !PageUptodate(page));
- assert("vs-1039", page->mapping && page->mapping->host);
+ assert("vs-1039", page_mapping_cache(page) && page_inode(page));

assert("vs-1044", znode_is_loaded(coord->node));
assert("vs-758", item_is_extent(coord));
assert("vs-1046", coord_is_existing_unit(coord));
assert("vs-1045", znode_is_rlocked(coord->node));
assert("vs-1047",
- page->mapping->host->i_ino ==
+ page_inode(page)->i_ino ==
get_key_objectid(item_key_by_coord(coord, &key)));
check_uf_coord(uf_coord, NULL);

Index: test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/tail.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/reiser4/plugin/item/tail.c
+++ test-2.6.23-rc4-mm1/fs/reiser4/plugin/item/tail.c
@@ -317,7 +317,7 @@ static int do_readpage_tail(uf_coord_t *
/* saving passed coord in order to do not move it by tap. */
init_lh(&lh);
copy_lh(&lh, uf_coord->lh);
- inode = page->mapping->host;
+ inode = page_inode(page);
coord_dup(&coord, &uf_coord->coord);

reiser4_tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK);
@@ -421,14 +421,14 @@ int readpage_tail(void *vp, struct page
assert("umka-2515", PageLocked(page));
assert("umka-2516", !PageUptodate(page));
assert("umka-2517", !jprivate(page) && !PagePrivate(page));
- assert("umka-2518", page->mapping && page->mapping->host);
+ assert("umka-2518", page_mapping_cache(page) && page_inode(page));

assert("umka-2519", znode_is_loaded(coord->node));
assert("umka-2520", item_is_tail(coord));
assert("umka-2521", coord_is_existing_unit(coord));
assert("umka-2522", znode_is_rlocked(coord->node));
assert("umka-2523",
- page->mapping->host->i_ino ==
+ page_inode(page)->i_ino ==
get_key_objectid(item_key_by_coord(coord, &key)));

return do_readpage_tail(uf_coord, page);

2007-09-10 10:26:37

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [30/35] changes ROMFS

Changes page->mapping handling in ROMFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/romfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: test-2.6.23-rc4-mm1/fs/romfs/inode.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/romfs/inode.c
+++ test-2.6.23-rc4-mm1/fs/romfs/inode.c
@@ -417,7 +417,7 @@ out: unlock_kernel();
static int
romfs_readpage(struct file *file, struct page * page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
loff_t offset, avail, readlen;
void *buf;
int result = -EIO;

2007-09-10 10:28:22

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [31/35] changes in SYSVFS

Changes page->mapping handlingi in SYSVFS.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/sysv/dir.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/sysv/dir.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/sysv/dir.c
+++ test-2.6.23-rc4-mm1/fs/sysv/dir.c
@@ -40,7 +40,7 @@ static inline unsigned long dir_pages(st

static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
int err = 0;

@@ -221,7 +221,8 @@ got_it:
pos = page_offset(page) +
(char*)de - (char*)page_address(page);
lock_page(page);
- err = __sysv_write_begin(NULL, page->mapping, pos, SYSV_DIRSIZE,
+ err = __sysv_write_begin(NULL, page_mapping_cache(page),
+ pos, SYSV_DIRSIZE,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err)
goto out_unlock;
@@ -242,7 +243,7 @@ out_unlock:

int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *inode = (struct inode*)mapping->host;
char *kaddr = (char*)page_address(page);
loff_t pos = page_offset(page) + (char *)de - kaddr;
@@ -344,7 +345,7 @@ not_empty:
void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
struct inode *inode)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
loff_t pos = page_offset(page) +
(char *)de-(char*)page_address(page);


2007-09-10 10:30:50

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [32/35] changes in UDFFS

Changes page->mapping handling in UDFFS

Signed-off-by: KAMEZAWA hiroyuki <[email protected]>
---
fs/udf/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/udf/file.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/udf/file.c
+++ test-2.6.23-rc4-mm1/fs/udf/file.c
@@ -43,7 +43,7 @@

static int udf_adinicb_readpage(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
char *kaddr;

BUG_ON(!PageLocked(page));
@@ -61,7 +61,7 @@ static int udf_adinicb_readpage(struct f

static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
char *kaddr;

BUG_ON(!PageLocked(page));
Index: test-2.6.23-rc4-mm1/fs/udf/symlink.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/udf/symlink.c
+++ test-2.6.23-rc4-mm1/fs/udf/symlink.c
@@ -73,7 +73,7 @@ static void udf_pc_to_char(struct super_

static int udf_symlink_filler(struct file *file, struct page *page)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
struct buffer_head *bh = NULL;
char *symlink;
int err = -EIO;

2007-09-10 10:32:14

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [33/35] changes in UFS

Changes page->mapping handling in UFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/ufs/dir.c | 10 +++++-----
fs/ufs/util.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/ufs/dir.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ufs/dir.c
+++ test-2.6.23-rc4-mm1/fs/ufs/dir.c
@@ -42,7 +42,7 @@ static inline int ufs_match(struct super

static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
struct inode *dir = mapping->host;
int err = 0;

@@ -95,7 +95,7 @@ void ufs_set_link(struct inode *dir, str
int err;

lock_page(page);
- err = __ufs_write_begin(NULL, page->mapping, pos, len,
+ err = __ufs_write_begin(NULL, page_mapping_cache(page), pos, len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err);

@@ -111,7 +111,7 @@ void ufs_set_link(struct inode *dir, str

static void ufs_check_page(struct page *page)
{
- struct inode *dir = page->mapping->host;
+ struct inode *dir = page_inode(page);
struct super_block *sb = dir->i_sb;
char *kaddr = page_address(page);
unsigned offs, rec_len;
@@ -381,7 +381,7 @@ int ufs_add_link(struct dentry *dentry,
got_it:
pos = page_offset(page) +
(char*)de - (char*)page_address(page);
- err = __ufs_write_begin(NULL, page->mapping, pos, rec_len,
+ err = __ufs_write_begin(NULL, page_mapping_cache(page), pos, rec_len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err)
goto out_unlock;
@@ -518,7 +518,7 @@ int ufs_delete_entry(struct inode *inode
struct page * page)
{
struct super_block *sb = inode->i_sb;
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = page_mapping_cache(page);
char *kaddr = page_address(page);
unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
Index: test-2.6.23-rc4-mm1/fs/ufs/util.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/ufs/util.c
+++ test-2.6.23-rc4-mm1/fs/ufs/util.c
@@ -263,7 +263,7 @@ struct page *ufs_get_locked_page(struct

lock_page(page);

- if (unlikely(page->mapping == NULL)) {
+ if (unlikely(!page_is_pagecache(page))) {
/* Truncate got there first */
unlock_page(page);
page_cache_release(page);

2007-09-10 10:34:35

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [34/35] changes in UNIONFS

Changes page->mapping handling in UNIONFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

---
fs/unionfs/mmap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/unionfs/mmap.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/unionfs/mmap.c
+++ test-2.6.23-rc4-mm1/fs/unionfs/mmap.c
@@ -61,7 +61,7 @@ static int unionfs_writepage(struct page
char *kaddr, *lower_kaddr;
int saved_for_writepages = wbc->for_writepages;

- inode = page->mapping->host;
+ inode = page_inode(page);
lower_inode = unionfs_lower_inode(inode);

/* find lower page (returns a locked page) */
@@ -225,7 +225,7 @@ static int unionfs_commit_write(struct f
if ((err = unionfs_file_revalidate(file, 1)))
goto out;

- inode = page->mapping->host;
+ inode = page_inode(page);
lower_inode = unionfs_lower_inode(inode);

if (UNIONFS_F(file) != NULL)
@@ -283,7 +283,7 @@ static void unionfs_sync_page(struct pag
struct page *lower_page;
struct address_space *mapping;

- inode = page->mapping->host;
+ inode = page_inode(page);
lower_inode = unionfs_lower_inode(inode);

/* find lower page (returns a locked page) */
@@ -292,7 +292,7 @@ static void unionfs_sync_page(struct pag
goto out;

/* do the actual sync */
- mapping = lower_page->mapping;
+ mapping = page_mapping_cache(lower_page);
/*
* XXX: can we optimize ala RAIF and set the lower page to be
* discarded after a successful sync_page?

2007-09-10 10:35:31

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [PATCH] add page->mapping handling interface [35/35] changes in XFS

Change page->mapping handling in XFS

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>


---
fs/xfs/linux-2.6/xfs_aops.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

Index: test-2.6.23-rc4-mm1/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- test-2.6.23-rc4-mm1.orig/fs/xfs/linux-2.6/xfs_aops.c
+++ test-2.6.23-rc4-mm1/fs/xfs/linux-2.6/xfs_aops.c
@@ -595,7 +595,7 @@ xfs_probe_page(
if (PageWriteback(page))
return 0;

- if (page->mapping && PageDirty(page)) {
+ if (page_mapping_cache(page) && PageDirty(page)) {
if (page_has_buffers(page)) {
struct buffer_head *bh, *head;

@@ -697,7 +697,7 @@ xfs_is_delayed_page(
if (PageWriteback(page))
return 0;

- if (page->mapping && page_has_buffers(page)) {
+ if (page_mapping_cache(page) && page_has_buffers(page)) {
struct buffer_head *bh, *head;
int acceptable = 0;

@@ -752,7 +752,7 @@ xfs_convert_page(
goto fail;
if (PageWriteback(page))
goto fail_unlock_page;
- if (page->mapping != inode->i_mapping)
+ if (pagecache_consistent(page, inode->i_mapping))
goto fail_unlock_page;
if (!xfs_is_delayed_page(page, (*ioendp)->io_type))
goto fail_unlock_page;
@@ -1178,7 +1178,7 @@ xfs_vm_writepage(
int error;
int need_trans;
int delalloc, unmapped, unwritten;
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);

xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);

@@ -1270,7 +1270,7 @@ xfs_vm_releasepage(
struct page *page,
gfp_t gfp_mask)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = page_inode(page);
int dirty, delalloc, unmapped, unwritten;
struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL,
@@ -1562,7 +1562,7 @@ xfs_vm_invalidatepage(
unsigned long offset)
{
xfs_page_trace(XFS_INVALIDPAGE_ENTER,
- page->mapping->host, page, offset);
+ page_inode(page), page, offset);
block_invalidatepage(page, offset);
}


2007-09-10 10:39:32

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: [PATCH] add page->mapping handling interface [22/35] changes in JFFS2

On Mon, 10 Sep 2007 11:19:51 +0100
David Woodhouse <[email protected]> wrote:

> On Mon, 2007-09-10 at 19:16 +0900, KAMEZAWA Hiroyuki wrote:
> > Changes page->mapping handling in JFFS2
> >
> > Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
>
> Looks reasonable to me; I assume it's not intended for me to take it and
> apply it yet, before the core parts are merged? I'll let you shepherd it
> upstream...
>
Ah, no. core patches are not merged. This patch's target is -mm, now.
I just CC:ed to each FS maintainers to show what this patch set does.

Thanks,
-Kame

2007-09-13 20:19:57

by Richard Knutsson

[permalink] [raw]
Subject: Re: [PATCH] add page->mapping handling interface [1/35] interface definitions

KAMEZAWA Hiroyuki wrote:
> - changes page->mapping from address_space* to unsigned long
> - add page_mapping_anon() function.
> - add linux/page-cache.h
> - add page_inode() function
> - add page_is_pagecache() function
> - add pagecaceh_consisten() function for pagecache consistency test.
> - expoterd swapper_space. inline function page_mapping() refers this.
>
> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
>
> ---
> include/linux/fs.h | 1 +
> include/linux/mm.h | 20 +++++++++++++++++---
> include/linux/mm_types.h | 2 +-
> include/linux/page-cache.h | 39 +++++++++++++++++++++++++++++++++++++++
> mm/swap_state.c | 2 ++
> 5 files changed, 60 insertions(+), 4 deletions(-)
>
> Index: test-2.6.23-rc4-mm1/include/linux/page-cache.h
> ===================================================================
> --- /dev/null
> +++ test-2.6.23-rc4-mm1/include/linux/page-cache.h
> @@ -0,0 +1,39 @@
> +/*
> + * For interface definitions between memory management and file systems.
> + * - This file defines small interface functions for handling page cache.
> + */
> +
> +#ifndef _LINUX_PAGECACHE_H
> +#define _LINUX_PAGECACHE_H
> +
> +#include <linux/mm.h>
> +/* page_mapping_xxx() function is defined in mm.h */
> +
> +static inline int page_is_pagecache(struct page *page)
>
Why return it as an 'int' instead of 'bool'?
> +{
> + if (!page->mapping || (page->mapping & PAGE_MAPPING_ANON))
> + return 0;
> + return 1;
> +}
>
Not easier with 'return page->mapping && (page->mapping &
PAGE_MAPPING_ANON) == 0;'?
> +
> +/*
> + * Return an inode this page belongs to
> + */
> +
> +static inline struct inode *page_inode(struct page *page)
> +{
> + if (!page_is_pagecache(page))
> + return NULL;
> + return page_mapping_cache(page)->host;
> +}
> +
> +/*
> + * Test a page is a page-cache of an address_space.
> + */
> +static inline int
> +pagecache_consistent(struct page *page, struct address_space *as)
> +{
> + return (page_mapping(page) == as);
> +}
> +
> +#endif
<snip>
> Index: test-2.6.23-rc4-mm1/include/linux/mm.h
> ===================================================================
> --- test-2.6.23-rc4-mm1.orig/include/linux/mm.h
> +++ test-2.6.23-rc4-mm1/include/linux/mm.h
> @@ -563,7 +563,7 @@ void page_address_init(void);
> extern struct address_space swapper_space;
> static inline struct address_space *page_mapping(struct page *page)
> {
> - struct address_space *mapping = page->mapping;
> + struct address_space *mapping = (struct address_space *)page->mapping;
>
> VM_BUG_ON(PageSlab(page));
> if (unlikely(PageSwapCache(page)))
> @@ -579,7 +579,21 @@ static inline struct address_space *page
>
> static inline int PageAnon(struct page *page)
>
Change to bool? Then "you" can also remove the '!!' from:
mm/memory.c:483: rss[!!PageAnon(page)]++;
> {
> - return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
> + return (page->mapping & PAGE_MAPPING_ANON) != 0;
> +}
> +
>
<snip>

If you don't mind bool(eans) (for some reason), I can/will check out the
rest.

Richard Knutsson

2007-09-14 01:04:54

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: [PATCH] add page->mapping handling interface [1/35] interface definitions

On Thu, 13 Sep 2007 22:19:20 +0200
Richard Knutsson <[email protected]> wrote:
> > +static inline int page_is_pagecache(struct page *page)
> >
> Why return it as an 'int' instead of 'bool'?
> > +{
> > + if (!page->mapping || (page->mapping & PAGE_MAPPING_ANON))
> > + return 0;
> > + return 1;
> > +}

Ah, I missed bool type just because I have no experience to use 'bool' in
Linux kernel. ok, will try in the next version. thank you.

> >
> Not easier with 'return page->mapping && (page->mapping &
> PAGE_MAPPING_ANON) == 0;'?
> > +

yours seems better.


>
> > static inline int PageAnon(struct page *page)
> >
> Change to bool? Then "you" can also remove the '!!' from:
> mm/memory.c:483: rss[!!PageAnon(page)]++;

Hmm, will try unless it makes diff big.

> > {
> > - return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
> > + return (page->mapping & PAGE_MAPPING_ANON) != 0;
> > +}
> > +
> >
> <snip>
>
> If you don't mind bool(eans) (for some reason), I can/will check out the
> rest.
>

Thank you. I'll try 'bool' type.

Regards,
-Kame