Commit 2402211a authored by David Teigland's avatar David Teigland

dlm: move plock code from gfs2

Move the code that handles cluster posix locks from gfs2 into the dlm
so that it can be used by both gfs2 and ocfs2.
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent d44e0fc7
......@@ -10,6 +10,7 @@ dlm-y := ast.o \
midcomms.o \
netlink.o \
lowcomms.o \
plock.o \
rcom.o \
recover.o \
recoverd.o \
......
......@@ -582,6 +582,8 @@ static inline int dlm_no_directory(struct dlm_ls *ls)
int dlm_netlink_init(void);
void dlm_netlink_exit(void);
void dlm_timeout_warn(struct dlm_lkb *lkb);
int dlm_plock_init(void);
void dlm_plock_exit(void);
#ifdef CONFIG_DLM_DEBUG
int dlm_register_debugfs(void);
......
......@@ -46,10 +46,16 @@ static int __init init_dlm(void)
if (error)
goto out_user;
error = dlm_plock_init();
if (error)
goto out_netlink;
printk("DLM (built %s %s) installed\n", __DATE__, __TIME__);
return 0;
out_netlink:
dlm_netlink_exit();
out_user:
dlm_user_exit();
out_debug:
......@@ -66,6 +72,7 @@ static int __init init_dlm(void)
static void __exit exit_dlm(void)
{
dlm_plock_exit();
dlm_netlink_exit();
dlm_user_exit();
dlm_config_exit();
......
obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o
lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o plock.o
lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o
......@@ -25,6 +25,7 @@
#include <net/sock.h>
#include <linux/dlm.h>
#include <linux/dlm_plock.h>
#include <linux/lm_interface.h>
/*
......@@ -173,17 +174,6 @@ void gdlm_cancel(void *);
int gdlm_hold_lvb(void *, char **);
void gdlm_unhold_lvb(void *, char *);
/* plock.c */
int gdlm_plock_init(void);
void gdlm_plock_exit(void);
int gdlm_plock(void *, struct lm_lockname *, struct file *, int,
struct file_lock *);
int gdlm_plock_get(void *, struct lm_lockname *, struct file *,
struct file_lock *);
int gdlm_punlock(void *, struct lm_lockname *, struct file *,
struct file_lock *);
/* mount.c */
extern const struct lm_lockops gdlm_ops;
......
......@@ -28,13 +28,6 @@ static int __init init_lock_dlm(void)
return error;
}
error = gdlm_plock_init();
if (error) {
gdlm_sysfs_exit();
gfs2_unregister_lockproto(&gdlm_ops);
return error;
}
printk(KERN_INFO
"Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__);
return 0;
......@@ -42,7 +35,6 @@ static int __init init_lock_dlm(void)
static void __exit exit_lock_dlm(void)
{
gdlm_plock_exit();
gdlm_sysfs_exit();
gfs2_unregister_lockproto(&gdlm_ops);
}
......
......@@ -236,6 +236,27 @@ static void gdlm_withdraw(void *lockspace)
gdlm_kobject_release(ls);
}
static int gdlm_plock(void *lockspace, struct lm_lockname *name,
struct file *file, int cmd, struct file_lock *fl)
{
struct gdlm_ls *ls = lockspace;
return dlm_posix_lock(ls->dlm_lockspace, name->ln_number, file, cmd, fl);
}
static int gdlm_punlock(void *lockspace, struct lm_lockname *name,
struct file *file, struct file_lock *fl)
{
struct gdlm_ls *ls = lockspace;
return dlm_posix_unlock(ls->dlm_lockspace, name->ln_number, file, fl);
}
static int gdlm_plock_get(void *lockspace, struct lm_lockname *name,
struct file *file, struct file_lock *fl)
{
struct gdlm_ls *ls = lockspace;
return dlm_posix_get(ls->dlm_lockspace, name->ln_number, file, fl);
}
const struct lm_lockops gdlm_ops = {
.lm_proto_name = "lock_dlm",
.lm_mount = gdlm_mount,
......
......@@ -100,7 +100,7 @@ header-y += ixjuser.h
header-y += jffs2.h
header-y += keyctl.h
header-y += limits.h
header-y += lock_dlm_plock.h
header-y += dlm_plock.h
header-y += magic.h
header-y += major.h
header-y += matroxfb.h
......
/*
* Copyright (C) 2005 Red Hat, Inc. All rights reserved.
* Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
*
* 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.
*/
#ifndef __LOCK_DLM_PLOCK_DOT_H__
#define __LOCK_DLM_PLOCK_DOT_H__
#ifndef __DLM_PLOCK_DOT_H__
#define __DLM_PLOCK_DOT_H__
#define GDLM_PLOCK_MISC_NAME "lock_dlm_plock"
#define DLM_PLOCK_MISC_NAME "dlm_plock"
#define GDLM_PLOCK_VERSION_MAJOR 1
#define GDLM_PLOCK_VERSION_MINOR 1
#define GDLM_PLOCK_VERSION_PATCH 0
#define DLM_PLOCK_VERSION_MAJOR 1
#define DLM_PLOCK_VERSION_MINOR 1
#define DLM_PLOCK_VERSION_PATCH 0
enum {
GDLM_PLOCK_OP_LOCK = 1,
GDLM_PLOCK_OP_UNLOCK,
GDLM_PLOCK_OP_GET,
DLM_PLOCK_OP_LOCK = 1,
DLM_PLOCK_OP_UNLOCK,
DLM_PLOCK_OP_GET,
};
struct gdlm_plock_info {
struct dlm_plock_info {
__u32 version[3];
__u8 optype;
__u8 ex;
......@@ -37,5 +37,14 @@ struct gdlm_plock_info {
__u64 owner;
};
#ifdef __KERNEL__
int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
int cmd, struct file_lock *fl);
int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
struct file_lock *fl);
int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
struct file_lock *fl);
#endif /* __KERNEL__ */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment