Remove BKL from remote_llseek v2
[pandora-kernel.git] / fs / gfs2 / ops_file.c
index ad5daaa..24dd594 100644 (file)
@@ -30,7 +30,6 @@
 #include "glock.h"
 #include "glops.h"
 #include "inode.h"
-#include "lm.h"
 #include "log.h"
 #include "meta_io.h"
 #include "quota.h"
@@ -39,6 +38,7 @@
 #include "util.h"
 #include "eaops.h"
 #include "ops_address.h"
+#include "ops_inode.h"
 
 /**
  * gfs2_llseek - seek to a location in a file
@@ -62,11 +62,11 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
                error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
                                           &i_gh);
                if (!error) {
-                       error = remote_llseek(file, offset, origin);
+                       error = generic_file_llseek_unlocked(file, offset, origin);
                        gfs2_glock_dq_uninit(&i_gh);
                }
        } else
-               error = remote_llseek(file, offset, origin);
+               error = generic_file_llseek_unlocked(file, offset, origin);
 
        return error;
 }
@@ -323,7 +323,7 @@ static int gfs2_allocate_page_backing(struct page *page)
        do {
                bh.b_state = 0;
                bh.b_size = size;
-               gfs2_block_map(inode, lblock, 1, &bh);
+               gfs2_block_map(inode, lblock, &bh, 1);
                if (!buffer_mapped(&bh))
                        return -EIO;
                size -= bh.b_size;
@@ -364,15 +364,14 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
        ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required);
        if (ret || !alloc_required)
                goto out_unlock;
-
-       ip->i_alloc.al_requested = 0;
+       ret = -ENOMEM;
        al = gfs2_alloc_get(ip);
-       ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       if (al == NULL)
+               goto out_unlock;
+
+       ret = gfs2_quota_lock_check(ip);
        if (ret)
                goto out_alloc_put;
-       ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
-       if (ret)
-               goto out_quota_unlock;
        al->al_requested = data_blocks + ind_blocks;
        ret = gfs2_inplace_reserve(ip);
        if (ret)
@@ -392,6 +391,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
        last_index = ip->i_inode.i_size >> PAGE_CACHE_SHIFT;
        if (page->index > last_index)
                goto out_unlock_page;
+       ret = 0;
        if (!PageUptodate(page) || page->mapping != ip->i_inode.i_mapping)
                goto out_unlock_page;
        if (gfs2_is_stuffed(ip)) {
@@ -593,6 +593,36 @@ static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
        return generic_setlease(file, arg, fl);
 }
 
+static int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name,
+                     struct file *file, struct file_lock *fl)
+{
+       int error = -EIO;
+       if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+               error = sdp->sd_lockstruct.ls_ops->lm_plock_get(
+                               sdp->sd_lockstruct.ls_lockspace, name, file, fl);
+       return error;
+}
+
+static int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+                 struct file *file, int cmd, struct file_lock *fl)
+{
+       int error = -EIO;
+       if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+               error = sdp->sd_lockstruct.ls_ops->lm_plock(
+                               sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl);
+       return error;
+}
+
+static int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+                   struct file *file, struct file_lock *fl)
+{
+       int error = -EIO;
+       if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+               error = sdp->sd_lockstruct.ls_ops->lm_punlock(
+                               sdp->sd_lockstruct.ls_lockspace, name, file, fl);
+       return error;
+}
+
 /**
  * gfs2_lock - acquire/release a posix lock on a file
  * @file: the file pointer
@@ -615,15 +645,6 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
        if (__mandatory_lock(&ip->i_inode))
                return -ENOLCK;
 
-       if (sdp->sd_args.ar_localflocks) {
-               if (IS_GETLK(cmd)) {
-                       posix_test_lock(file, fl);
-                       return 0;
-               } else {
-                       return posix_lock_file_wait(file, fl);
-               }
-       }
-
        if (cmd == F_CANCELLK) {
                /* Hack: */
                cmd = F_SETLK;
@@ -709,16 +730,12 @@ static void do_unflock(struct file *file, struct file_lock *fl)
 static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
 {
        struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
-       struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
 
        if (!(fl->fl_flags & FL_FLOCK))
                return -ENOLCK;
        if (__mandatory_lock(&ip->i_inode))
                return -ENOLCK;
 
-       if (sdp->sd_args.ar_localflocks)
-               return flock_lock_file_wait(file, fl);
-
        if (fl->fl_type == F_UNLCK) {
                do_unflock(file, fl);
                return 0;
@@ -755,3 +772,27 @@ const struct file_operations gfs2_dir_fops = {
        .flock          = gfs2_flock,
 };
 
+const struct file_operations gfs2_file_fops_nolock = {
+       .llseek         = gfs2_llseek,
+       .read           = do_sync_read,
+       .aio_read       = generic_file_aio_read,
+       .write          = do_sync_write,
+       .aio_write      = generic_file_aio_write,
+       .unlocked_ioctl = gfs2_ioctl,
+       .mmap           = gfs2_mmap,
+       .open           = gfs2_open,
+       .release        = gfs2_close,
+       .fsync          = gfs2_fsync,
+       .splice_read    = generic_file_splice_read,
+       .splice_write   = generic_file_splice_write,
+       .setlease       = gfs2_setlease,
+};
+
+const struct file_operations gfs2_dir_fops_nolock = {
+       .readdir        = gfs2_readdir,
+       .unlocked_ioctl = gfs2_ioctl,
+       .open           = gfs2_open,
+       .release        = gfs2_close,
+       .fsync          = gfs2_fsync,
+};
+