Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[powerpc.git] / fs / gfs2 / ops_vm.c
index 08709f1..45a5f11 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
+ * of the GNU General Public License version 2.
  */
 
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "bmap.h"
 #include "glock.h"
 #include "inode.h"
 #include "ops_vm.h"
-#include "page.h"
 #include "quota.h"
 #include "rgrp.h"
 #include "trans.h"
@@ -47,13 +46,7 @@ static struct page *gfs2_private_nopage(struct vm_area_struct *area,
                                        unsigned long address, int *type)
 {
        struct gfs2_inode *ip = GFS2_I(area->vm_file->f_mapping->host);
-       struct gfs2_holder i_gh;
        struct page *result;
-       int error;
-
-       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
-       if (error)
-               return NULL;
 
        set_bit(GIF_PAGED, &ip->i_flags);
 
@@ -62,8 +55,6 @@ static struct page *gfs2_private_nopage(struct vm_area_struct *area,
        if (result && result != NOPAGE_OOM)
                pfault_be_greedy(ip);
 
-       gfs2_glock_dq_uninit(&i_gh);
-
        return result;
 }
 
@@ -71,7 +62,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        unsigned long index = page->index;
-       uint64_t lblock = index << (PAGE_CACHE_SHIFT -
+       u64 lblock = index << (PAGE_CACHE_SHIFT -
                                    sdp->sd_sb.sb_bsize_shift);
        unsigned int blocks = PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift;
        struct gfs2_alloc *al;
@@ -85,7 +76,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
+       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
        if (error)
                goto out_gunlock_q;
 
@@ -104,13 +95,13 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
                goto out_ipres;
 
        if (gfs2_is_stuffed(ip)) {
-               error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page, NULL);
+               error = gfs2_unstuff_dinode(ip, NULL);
                if (error)
                        goto out_trans;
        }
 
        for (x = 0; x < blocks; ) {
-               uint64_t dblock;
+               u64 dblock;
                unsigned int extlen;
                int new = 1;
 
@@ -124,25 +115,23 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
 
        gfs2_assert_warn(sdp, al->al_alloced);
 
- out_trans:
+out_trans:
        gfs2_trans_end(sdp);
-
- out_ipres:
+out_ipres:
        gfs2_inplace_release(ip);
-
- out_gunlock_q:
+out_gunlock_q:
        gfs2_quota_unlock(ip);
-
- out:
+out:
        gfs2_alloc_put(ip);
-
        return error;
 }
 
 static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area,
                                           unsigned long address, int *type)
 {
-       struct gfs2_inode *ip = GFS2_I(area->vm_file->f_mapping->host);
+       struct file *file = area->vm_file;
+       struct gfs2_file *gf = file->private_data;
+       struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
        struct gfs2_holder i_gh;
        struct page *result = NULL;
        unsigned long index = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) +
@@ -157,13 +146,14 @@ static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area,
        set_bit(GIF_PAGED, &ip->i_flags);
        set_bit(GIF_SW_PAGED, &ip->i_flags);
 
-       error = gfs2_write_alloc_required(ip,
-                                         (uint64_t)index << PAGE_CACHE_SHIFT,
+       error = gfs2_write_alloc_required(ip, (u64)index << PAGE_CACHE_SHIFT,
                                          PAGE_CACHE_SIZE, &alloc_required);
        if (error)
                goto out;
 
+       set_bit(GFF_EXLOCK, &gf->f_flags);
        result = filemap_nopage(area, address, type);
+       clear_bit(GFF_EXLOCK, &gf->f_flags);
        if (!result || result == NOPAGE_OOM)
                goto out;
 
@@ -178,8 +168,7 @@ static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area,
        }
 
        pfault_be_greedy(ip);
-
- out:
+out:
        gfs2_glock_dq_uninit(&i_gh);
 
        return result;