Pull ia64-clocksource into release branch
[pandora-kernel.git] / fs / gfs2 / ops_file.c
index b50180e..1a5e8e8 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/uio.h>
 #include <linux/blkdev.h>
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/ext2_fs.h>
@@ -489,6 +488,29 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
        return ret;
 }
 
+/**
+ * gfs2_setlease - acquire/release a file lease
+ * @file: the file pointer
+ * @arg: lease type
+ * @fl: file lock
+ *
+ * Returns: errno
+ */
+
+static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
+{
+       struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
+
+       /*
+        * We don't currently have a way to enforce a lease across the whole
+        * cluster; until we do, disable leases (by just returning -EINVAL),
+        * unless the administrator has requested purely local locking.
+        */
+       if (!sdp->sd_args.ar_localflocks)
+               return -EINVAL;
+       return setlease(file, arg, fl);
+}
+
 /**
  * gfs2_lock - acquire/release a posix lock on a file
  * @file: the file pointer
@@ -503,7 +525,7 @@ static int gfs2_lock(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);
        struct lm_lockname name =
-               { .ln_number = ip->i_num.no_addr,
+               { .ln_number = ip->i_no_addr,
                  .ln_type = LM_TYPE_PLOCK };
 
        if (!(fl->fl_flags & FL_POSIX))
@@ -513,18 +535,18 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
 
        if (sdp->sd_args.ar_localflocks) {
                if (IS_GETLK(cmd)) {
-                       struct file_lock tmp;
-                       int ret;
-                       ret = posix_test_lock(file, fl, &tmp);
-                       fl->fl_type = F_UNLCK;
-                       if (ret)
-                               memcpy(fl, &tmp, sizeof(struct file_lock));
+                       posix_test_lock(file, fl);
                        return 0;
                } else {
                        return posix_lock_file_wait(file, fl);
                }
        }
 
+       if (cmd == F_CANCELLK) {
+               /* Hack: */
+               cmd = F_SETLK;
+               fl->fl_type = F_UNLCK;
+       }
        if (IS_GETLK(cmd))
                return gfs2_lm_plock_get(sdp, &name, file, fl);
        else if (fl->fl_type == F_UNLCK)
@@ -558,7 +580,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
                gfs2_glock_dq_uninit(fl_gh);
        } else {
                error = gfs2_glock_get(GFS2_SB(&ip->i_inode),
-                                     ip->i_num.no_addr, &gfs2_flock_glops,
+                                     ip->i_no_addr, &gfs2_flock_glops,
                                      CREATE, &gl);
                if (error)
                        goto out;
@@ -636,10 +658,10 @@ const struct file_operations gfs2_file_fops = {
        .release        = gfs2_close,
        .fsync          = gfs2_fsync,
        .lock           = gfs2_lock,
-       .sendfile       = generic_file_sendfile,
        .flock          = gfs2_flock,
        .splice_read    = generic_file_splice_read,
        .splice_write   = generic_file_splice_write,
+       .setlease       = gfs2_setlease,
 };
 
 const struct file_operations gfs2_dir_fops = {