nilfs2: always set back pointer to host inode in mapping->host
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Thu, 5 May 2011 03:56:51 +0000 (12:56 +0900)
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tue, 10 May 2011 13:21:57 +0000 (22:21 +0900)
In the current nilfs, page cache for btree nodes and meta data files
do not set a valid back pointer to the host inode in mapping->host.

This will change it so that every address space in nilfs uses
mapping->host to hold its host inode.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
fs/nilfs2/btnode.c
fs/nilfs2/btnode.h
fs/nilfs2/mdt.c
fs/nilfs2/nilfs.h
fs/nilfs2/page.c
fs/nilfs2/page.h
fs/nilfs2/segment.c
fs/nilfs2/super.c

index 4817560424236ec6c5456a573e0d131834daacc9..c353e4fa600cd1336d7c9127031c344887c11795 100644 (file)
 #include "page.h"
 #include "btnode.h"
 
-void nilfs_btnode_cache_init(struct address_space *btnc,
-                            struct backing_dev_info *bdi)
-{
-       nilfs_mapping_init(btnc, bdi);
-}
-
 void nilfs_btnode_cache_clear(struct address_space *btnc)
 {
        invalidate_mapping_pages(btnc, 0, -1);
index 1b8ebd888c2844348a128a37e0781c1b82915aea..7de449c2e2a30d119908e8e9903b342b9d05c8e3 100644 (file)
@@ -37,7 +37,6 @@ struct nilfs_btnode_chkey_ctxt {
        struct buffer_head *newbh;
 };
 
-void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *);
 void nilfs_btnode_cache_clear(struct address_space *);
 struct buffer_head *nilfs_btnode_create_block(struct address_space *btnc,
                                              __u64 blocknr);
index a649b05f7069db7b0beb31b7ebf10e5639a245bd..6790ca689c174fcc5214dd8a6f2ad453092608db 100644 (file)
@@ -450,9 +450,9 @@ int nilfs_mdt_setup_shadow_map(struct inode *inode,
 
        INIT_LIST_HEAD(&shadow->frozen_buffers);
        address_space_init_once(&shadow->frozen_data);
-       nilfs_mapping_init(&shadow->frozen_data, bdi);
+       nilfs_mapping_init(&shadow->frozen_data, inode, bdi);
        address_space_init_once(&shadow->frozen_btnodes);
-       nilfs_mapping_init(&shadow->frozen_btnodes, bdi);
+       nilfs_mapping_init(&shadow->frozen_btnodes, inode, bdi);
        mi->mi_shadow = shadow;
        return 0;
 }
index 09af00999ec004075afaad92d04a3a45914f3873..a9c6a531f80c5786ce628e3cbf0bd331ba86141f 100644 (file)
@@ -80,12 +80,6 @@ static inline struct inode *NILFS_BTNC_I(struct address_space *btnc)
        return &ii->vfs_inode;
 }
 
-static inline struct inode *NILFS_AS_I(struct address_space *mapping)
-{
-       return (mapping->host) ? :
-               container_of(mapping, struct inode, i_data);
-}
-
 /*
  * Dynamic state flags of NILFS on-memory inode (i_state)
  */
index b3b988c2018fac7d684a6dad528ec8cb4ddb6006..3f18f5c076e89763765fd82467ee9632e94911c7 100644 (file)
@@ -182,7 +182,7 @@ int nilfs_page_buffers_clean(struct page *page)
 void nilfs_page_bug(struct page *page)
 {
        struct address_space *m;
-       unsigned long ino = 0;
+       unsigned long ino;
 
        if (unlikely(!page)) {
                printk(KERN_CRIT "NILFS_PAGE_BUG(NULL)\n");
@@ -190,11 +190,8 @@ void nilfs_page_bug(struct page *page)
        }
 
        m = page->mapping;
-       if (m) {
-               struct inode *inode = NILFS_AS_I(m);
-               if (inode != NULL)
-                       ino = inode->i_ino;
-       }
+       ino = m ? m->host->i_ino : 0;
+
        printk(KERN_CRIT "NILFS_PAGE_BUG(%p): cnt=%d index#=%llu flags=0x%lx "
               "mapping=%p ino=%lu\n",
               page, atomic_read(&page->_count),
@@ -441,10 +438,10 @@ unsigned nilfs_page_count_clean_buffers(struct page *page,
        return nc;
 }
 
-void nilfs_mapping_init(struct address_space *mapping,
+void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
                        struct backing_dev_info *bdi)
 {
-       mapping->host = NULL;
+       mapping->host = inode;
        mapping->flags = 0;
        mapping_set_gfp_mask(mapping, GFP_NOFS);
        mapping->assoc_mapping = NULL;
index f827afabd548739478bdaeb8b2d643f77e0ca5d9..e301e5661c367c88b3713cfa13deef3a38c38526 100644 (file)
@@ -57,7 +57,7 @@ void nilfs_page_bug(struct page *);
 int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
 void nilfs_copy_back_pages(struct address_space *, struct address_space *);
 void nilfs_clear_dirty_pages(struct address_space *);
-void nilfs_mapping_init(struct address_space *mapping,
+void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
                        struct backing_dev_info *bdi);
 unsigned nilfs_page_count_clean_buffers(struct page *, unsigned, unsigned);
 unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
index 186cabbe54d7001ace29d8a5e8b81ec346bd64af..eeb1bc2c76ca26867753a37ef39704528649b683 100644 (file)
@@ -655,13 +655,10 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
                if (unlikely(page->index > last))
                        break;
 
-               if (mapping->host) {
-                       lock_page(page);
-                       if (!page_has_buffers(page))
-                               create_empty_buffers(page,
-                                                    1 << inode->i_blkbits, 0);
-                       unlock_page(page);
-               }
+               lock_page(page);
+               if (!page_has_buffers(page))
+                       create_empty_buffers(page, 1 << inode->i_blkbits, 0);
+               unlock_page(page);
 
                bh = head = page_buffers(page);
                do {
@@ -1503,10 +1500,7 @@ nilfs_segctor_update_payload_blocknr(struct nilfs_sc_info *sci,
                        nblocks = le32_to_cpu(finfo->fi_nblocks);
                        ndatablk = le32_to_cpu(finfo->fi_ndatablk);
 
-                       if (buffer_nilfs_node(bh))
-                               inode = NILFS_BTNC_I(bh->b_page->mapping);
-                       else
-                               inode = NILFS_AS_I(bh->b_page->mapping);
+                       inode = bh->b_page->mapping->host;
 
                        if (mode == SC_LSEG_DSYNC)
                                sc_op = &nilfs_sc_dsync_ops;
index 2846491071ce8415eb82474c35da568a79bf70d2..8351c44a7320f06902bf03dcc114ade367c22fbe 100644 (file)
@@ -166,7 +166,7 @@ struct inode *nilfs_alloc_inode(struct super_block *sb)
        ii->i_state = 0;
        ii->i_cno = 0;
        ii->vfs_inode.i_version = 1;
-       nilfs_btnode_cache_init(&ii->i_btnode_cache, sb->s_bdi);
+       nilfs_mapping_init(&ii->i_btnode_cache, &ii->vfs_inode, sb->s_bdi);
        return &ii->vfs_inode;
 }