[GFS2] Add generation number
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / gfs2 / page.c
index 3542aa6b01c4355b4dd224018200a32fb69b7ddd..b93caf294b9f49e7e6429bf2fcc3cb3e3d42acdb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
  *
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/mm.h>
-#include <asm/semaphore.h>
+#include <linux/gfs2_ondisk.h>
 
 #include "gfs2.h"
+#include "lm_interface.h"
+#include "incore.h"
 #include "bmap.h"
 #include "inode.h"
 #include "page.h"
 #include "trans.h"
 #include "ops_address.h"
+#include "util.h"
 
 /**
  * gfs2_pte_inval - Sync and invalidate all PTEs associated with a glock
@@ -34,21 +37,18 @@ void gfs2_pte_inval(struct gfs2_glock *gl)
        struct gfs2_inode *ip;
        struct inode *inode;
 
-       ip = get_gl2ip(gl);
+       ip = gl->gl_object;
+       inode = &ip->i_inode;
        if (!ip || !S_ISREG(ip->i_di.di_mode))
                return;
 
        if (!test_bit(GIF_PAGED, &ip->i_flags))
                return;
 
-       inode = gfs2_ip2v_lookup(ip);
-       if (inode) {
-               unmap_shared_mapping_range(inode->i_mapping, 0, 0);
-               iput(inode);
+       unmap_shared_mapping_range(inode->i_mapping, 0, 0);
 
-               if (test_bit(GIF_SW_PAGED, &ip->i_flags))
-                       set_bit(GLF_DIRTY, &gl->gl_flags);
-       }
+       if (test_bit(GIF_SW_PAGED, &ip->i_flags))
+               set_bit(GLF_DIRTY, &gl->gl_flags);
 
        clear_bit(GIF_SW_PAGED, &ip->i_flags);
 }
@@ -64,20 +64,13 @@ void gfs2_page_inval(struct gfs2_glock *gl)
        struct gfs2_inode *ip;
        struct inode *inode;
 
-       ip = get_gl2ip(gl);
+       ip = gl->gl_object;
+       inode = &ip->i_inode;
        if (!ip || !S_ISREG(ip->i_di.di_mode))
                return;
 
-       inode = gfs2_ip2v_lookup(ip);
-       if (inode) {
-               struct address_space *mapping = inode->i_mapping;
-
-               truncate_inode_pages(mapping, 0);
-               gfs2_assert_withdraw(ip->i_sbd, !mapping->nrpages);
-
-               iput(inode);
-       }
-
+       truncate_inode_pages(inode->i_mapping, 0);
+       gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages);
        clear_bit(GIF_PAGED, &ip->i_flags);
 }
 
@@ -94,32 +87,30 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags)
 {
        struct gfs2_inode *ip;
        struct inode *inode;
+       struct address_space *mapping;
+       int error = 0;
 
-       ip = get_gl2ip(gl);
+       ip = gl->gl_object;
+       inode = &ip->i_inode;
        if (!ip || !S_ISREG(ip->i_di.di_mode))
                return;
 
-       inode = gfs2_ip2v_lookup(ip);
-       if (inode) {
-               struct address_space *mapping = inode->i_mapping;
-               int error = 0;
+       mapping = inode->i_mapping;
 
-               if (flags & DIO_START)
-                       filemap_fdatawrite(mapping);
-               if (!error && (flags & DIO_WAIT))
-                       error = filemap_fdatawait(mapping);
+       if (flags & DIO_START)
+               filemap_fdatawrite(mapping);
+       if (!error && (flags & DIO_WAIT))
+               error = filemap_fdatawait(mapping);
 
-               /* Put back any errors cleared by filemap_fdatawait()
-                  so they can be caught by someone who can pass them
-                  up to user space. */
+       /* Put back any errors cleared by filemap_fdatawait()
+          so they can be caught by someone who can pass them
+          up to user space. */
 
-               if (error == -ENOSPC)
-                       set_bit(AS_ENOSPC, &mapping->flags);
-               else if (error)
-                       set_bit(AS_EIO, &mapping->flags);
+       if (error == -ENOSPC)
+               set_bit(AS_ENOSPC, &mapping->flags);
+       else if (error)
+               set_bit(AS_EIO, &mapping->flags);
 
-               iput(inode);
-       }
 }
 
 /**
@@ -135,8 +126,8 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags)
 int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
                        uint64_t block, void *private)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
-       struct inode *inode = ip->i_vnode;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       struct inode *inode = &ip->i_inode;
        struct page *page = (struct page *)private;
        struct buffer_head *bh;
        int release = 0;
@@ -151,11 +142,9 @@ int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
        if (!PageUptodate(page)) {
                void *kaddr = kmap(page);
 
-               memcpy(kaddr,
-                      dibh->b_data + sizeof(struct gfs2_dinode),
+               memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
                       ip->i_di.di_size);
-               memset(kaddr + ip->i_di.di_size,
-                      0,
+               memset(kaddr + ip->i_di.di_size, 0,
                       PAGE_CACHE_SIZE - ip->i_di.di_size);
                kunmap(page);
 
@@ -192,8 +181,8 @@ int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 int gfs2_block_truncate_page(struct address_space *mapping)
 {
        struct inode *inode = mapping->host;
-       struct gfs2_inode *ip = get_v2ip(inode);
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_inode *ip = GFS2_I(inode);
+       struct gfs2_sbd *sdp = GFS2_SB(inode);
        loff_t from = inode->i_size;
        unsigned long index = from >> PAGE_CACHE_SHIFT;
        unsigned offset = from & (PAGE_CACHE_SIZE-1);
@@ -267,8 +256,7 @@ void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
        struct buffer_head *bh;
        unsigned int start, end;
 
-       for (bh = head, start = 0;
-            bh != head || !start;
+       for (bh = head, start = 0; bh != head || !start;
             bh = bh->b_this_page, start = end) {
                end = start + bsize;
                if (end <= from || start >= to)