Merge branch 'master' into for_paulus
[linux-drm-fsl-dcu.git] / fs / gfs2 / locking / dlm / plock.c
index 382847205bc18edf5a1e9b9d5ca1a6065ffefbda..1dd4215b83d02133592033949bced668548102cc 100644 (file)
@@ -3,11 +3,12 @@
  *
  * 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/miscdevice.h>
 #include <linux/lock_dlm_plock.h>
+#include <linux/poll.h>
 
 #include "lock_dlm.h"
 
@@ -58,10 +59,10 @@ static void send_op(struct plock_op *op)
        wake_up(&send_wq);
 }
 
-int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
+int gdlm_plock(void *lockspace, struct lm_lockname *name,
               struct file *file, int cmd, struct file_lock *fl)
 {
-       struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
+       struct gdlm_ls *ls = lockspace;
        struct plock_op *op;
        int rv;
 
@@ -70,20 +71,21 @@ int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
                return -ENOMEM;
 
        op->info.optype         = GDLM_PLOCK_OP_LOCK;
-       op->info.pid            = (uint32_t) fl->fl_owner;
+       op->info.pid            = fl->fl_pid;
        op->info.ex             = (fl->fl_type == F_WRLCK);
        op->info.wait           = IS_SETLKW(cmd);
        op->info.fsid           = ls->id;
        op->info.number         = name->ln_number;
        op->info.start          = fl->fl_start;
        op->info.end            = fl->fl_end;
+       op->info.owner          = (__u64)(long) fl->fl_owner;
 
        send_op(op);
        wait_event(recv_wq, (op->done != 0));
 
        spin_lock(&ops_lock);
        if (!list_empty(&op->list)) {
-               printk("plock op on list\n");
+               printk(KERN_INFO "plock op on list\n");
                list_del(&op->list);
        }
        spin_unlock(&ops_lock);
@@ -93,17 +95,18 @@ int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
        if (!rv) {
                if (posix_lock_file_wait(file, fl) < 0)
                        log_error("gdlm_plock: vfs lock error %x,%llx",
-                                 name->ln_type, name->ln_number);
+                                 name->ln_type,
+                                 (unsigned long long)name->ln_number);
        }
 
        kfree(op);
        return rv;
 }
 
-int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
+int gdlm_punlock(void *lockspace, struct lm_lockname *name,
                 struct file *file, struct file_lock *fl)
 {
-       struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
+       struct gdlm_ls *ls = lockspace;
        struct plock_op *op;
        int rv;
 
@@ -113,21 +116,22 @@ int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
 
        if (posix_lock_file_wait(file, fl) < 0)
                log_error("gdlm_punlock: vfs unlock error %x,%llx",
-                         name->ln_type, name->ln_number);
+                         name->ln_type, (unsigned long long)name->ln_number);
 
        op->info.optype         = GDLM_PLOCK_OP_UNLOCK;
-       op->info.pid            = (uint32_t) fl->fl_owner;
+       op->info.pid            = fl->fl_pid;
        op->info.fsid           = ls->id;
        op->info.number         = name->ln_number;
        op->info.start          = fl->fl_start;
        op->info.end            = fl->fl_end;
+       op->info.owner          = (__u64)(long) fl->fl_owner;
 
        send_op(op);
        wait_event(recv_wq, (op->done != 0));
 
        spin_lock(&ops_lock);
        if (!list_empty(&op->list)) {
-               printk("punlock op on list\n");
+               printk(KERN_INFO "punlock op on list\n");
                list_del(&op->list);
        }
        spin_unlock(&ops_lock);
@@ -138,10 +142,10 @@ int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
        return rv;
 }
 
-int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
+int gdlm_plock_get(void *lockspace, struct lm_lockname *name,
                   struct file *file, struct file_lock *fl)
 {
-       struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
+       struct gdlm_ls *ls = lockspace;
        struct plock_op *op;
        int rv;
 
@@ -150,7 +154,7 @@ int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
                return -ENOMEM;
 
        op->info.optype         = GDLM_PLOCK_OP_GET;
-       op->info.pid            = (uint32_t) fl->fl_owner;
+       op->info.pid            = fl->fl_pid;
        op->info.ex             = (fl->fl_type == F_WRLCK);
        op->info.fsid           = ls->id;
        op->info.number         = name->ln_number;
@@ -162,7 +166,7 @@ int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
 
        spin_lock(&ops_lock);
        if (!list_empty(&op->list)) {
-               printk("plock_get op on list\n");
+               printk(KERN_INFO "plock_get op on list\n");
                list_del(&op->list);
        }
        spin_unlock(&ops_lock);
@@ -228,8 +232,8 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
 
        spin_lock(&ops_lock);
        list_for_each_entry(op, &recv_list, list) {
-               if (op->info.fsid == info.fsid &&
-                   op->info.number == info.number) {
+               if (op->info.fsid == info.fsid && op->info.number == info.number &&
+                   op->info.owner == info.owner) {
                        list_del_init(&op->list);
                        found = 1;
                        op->done = 1;
@@ -242,8 +246,8 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
        if (found)
                wake_up(&recv_wq);
        else
-               printk("gdlm dev_write no op %x %llx\n", info.fsid,
-                       info.number);
+               printk(KERN_INFO "gdlm dev_write no op %x %llx\n", info.fsid,
+                       (unsigned long long)info.number);
        return count;
 }
 
@@ -260,7 +264,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait)
        return 0;
 }
 
-static struct file_operations dev_fops = {
+static const struct file_operations dev_fops = {
        .read    = dev_read,
        .write   = dev_write,
        .poll    = dev_poll,
@@ -285,13 +289,14 @@ int gdlm_plock_init(void)
 
        rv = misc_register(&plock_dev_misc);
        if (rv)
-               printk("gdlm_plock_init: misc_register failed %d", rv);
+               printk(KERN_INFO "gdlm_plock_init: misc_register failed %d",
+                      rv);
        return rv;
 }
 
 void gdlm_plock_exit(void)
 {
        if (misc_deregister(&plock_dev_misc) < 0)
-               printk("gdlm_plock_exit: misc_deregister failed");
+               printk(KERN_INFO "gdlm_plock_exit: misc_deregister failed");
 }