]> err.no Git - linux-2.6/blobdiff - fs/dlm/user.c
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
[linux-2.6] / fs / dlm / user.c
index c3060458b68e59325ce591b6314330396a8608e6..929e48ae7591199cc0e6e4c80eb4516c939bfd60 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/poll.h>
 #include <linux/signal.h>
 #include <linux/spinlock.h>
+#include <linux/smp_lock.h>
 #include <linux/dlm.h>
 #include <linux/dlm_device.h>
 
@@ -195,8 +196,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
        if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
                goto out;
 
-       DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb););
-       ua = (struct dlm_user_args *)lkb->lkb_astparam;
+       DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););
+       ua = lkb->lkb_ua;
        proc = ua->proc;
 
        if (type == AST_BAST && ua->bastaddr == NULL)
@@ -538,7 +539,7 @@ static ssize_t device_write(struct file *file, const char __user *buf,
 
        /* do we really need this? can a write happen after a close? */
        if ((kbuf->cmd == DLM_USER_LOCK || kbuf->cmd == DLM_USER_UNLOCK) &&
-           test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags))
+           (proc && test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags)))
                return -EINVAL;
 
        sigfillset(&allsigs);
@@ -618,13 +619,17 @@ static int device_open(struct inode *inode, struct file *file)
        struct dlm_user_proc *proc;
        struct dlm_ls *ls;
 
+       lock_kernel();
        ls = dlm_find_lockspace_device(iminor(inode));
-       if (!ls)
+       if (!ls) {
+               unlock_kernel();
                return -ENOENT;
+       }
 
        proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL);
        if (!proc) {
                dlm_put_lockspace(ls);
+               unlock_kernel();
                return -ENOMEM;
        }
 
@@ -636,6 +641,7 @@ static int device_open(struct inode *inode, struct file *file)
        spin_lock_init(&proc->locks_spin);
        init_waitqueue_head(&proc->wait);
        file->private_data = proc;
+       unlock_kernel();
 
        return 0;
 }
@@ -771,7 +777,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
 {
        struct dlm_user_proc *proc = file->private_data;
        struct dlm_lkb *lkb;
-       struct dlm_user_args *ua;
        DECLARE_WAITQUEUE(wait, current);
        int error, type=0, bmode=0, removed = 0;
 
@@ -842,8 +847,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
        }
        spin_unlock(&proc->asts_spin);
 
-       ua = (struct dlm_user_args *)lkb->lkb_astparam;
-       error = copy_result_to_user(ua,
+       error = copy_result_to_user(lkb->lkb_ua,
                                test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags),
                                type, bmode, buf, count);
 
@@ -872,6 +876,7 @@ static unsigned int device_poll(struct file *file, poll_table *wait)
 
 static int ctl_device_open(struct inode *inode, struct file *file)
 {
+       cycle_kernel_lock();
        file->private_data = NULL;
        return 0;
 }
@@ -904,7 +909,7 @@ static struct miscdevice ctl_device = {
        .minor = MISC_DYNAMIC_MINOR,
 };
 
-int dlm_user_init(void)
+int __init dlm_user_init(void)
 {
        int error;