]> Pileus Git - ~andy/linux/blobdiff - fs/gfs2/locking/nolock/main.c
[GFS2] Export lm_interface to kernel headers
[~andy/linux] / fs / gfs2 / locking / nolock / main.c
index b716e336c0732ff599fcf17c1c1964b28e398497..acfbc941f31950c87323928cd6d48d82082f2685 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/module.h>
 #include <linux/types.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
-
-#include "../../lm_interface.h"
+#include <linux/lm_interface.h>
 
 struct nolock_lockspace {
        unsigned int nl_lvb_size;
 };
 
-struct lm_lockops nolock_ops;
+static const struct lm_lockops nolock_ops;
 
 static int nolock_mount(char *table_name, char *host_data,
-                       lm_callback_t cb, lm_fsdata_t *fsdata,
+                       lm_callback_t cb, void *cb_data,
                        unsigned int min_lvb_size, int flags,
                        struct lm_lockstruct *lockstruct,
                        struct kobject *fskobj)
@@ -33,9 +32,6 @@ static int nolock_mount(char *table_name, char *host_data,
        unsigned int jid;
        struct nolock_lockspace *nl;
 
-       /* If there is a "jid=" in the hostdata, return that jid.
-          Otherwise, return zero. */
-
        c = strstr(host_data, "jid=");
        if (!c)
                jid = 0;
@@ -44,34 +40,33 @@ static int nolock_mount(char *table_name, char *host_data,
                sscanf(c, "%u", &jid);
        }
 
-       nl = kmalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
+       nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
        if (!nl)
                return -ENOMEM;
 
-       memset(nl, 0, sizeof(struct nolock_lockspace));
        nl->nl_lvb_size = min_lvb_size;
 
        lockstruct->ls_jid = jid;
        lockstruct->ls_first = 1;
        lockstruct->ls_lvb_size = min_lvb_size;
-       lockstruct->ls_lockspace = (lm_lockspace_t *)nl;
+       lockstruct->ls_lockspace = nl;
        lockstruct->ls_ops = &nolock_ops;
        lockstruct->ls_flags = LM_LSFLAG_LOCAL;
 
        return 0;
 }
 
-static void nolock_others_may_mount(lm_lockspace_t *lockspace)
+static void nolock_others_may_mount(void *lockspace)
 {
 }
 
-static void nolock_unmount(lm_lockspace_t *lockspace)
+static void nolock_unmount(void *lockspace)
 {
-       struct nolock_lockspace *nl = (struct nolock_lockspace *)lockspace;
+       struct nolock_lockspace *nl = lockspace;
        kfree(nl);
 }
 
-static void nolock_withdraw(lm_lockspace_t *lockspace)
+static void nolock_withdraw(void *lockspace)
 {
 }
 
@@ -84,10 +79,10 @@ static void nolock_withdraw(lm_lockspace_t *lockspace)
  * Returns: 0 on success, -EXXX on failure
  */
 
-static int nolock_get_lock(lm_lockspace_t *lockspace, struct lm_lockname *name,
-                          lm_lock_t **lockp)
+static int nolock_get_lock(void *lockspace, struct lm_lockname *name,
+                          void **lockp)
 {
-       *lockp = (lm_lock_t *)lockspace;
+       *lockp = lockspace;
        return 0;
 }
 
@@ -97,7 +92,7 @@ static int nolock_get_lock(lm_lockspace_t *lockspace, struct lm_lockname *name,
  *
  */
 
-static void nolock_put_lock(lm_lock_t *lock)
+static void nolock_put_lock(void *lock)
 {
 }
 
@@ -111,7 +106,7 @@ static void nolock_put_lock(lm_lock_t *lock)
  * Returns: A bitmap of LM_OUT_*
  */
 
-static unsigned int nolock_lock(lm_lock_t *lock, unsigned int cur_state,
+static unsigned int nolock_lock(void *lock, unsigned int cur_state,
                                unsigned int req_state, unsigned int flags)
 {
        return req_state | LM_OUT_CACHEABLE;
@@ -125,12 +120,12 @@ static unsigned int nolock_lock(lm_lock_t *lock, unsigned int cur_state,
  * Returns: 0
  */
 
-static unsigned int nolock_unlock(lm_lock_t *lock, unsigned int cur_state)
+static unsigned int nolock_unlock(void *lock, unsigned int cur_state)
 {
        return 0;
 }
 
-static void nolock_cancel(lm_lock_t *lock)
+static void nolock_cancel(void *lock)
 {
 }
 
@@ -142,15 +137,13 @@ static void nolock_cancel(lm_lock_t *lock)
  * Returns: 0 on success, -EXXX on failure
  */
 
-static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp)
+static int nolock_hold_lvb(void *lock, char **lvbp)
 {
-       struct nolock_lockspace *nl = (struct nolock_lockspace *)lock;
+       struct nolock_lockspace *nl = lock;
        int error = 0;
 
-       *lvbp = kmalloc(nl->nl_lvb_size, GFP_KERNEL);
-       if (*lvbp)
-               memset(*lvbp, 0, nl->nl_lvb_size);
-       else
+       *lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL);
+       if (!*lvbp)
                error = -ENOMEM;
 
        return error;
@@ -163,63 +156,47 @@ static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp)
  *
  */
 
-static void nolock_unhold_lvb(lm_lock_t *lock, char *lvb)
+static void nolock_unhold_lvb(void *lock, char *lvb)
 {
        kfree(lvb);
 }
 
-/**
- * nolock_sync_lvb - sync out the value of a lvb
- * @lock: the lock the LVB is associated with
- * @lvb: the lock value block
- *
- */
-
-static void nolock_sync_lvb(lm_lock_t *lock, char *lvb)
-{
-}
-
-static int nolock_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
+static int nolock_plock_get(void *lockspace, struct lm_lockname *name,
                            struct file *file, struct file_lock *fl)
 {
-       struct file_lock *tmp;
+       struct file_lock tmp;
+       int ret;
 
-       lock_kernel();
-       tmp = posix_test_lock(file, fl);
+       ret = posix_test_lock(file, fl, &tmp);
        fl->fl_type = F_UNLCK;
-       if (tmp)
-               memcpy(fl, tmp, sizeof(struct file_lock));
-       unlock_kernel();
+       if (ret)
+               memcpy(fl, &tmp, sizeof(struct file_lock));
 
        return 0;
 }
 
-static int nolock_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
+static int nolock_plock(void *lockspace, struct lm_lockname *name,
                        struct file *file, int cmd, struct file_lock *fl)
 {
        int error;
-       lock_kernel();
        error = posix_lock_file_wait(file, fl);
-       unlock_kernel();
        return error;
 }
 
-static int nolock_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
+static int nolock_punlock(void *lockspace, struct lm_lockname *name,
                          struct file *file, struct file_lock *fl)
 {
        int error;
-       lock_kernel();
        error = posix_lock_file_wait(file, fl);
-       unlock_kernel();
        return error;
 }
 
-static void nolock_recovery_done(lm_lockspace_t *lockspace, unsigned int jid,
+static void nolock_recovery_done(void *lockspace, unsigned int jid,
                                 unsigned int message)
 {
 }
 
-struct lm_lockops nolock_ops = {
+static const struct lm_lockops nolock_ops = {
        .lm_proto_name = "lock_nolock",
        .lm_mount = nolock_mount,
        .lm_others_may_mount = nolock_others_may_mount,
@@ -232,7 +209,6 @@ struct lm_lockops nolock_ops = {
        .lm_cancel = nolock_cancel,
        .lm_hold_lvb = nolock_hold_lvb,
        .lm_unhold_lvb = nolock_unhold_lvb,
-       .lm_sync_lvb = nolock_sync_lvb,
        .lm_plock_get = nolock_plock_get,
        .lm_plock = nolock_plock,
        .lm_punlock = nolock_punlock,
@@ -240,23 +216,25 @@ struct lm_lockops nolock_ops = {
        .lm_owner = THIS_MODULE,
 };
 
-int __init init_nolock(void)
+static int __init init_nolock(void)
 {
        int error;
 
-       error = gfs_register_lockproto(&nolock_ops);
+       error = gfs2_register_lockproto(&nolock_ops);
        if (error) {
-               printk("lock_nolock: can't register protocol: %d\n", error);
+               printk(KERN_WARNING
+                      "lock_nolock: can't register protocol: %d\n", error);
                return error;
        }
 
-       printk("Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__);
+       printk(KERN_INFO
+              "Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__);
        return 0;
 }
 
-void __exit exit_nolock(void)
+static void __exit exit_nolock(void)
 {
-       gfs_unregister_lockproto(&nolock_ops);
+       gfs2_unregister_lockproto(&nolock_ops);
 }
 
 module_init(init_nolock);