forked from Minki/linux
[GFS2] An update of the GFS2 lock modules
This brings the lock modules uptodate and removes the stray .mod.c file which accidently got included in the last check in. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
parent
a8f2d64728
commit
869d81df53
@ -1,3 +1,3 @@
|
||||
obj-$(CONFIG_GFS2_FS) += lock_dlm.o
|
||||
lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o
|
||||
lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o plock.o
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
** Copyright (C) 2004-2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include "lock_dlm.h"
|
||||
|
||||
@ -38,7 +34,7 @@ static inline void gdlm_bast(void *astarg, int mode)
|
||||
struct gdlm_ls *ls = lp->ls;
|
||||
|
||||
if (!mode) {
|
||||
printk("lock_dlm: bast mode zero %x,%"PRIx64"\n",
|
||||
printk("lock_dlm: bast mode zero %x,%llx\n",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
return;
|
||||
}
|
||||
@ -75,9 +71,9 @@ static int16_t make_mode(int16_t lmstate)
|
||||
return DLM_LOCK_CW;
|
||||
case LM_ST_SHARED:
|
||||
return DLM_LOCK_PR;
|
||||
default:
|
||||
GDLM_ASSERT(0, printk("unknown LM state %d\n", lmstate););
|
||||
}
|
||||
gdlm_assert(0, "unknown LM state %d", lmstate);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* convert dlm lock-mode to gfs lock-state */
|
||||
@ -94,9 +90,9 @@ int16_t gdlm_make_lmstate(int16_t dlmmode)
|
||||
return LM_ST_DEFERRED;
|
||||
case DLM_LOCK_PR:
|
||||
return LM_ST_SHARED;
|
||||
default:
|
||||
GDLM_ASSERT(0, printk("unknown DLM mode %d\n", dlmmode););
|
||||
}
|
||||
gdlm_assert(0, "unknown DLM mode %d", dlmmode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and
|
||||
@ -106,7 +102,7 @@ static void check_cur_state(struct gdlm_lock *lp, unsigned int cur_state)
|
||||
{
|
||||
int16_t cur = make_mode(cur_state);
|
||||
if (lp->cur != DLM_LOCK_IV)
|
||||
GDLM_ASSERT(lp->cur == cur, printk("%d, %d\n", lp->cur, cur););
|
||||
gdlm_assert(lp->cur == cur, "%d, %d", lp->cur, cur);
|
||||
}
|
||||
|
||||
static inline unsigned int make_flags(struct gdlm_lock *lp,
|
||||
@ -157,7 +153,7 @@ static inline unsigned int make_flags(struct gdlm_lock *lp,
|
||||
static inline void make_strname(struct lm_lockname *lockname,
|
||||
struct gdlm_strname *str)
|
||||
{
|
||||
sprintf(str->name, "%8x%16"PRIx64, lockname->ln_type,
|
||||
sprintf(str->name, "%8x%16llx", lockname->ln_type,
|
||||
lockname->ln_number);
|
||||
str->namelen = GDLM_STRNAME_BYTES;
|
||||
}
|
||||
@ -167,11 +163,10 @@ int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name,
|
||||
{
|
||||
struct gdlm_lock *lp;
|
||||
|
||||
lp = kmalloc(sizeof(struct gdlm_lock), GFP_KERNEL);
|
||||
lp = kzalloc(sizeof(struct gdlm_lock), GFP_KERNEL);
|
||||
if (!lp)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(lp, 0, sizeof(struct gdlm_lock));
|
||||
lp->lockname = *name;
|
||||
lp->ls = ls;
|
||||
lp->cur = DLM_LOCK_IV;
|
||||
@ -202,7 +197,8 @@ void gdlm_delete_lp(struct gdlm_lock *lp)
|
||||
list_del_init(&lp->blist);
|
||||
if (!list_empty(&lp->delay_list))
|
||||
list_del_init(&lp->delay_list);
|
||||
GDLM_ASSERT(!list_empty(&lp->all_list),);
|
||||
gdlm_assert(!list_empty(&lp->all_list),
|
||||
"%x,%llx", lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
list_del_init(&lp->all_list);
|
||||
ls->all_locks_count--;
|
||||
spin_unlock(&ls->async_lock);
|
||||
@ -227,7 +223,7 @@ void gdlm_put_lock(lm_lock_t *lock)
|
||||
gdlm_delete_lp((struct gdlm_lock *) lock);
|
||||
}
|
||||
|
||||
void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range)
|
||||
unsigned int gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range)
|
||||
{
|
||||
struct gdlm_ls *ls = lp->ls;
|
||||
struct gdlm_strname str;
|
||||
@ -242,7 +238,7 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range)
|
||||
if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) &&
|
||||
!test_bit(LFL_NOBLOCK, &lp->flags) && lp->req != DLM_LOCK_NL) {
|
||||
gdlm_queue_delayed(lp);
|
||||
return;
|
||||
return LM_OUT_ASYNC;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -256,7 +252,7 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range)
|
||||
|
||||
set_bit(LFL_ACTIVE, &lp->flags);
|
||||
|
||||
log_debug("lk %x,%"PRIx64" id %x %d,%d %x", lp->lockname.ln_type,
|
||||
log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->lksb.sb_lkid,
|
||||
lp->cur, lp->req, lp->lkf);
|
||||
|
||||
@ -270,15 +266,19 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range)
|
||||
error = 0;
|
||||
}
|
||||
|
||||
GDLM_ASSERT(!error,
|
||||
printk("%s: num=%x,%"PRIx64" err=%d cur=%d req=%d lkf=%x\n",
|
||||
ls->fsname, lp->lockname.ln_type,
|
||||
if (error) {
|
||||
log_debug("%s: gdlm_lock %x,%llx err=%d cur=%d req=%d lkf=%x "
|
||||
"flags=%lx", ls->fsname, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, error, lp->cur, lp->req,
|
||||
lp->lkf););
|
||||
lp->lkf, lp->flags);
|
||||
return LM_OUT_ERROR;
|
||||
}
|
||||
return LM_OUT_ASYNC;
|
||||
}
|
||||
|
||||
void gdlm_do_unlock(struct gdlm_lock *lp)
|
||||
unsigned int gdlm_do_unlock(struct gdlm_lock *lp)
|
||||
{
|
||||
struct gdlm_ls *ls = lp->ls;
|
||||
unsigned int lkf = 0;
|
||||
int error;
|
||||
|
||||
@ -288,16 +288,19 @@ void gdlm_do_unlock(struct gdlm_lock *lp)
|
||||
if (lp->lvb)
|
||||
lkf = DLM_LKF_VALBLK;
|
||||
|
||||
log_debug("un %x,%"PRIx64" %x %d %x", lp->lockname.ln_type,
|
||||
log_debug("un %x,%llx %x %d %x", lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->lksb.sb_lkid, lp->cur, lkf);
|
||||
|
||||
error = dlm_unlock(lp->ls->dlm_lockspace, lp->lksb.sb_lkid, lkf,
|
||||
NULL, lp);
|
||||
error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, NULL, lp);
|
||||
|
||||
GDLM_ASSERT(!error,
|
||||
printk("%s: error=%d num=%x,%"PRIx64" lkf=%x flags=%lx\n",
|
||||
lp->ls->fsname, error, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lkf, lp->flags););
|
||||
if (error) {
|
||||
log_debug("%s: gdlm_unlock %x,%llx err=%d cur=%d req=%d lkf=%x "
|
||||
"flags=%lx", ls->fsname, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, error, lp->cur, lp->req,
|
||||
lp->lkf, lp->flags);
|
||||
return LM_OUT_ERROR;
|
||||
}
|
||||
return LM_OUT_ASYNC;
|
||||
}
|
||||
|
||||
unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state,
|
||||
@ -313,8 +316,7 @@ unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state,
|
||||
lp->req = make_mode(req_state);
|
||||
lp->lkf = make_flags(lp, flags, lp->cur, lp->req);
|
||||
|
||||
gdlm_do_lock(lp, NULL);
|
||||
return LM_OUT_ASYNC;
|
||||
return gdlm_do_lock(lp, NULL);
|
||||
}
|
||||
|
||||
unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state)
|
||||
@ -324,8 +326,7 @@ unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state)
|
||||
clear_bit(LFL_DLM_CANCEL, &lp->flags);
|
||||
if (lp->cur == DLM_LOCK_IV)
|
||||
return 0;
|
||||
gdlm_do_unlock(lp);
|
||||
return LM_OUT_ASYNC;
|
||||
return gdlm_do_unlock(lp);
|
||||
}
|
||||
|
||||
void gdlm_cancel(lm_lock_t *lock)
|
||||
@ -337,8 +338,8 @@ void gdlm_cancel(lm_lock_t *lock)
|
||||
if (test_bit(LFL_DLM_CANCEL, &lp->flags))
|
||||
return;
|
||||
|
||||
log_all("gdlm_cancel %x,%"PRIx64" flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number, lp->flags);
|
||||
log_info("gdlm_cancel %x,%llx flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number, lp->flags);
|
||||
|
||||
spin_lock(&ls->async_lock);
|
||||
if (!list_empty(&lp->delay_list)) {
|
||||
@ -356,9 +357,9 @@ void gdlm_cancel(lm_lock_t *lock)
|
||||
|
||||
if (!test_bit(LFL_ACTIVE, &lp->flags) ||
|
||||
test_bit(LFL_DLM_UNLOCK, &lp->flags)) {
|
||||
log_all("gdlm_cancel skip %x,%"PRIx64" flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number,
|
||||
lp->flags);
|
||||
log_info("gdlm_cancel skip %x,%llx flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number,
|
||||
lp->flags);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -370,8 +371,8 @@ void gdlm_cancel(lm_lock_t *lock)
|
||||
error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, DLM_LKF_CANCEL,
|
||||
NULL, lp);
|
||||
|
||||
log_all("gdlm_cancel rv %d %x,%"PRIx64" flags %lx", error,
|
||||
lp->lockname.ln_type, lp->lockname.ln_number, lp->flags);
|
||||
log_info("gdlm_cancel rv %d %x,%llx flags %lx", error,
|
||||
lp->lockname.ln_type, lp->lockname.ln_number, lp->flags);
|
||||
|
||||
if (error == -EBUSY)
|
||||
clear_bit(LFL_DLM_CANCEL, &lp->flags);
|
||||
@ -381,12 +382,10 @@ int gdlm_add_lvb(struct gdlm_lock *lp)
|
||||
{
|
||||
char *lvb;
|
||||
|
||||
lvb = kmalloc(GDLM_LVB_SIZE, GFP_KERNEL);
|
||||
lvb = kzalloc(GDLM_LVB_SIZE, GFP_KERNEL);
|
||||
if (!lvb)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(lvb, 0, GDLM_LVB_SIZE);
|
||||
|
||||
lp->lksb.sb_lvbptr = lvb;
|
||||
lp->lvb = lvb;
|
||||
return 0;
|
||||
@ -448,7 +447,8 @@ static void unhold_null_lock(struct gdlm_lock *lp)
|
||||
{
|
||||
struct gdlm_lock *lpn = lp->hold_null;
|
||||
|
||||
GDLM_ASSERT(lpn,);
|
||||
gdlm_assert(lpn, "%x,%llx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
lpn->lksb.sb_lvbptr = NULL;
|
||||
lpn->lvb = NULL;
|
||||
set_bit(LFL_UNLOCK_DELETE, &lpn->flags);
|
||||
|
191
fs/gfs2/locking/dlm/lock_dlm.h
Normal file
191
fs/gfs2/locking/dlm/lock_dlm.h
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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_DOT_H
|
||||
#define LOCK_DLM_DOT_H
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/socket.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/kobject.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/wait.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#include <linux/dlm.h>
|
||||
#include "../../lm_interface.h"
|
||||
|
||||
/*
|
||||
* Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
|
||||
* prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module
|
||||
* as "lock_dlm".
|
||||
*/
|
||||
|
||||
#define GDLM_STRNAME_BYTES 24
|
||||
#define GDLM_LVB_SIZE 32
|
||||
#define GDLM_DROP_COUNT 50000
|
||||
#define GDLM_DROP_PERIOD 60
|
||||
#define GDLM_NAME_LEN 128
|
||||
|
||||
/* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number).
|
||||
We sprintf these numbers into a 24 byte string of hex values to make them
|
||||
human-readable (to make debugging simpler.) */
|
||||
|
||||
struct gdlm_strname {
|
||||
unsigned char name[GDLM_STRNAME_BYTES];
|
||||
unsigned short namelen;
|
||||
};
|
||||
|
||||
enum {
|
||||
DFL_BLOCK_LOCKS = 0,
|
||||
DFL_SPECTATOR = 1,
|
||||
DFL_WITHDRAW = 2,
|
||||
};
|
||||
|
||||
struct gdlm_ls {
|
||||
uint32_t id;
|
||||
int jid;
|
||||
int first;
|
||||
int first_done;
|
||||
unsigned long flags;
|
||||
struct kobject kobj;
|
||||
char clustername[GDLM_NAME_LEN];
|
||||
char fsname[GDLM_NAME_LEN];
|
||||
int fsflags;
|
||||
dlm_lockspace_t *dlm_lockspace;
|
||||
lm_callback_t fscb;
|
||||
lm_fsdata_t *fsdata;
|
||||
int recover_jid;
|
||||
int recover_jid_done;
|
||||
spinlock_t async_lock;
|
||||
struct list_head complete;
|
||||
struct list_head blocking;
|
||||
struct list_head delayed;
|
||||
struct list_head submit;
|
||||
struct list_head all_locks;
|
||||
uint32_t all_locks_count;
|
||||
wait_queue_head_t wait_control;
|
||||
struct task_struct *thread1;
|
||||
struct task_struct *thread2;
|
||||
wait_queue_head_t thread_wait;
|
||||
unsigned long drop_time;
|
||||
int drop_locks_count;
|
||||
int drop_locks_period;
|
||||
};
|
||||
|
||||
enum {
|
||||
LFL_NOBLOCK = 0,
|
||||
LFL_NOCACHE = 1,
|
||||
LFL_DLM_UNLOCK = 2,
|
||||
LFL_DLM_CANCEL = 3,
|
||||
LFL_SYNC_LVB = 4,
|
||||
LFL_FORCE_PROMOTE = 5,
|
||||
LFL_REREQUEST = 6,
|
||||
LFL_ACTIVE = 7,
|
||||
LFL_INLOCK = 8,
|
||||
LFL_CANCEL = 9,
|
||||
LFL_NOBAST = 10,
|
||||
LFL_HEADQUE = 11,
|
||||
LFL_UNLOCK_DELETE = 12,
|
||||
};
|
||||
|
||||
struct gdlm_lock {
|
||||
struct gdlm_ls *ls;
|
||||
struct lm_lockname lockname;
|
||||
char *lvb;
|
||||
struct dlm_lksb lksb;
|
||||
|
||||
int16_t cur;
|
||||
int16_t req;
|
||||
int16_t prev_req;
|
||||
uint32_t lkf; /* dlm flags DLM_LKF_ */
|
||||
unsigned long flags; /* lock_dlm flags LFL_ */
|
||||
|
||||
int bast_mode; /* protected by async_lock */
|
||||
struct completion ast_wait;
|
||||
|
||||
struct list_head clist; /* complete */
|
||||
struct list_head blist; /* blocking */
|
||||
struct list_head delay_list; /* delayed */
|
||||
struct list_head all_list; /* all locks for the fs */
|
||||
struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
|
||||
};
|
||||
|
||||
#define gdlm_assert(assertion, fmt, args...) \
|
||||
do { \
|
||||
if (unlikely(!(assertion))) { \
|
||||
printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \
|
||||
"lock_dlm: " fmt "\n", \
|
||||
#assertion, ##args); \
|
||||
BUG(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg)
|
||||
#define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg)
|
||||
#define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg)
|
||||
#ifdef LOCK_DLM_LOG_DEBUG
|
||||
#define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg)
|
||||
#else
|
||||
#define log_debug(fmt, arg...)
|
||||
#endif
|
||||
|
||||
/* sysfs.c */
|
||||
|
||||
int gdlm_sysfs_init(void);
|
||||
void gdlm_sysfs_exit(void);
|
||||
int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *);
|
||||
void gdlm_kobject_release(struct gdlm_ls *);
|
||||
|
||||
/* thread.c */
|
||||
|
||||
int gdlm_init_threads(struct gdlm_ls *);
|
||||
void gdlm_release_threads(struct gdlm_ls *);
|
||||
|
||||
/* lock.c */
|
||||
|
||||
int16_t gdlm_make_lmstate(int16_t);
|
||||
void gdlm_queue_delayed(struct gdlm_lock *);
|
||||
void gdlm_submit_delayed(struct gdlm_ls *);
|
||||
int gdlm_release_all_locks(struct gdlm_ls *);
|
||||
int gdlm_create_lp(struct gdlm_ls *, struct lm_lockname *, struct gdlm_lock **);
|
||||
void gdlm_delete_lp(struct gdlm_lock *);
|
||||
int gdlm_add_lvb(struct gdlm_lock *);
|
||||
void gdlm_del_lvb(struct gdlm_lock *);
|
||||
unsigned int gdlm_do_lock(struct gdlm_lock *, struct dlm_range *);
|
||||
unsigned int gdlm_do_unlock(struct gdlm_lock *);
|
||||
|
||||
int gdlm_get_lock(lm_lockspace_t *, struct lm_lockname *, lm_lock_t **);
|
||||
void gdlm_put_lock(lm_lock_t *);
|
||||
unsigned int gdlm_lock(lm_lock_t *, unsigned int, unsigned int, unsigned int);
|
||||
unsigned int gdlm_unlock(lm_lock_t *, unsigned int);
|
||||
void gdlm_cancel(lm_lock_t *);
|
||||
int gdlm_hold_lvb(lm_lock_t *, char **);
|
||||
void gdlm_unhold_lvb(lm_lock_t *, char *);
|
||||
void gdlm_sync_lvb(lm_lock_t *, char *);
|
||||
|
||||
/* plock.c */
|
||||
|
||||
int gdlm_plock_init(void);
|
||||
void gdlm_plock_exit(void);
|
||||
int gdlm_plock(lm_lockspace_t *, struct lm_lockname *, struct file *, int,
|
||||
struct file_lock *);
|
||||
int gdlm_plock_get(lm_lockspace_t *, struct lm_lockname *, struct file *,
|
||||
struct file_lock *);
|
||||
int gdlm_punlock(lm_lockspace_t *, struct lm_lockname *, struct file *,
|
||||
struct file_lock *);
|
||||
#endif
|
||||
|
@ -1,15 +1,11 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
** Copyright (C) 2004-2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
|
||||
@ -24,7 +20,7 @@ int __init init_lock_dlm(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = lm_register_proto(&gdlm_ops);
|
||||
error = gfs_register_lockproto(&gdlm_ops);
|
||||
if (error) {
|
||||
printk("lock_dlm: can't register protocol: %d\n", error);
|
||||
return error;
|
||||
@ -32,7 +28,14 @@ int __init init_lock_dlm(void)
|
||||
|
||||
error = gdlm_sysfs_init();
|
||||
if (error) {
|
||||
lm_unregister_proto(&gdlm_ops);
|
||||
gfs_unregister_lockproto(&gdlm_ops);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = gdlm_plock_init();
|
||||
if (error) {
|
||||
gdlm_sysfs_exit();
|
||||
gfs_unregister_lockproto(&gdlm_ops);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -45,8 +48,9 @@ int __init init_lock_dlm(void)
|
||||
|
||||
void __exit exit_lock_dlm(void)
|
||||
{
|
||||
lm_unregister_proto(&gdlm_ops);
|
||||
gdlm_plock_exit();
|
||||
gdlm_sysfs_exit();
|
||||
gfs_unregister_lockproto(&gdlm_ops);
|
||||
}
|
||||
|
||||
module_init(init_lock_dlm);
|
||||
|
@ -1,15 +1,11 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
** Copyright (C) 2004-2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include "lock_dlm.h"
|
||||
|
||||
@ -24,27 +20,21 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata,
|
||||
struct gdlm_ls *ls;
|
||||
char buf[256], *p;
|
||||
|
||||
ls = kmalloc(sizeof(struct gdlm_ls), GFP_KERNEL);
|
||||
ls = kzalloc(sizeof(struct gdlm_ls), GFP_KERNEL);
|
||||
if (!ls)
|
||||
return NULL;
|
||||
|
||||
memset(ls, 0, sizeof(struct gdlm_ls));
|
||||
|
||||
ls->drop_locks_count = gdlm_drop_count;
|
||||
ls->drop_locks_period = gdlm_drop_period;
|
||||
|
||||
ls->fscb = cb;
|
||||
ls->fsdata = fsdata;
|
||||
ls->fsflags = flags;
|
||||
|
||||
spin_lock_init(&ls->async_lock);
|
||||
|
||||
INIT_LIST_HEAD(&ls->complete);
|
||||
INIT_LIST_HEAD(&ls->blocking);
|
||||
INIT_LIST_HEAD(&ls->delayed);
|
||||
INIT_LIST_HEAD(&ls->submit);
|
||||
INIT_LIST_HEAD(&ls->all_locks);
|
||||
|
||||
init_waitqueue_head(&ls->thread_wait);
|
||||
init_waitqueue_head(&ls->wait_control);
|
||||
ls->thread1 = NULL;
|
||||
@ -57,23 +47,75 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata,
|
||||
|
||||
p = strstr(buf, ":");
|
||||
if (!p) {
|
||||
printk("lock_dlm: invalid table_name \"%s\"\n", table_name);
|
||||
log_info("invalid table_name \"%s\"", table_name);
|
||||
kfree(ls);
|
||||
return NULL;
|
||||
}
|
||||
*p = '\0';
|
||||
p++;
|
||||
|
||||
strncpy(ls->clustername, buf, 128);
|
||||
strncpy(ls->fsname, p, 128);
|
||||
strncpy(ls->clustername, buf, GDLM_NAME_LEN);
|
||||
strncpy(ls->fsname, p, GDLM_NAME_LEN);
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
static int make_args(struct gdlm_ls *ls, char *data_arg)
|
||||
{
|
||||
char data[256];
|
||||
char *options, *x, *y;
|
||||
int error = 0;
|
||||
|
||||
memset(data, 0, 256);
|
||||
strncpy(data, data_arg, 255);
|
||||
|
||||
for (options = data; (x = strsep(&options, ":")); ) {
|
||||
if (!*x)
|
||||
continue;
|
||||
|
||||
y = strchr(x, '=');
|
||||
if (y)
|
||||
*y++ = 0;
|
||||
|
||||
if (!strcmp(x, "jid")) {
|
||||
if (!y) {
|
||||
log_error("need argument to jid");
|
||||
error = -EINVAL;
|
||||
break;
|
||||
}
|
||||
sscanf(y, "%u", &ls->jid);
|
||||
|
||||
} else if (!strcmp(x, "first")) {
|
||||
if (!y) {
|
||||
log_error("need argument to first");
|
||||
error = -EINVAL;
|
||||
break;
|
||||
}
|
||||
sscanf(y, "%u", &ls->first);
|
||||
|
||||
} else if (!strcmp(x, "id")) {
|
||||
if (!y) {
|
||||
log_error("need argument to id");
|
||||
error = -EINVAL;
|
||||
break;
|
||||
}
|
||||
sscanf(y, "%u", &ls->id);
|
||||
|
||||
} else {
|
||||
log_error("unkonwn option: %s", x);
|
||||
error = -EINVAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int gdlm_mount(char *table_name, char *host_data,
|
||||
lm_callback_t cb, lm_fsdata_t *fsdata,
|
||||
unsigned int min_lvb_size, int flags,
|
||||
struct lm_lockstruct *lockstruct)
|
||||
struct lm_lockstruct *lockstruct,
|
||||
struct kobject *fskobj)
|
||||
{
|
||||
struct gdlm_ls *ls;
|
||||
int error = -ENOMEM;
|
||||
@ -92,30 +134,18 @@ static int gdlm_mount(char *table_name, char *host_data,
|
||||
error = dlm_new_lockspace(ls->fsname, strlen(ls->fsname),
|
||||
&ls->dlm_lockspace, 0, GDLM_LVB_SIZE);
|
||||
if (error) {
|
||||
printk("lock_dlm: dlm_new_lockspace error %d\n", error);
|
||||
log_error("dlm_new_lockspace error %d", error);
|
||||
goto out_thread;
|
||||
}
|
||||
|
||||
error = gdlm_kobject_setup(ls);
|
||||
error = gdlm_kobject_setup(ls, fskobj);
|
||||
if (error)
|
||||
goto out_dlm;
|
||||
kobject_uevent(&ls->kobj, KOBJ_MOUNT, NULL);
|
||||
|
||||
/* Now we depend on userspace to notice the new mount,
|
||||
join the appropriate group, and do a write to our sysfs
|
||||
"mounted" or "terminate" file. Before the start, userspace
|
||||
must set "jid" and "first". */
|
||||
|
||||
error = wait_event_interruptible(ls->wait_control,
|
||||
test_bit(DFL_JOIN_DONE, &ls->flags));
|
||||
error = make_args(ls, host_data);
|
||||
if (error)
|
||||
goto out_sysfs;
|
||||
|
||||
if (test_bit(DFL_TERMINATE, &ls->flags)) {
|
||||
error = -ERESTARTSYS;
|
||||
goto out_sysfs;
|
||||
}
|
||||
|
||||
lockstruct->ls_jid = ls->jid;
|
||||
lockstruct->ls_first = ls->first;
|
||||
lockstruct->ls_lockspace = ls;
|
||||
@ -143,22 +173,19 @@ static void gdlm_unmount(lm_lockspace_t *lockspace)
|
||||
|
||||
log_debug("unmount flags %lx", ls->flags);
|
||||
|
||||
if (test_bit(DFL_WITHDRAW, &ls->flags)) {
|
||||
gdlm_kobject_release(ls);
|
||||
/* FIXME: serialize unmount and withdraw in case they
|
||||
happen at once. Also, if unmount follows withdraw,
|
||||
wait for withdraw to finish. */
|
||||
|
||||
if (test_bit(DFL_WITHDRAW, &ls->flags))
|
||||
goto out;
|
||||
}
|
||||
|
||||
kobject_uevent(&ls->kobj, KOBJ_UMOUNT, NULL);
|
||||
|
||||
wait_event_interruptible(ls->wait_control,
|
||||
test_bit(DFL_LEAVE_DONE, &ls->flags));
|
||||
|
||||
gdlm_kobject_release(ls);
|
||||
dlm_release_lockspace(ls->dlm_lockspace, 2);
|
||||
gdlm_release_threads(ls);
|
||||
rv = gdlm_release_all_locks(ls);
|
||||
if (rv)
|
||||
log_all("lm_dlm_unmount: %d stray locks freed", rv);
|
||||
log_info("gdlm_unmount: %d stray locks freed", rv);
|
||||
out:
|
||||
kfree(ls);
|
||||
}
|
||||
@ -167,7 +194,7 @@ static void gdlm_recovery_done(lm_lockspace_t *lockspace, unsigned int jid,
|
||||
unsigned int message)
|
||||
{
|
||||
struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
|
||||
ls->recover_done = jid;
|
||||
ls->recover_jid_done = jid;
|
||||
kobject_uevent(&ls->kobj, KOBJ_CHANGE, NULL);
|
||||
}
|
||||
|
||||
@ -178,12 +205,14 @@ static void gdlm_others_may_mount(lm_lockspace_t *lockspace)
|
||||
kobject_uevent(&ls->kobj, KOBJ_CHANGE, NULL);
|
||||
}
|
||||
|
||||
/* Userspace gets the offline uevent, blocks new gfs locks on
|
||||
other mounters, and lets us know (sets WITHDRAW flag). Then,
|
||||
userspace leaves the mount group while we leave the lockspace. */
|
||||
|
||||
static void gdlm_withdraw(lm_lockspace_t *lockspace)
|
||||
{
|
||||
struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
|
||||
|
||||
/* userspace suspends locking on all other members */
|
||||
|
||||
kobject_uevent(&ls->kobj, KOBJ_OFFLINE, NULL);
|
||||
|
||||
wait_event_interruptible(ls->wait_control,
|
||||
@ -192,49 +221,27 @@ static void gdlm_withdraw(lm_lockspace_t *lockspace)
|
||||
dlm_release_lockspace(ls->dlm_lockspace, 2);
|
||||
gdlm_release_threads(ls);
|
||||
gdlm_release_all_locks(ls);
|
||||
|
||||
kobject_uevent(&ls->kobj, KOBJ_UMOUNT, NULL);
|
||||
|
||||
/* userspace leaves the mount group, we don't need to wait for
|
||||
that to complete */
|
||||
}
|
||||
|
||||
int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, int cmd, struct file_lock *fl)
|
||||
{
|
||||
return -ENOSYS;
|
||||
gdlm_kobject_release(ls);
|
||||
}
|
||||
|
||||
struct lm_lockops gdlm_ops = {
|
||||
lm_proto_name:"lock_dlm",
|
||||
lm_mount:gdlm_mount,
|
||||
lm_others_may_mount:gdlm_others_may_mount,
|
||||
lm_unmount:gdlm_unmount,
|
||||
lm_withdraw:gdlm_withdraw,
|
||||
lm_get_lock:gdlm_get_lock,
|
||||
lm_put_lock:gdlm_put_lock,
|
||||
lm_lock:gdlm_lock,
|
||||
lm_unlock:gdlm_unlock,
|
||||
lm_plock:gdlm_plock,
|
||||
lm_punlock:gdlm_punlock,
|
||||
lm_plock_get:gdlm_plock_get,
|
||||
lm_cancel:gdlm_cancel,
|
||||
lm_hold_lvb:gdlm_hold_lvb,
|
||||
lm_unhold_lvb:gdlm_unhold_lvb,
|
||||
lm_sync_lvb:gdlm_sync_lvb,
|
||||
lm_recovery_done:gdlm_recovery_done,
|
||||
lm_owner:THIS_MODULE,
|
||||
.lm_proto_name = "lock_dlm",
|
||||
.lm_mount = gdlm_mount,
|
||||
.lm_others_may_mount = gdlm_others_may_mount,
|
||||
.lm_unmount = gdlm_unmount,
|
||||
.lm_withdraw = gdlm_withdraw,
|
||||
.lm_get_lock = gdlm_get_lock,
|
||||
.lm_put_lock = gdlm_put_lock,
|
||||
.lm_lock = gdlm_lock,
|
||||
.lm_unlock = gdlm_unlock,
|
||||
.lm_plock = gdlm_plock,
|
||||
.lm_punlock = gdlm_punlock,
|
||||
.lm_plock_get = gdlm_plock_get,
|
||||
.lm_cancel = gdlm_cancel,
|
||||
.lm_hold_lvb = gdlm_hold_lvb,
|
||||
.lm_unhold_lvb = gdlm_unhold_lvb,
|
||||
.lm_sync_lvb = gdlm_sync_lvb,
|
||||
.lm_recovery_done = gdlm_recovery_done,
|
||||
.lm_owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
297
fs/gfs2/locking/dlm/plock.c
Normal file
297
fs/gfs2/locking/dlm/plock.c
Normal file
@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/lock_dlm_plock.h>
|
||||
|
||||
#include "lock_dlm.h"
|
||||
|
||||
|
||||
static spinlock_t ops_lock;
|
||||
static struct list_head send_list;
|
||||
static struct list_head recv_list;
|
||||
static wait_queue_head_t send_wq;
|
||||
static wait_queue_head_t recv_wq;
|
||||
|
||||
struct plock_op {
|
||||
struct list_head list;
|
||||
int done;
|
||||
struct gdlm_plock_info info;
|
||||
};
|
||||
|
||||
static inline void set_version(struct gdlm_plock_info *info)
|
||||
{
|
||||
info->version[0] = GDLM_PLOCK_VERSION_MAJOR;
|
||||
info->version[1] = GDLM_PLOCK_VERSION_MINOR;
|
||||
info->version[2] = GDLM_PLOCK_VERSION_PATCH;
|
||||
}
|
||||
|
||||
static int check_version(struct gdlm_plock_info *info)
|
||||
{
|
||||
if ((GDLM_PLOCK_VERSION_MAJOR != info->version[0]) ||
|
||||
(GDLM_PLOCK_VERSION_MINOR < info->version[1])) {
|
||||
log_error("plock device version mismatch: "
|
||||
"kernel (%u.%u.%u), user (%u.%u.%u)",
|
||||
GDLM_PLOCK_VERSION_MAJOR,
|
||||
GDLM_PLOCK_VERSION_MINOR,
|
||||
GDLM_PLOCK_VERSION_PATCH,
|
||||
info->version[0],
|
||||
info->version[1],
|
||||
info->version[2]);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void send_op(struct plock_op *op)
|
||||
{
|
||||
set_version(&op->info);
|
||||
INIT_LIST_HEAD(&op->list);
|
||||
spin_lock(&ops_lock);
|
||||
list_add_tail(&op->list, &send_list);
|
||||
spin_unlock(&ops_lock);
|
||||
wake_up(&send_wq);
|
||||
}
|
||||
|
||||
int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, int cmd, struct file_lock *fl)
|
||||
{
|
||||
struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
|
||||
struct plock_op *op;
|
||||
int rv;
|
||||
|
||||
op = kzalloc(sizeof(*op), GFP_KERNEL);
|
||||
if (!op)
|
||||
return -ENOMEM;
|
||||
|
||||
op->info.optype = GDLM_PLOCK_OP_LOCK;
|
||||
op->info.pid = (uint32_t) fl->fl_owner;
|
||||
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;
|
||||
|
||||
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");
|
||||
list_del(&op->list);
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
|
||||
rv = op->info.rv;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
kfree(op);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
|
||||
struct plock_op *op;
|
||||
int rv;
|
||||
|
||||
op = kzalloc(sizeof(*op), GFP_KERNEL);
|
||||
if (!op)
|
||||
return -ENOMEM;
|
||||
|
||||
if (posix_lock_file_wait(file, fl) < 0)
|
||||
log_error("gdlm_punlock: vfs unlock error %x,%llx",
|
||||
name->ln_type, name->ln_number);
|
||||
|
||||
op->info.optype = GDLM_PLOCK_OP_UNLOCK;
|
||||
op->info.pid = (uint32_t) fl->fl_owner;
|
||||
op->info.fsid = ls->id;
|
||||
op->info.number = name->ln_number;
|
||||
op->info.start = fl->fl_start;
|
||||
op->info.end = fl->fl_end;
|
||||
|
||||
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");
|
||||
list_del(&op->list);
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
|
||||
rv = op->info.rv;
|
||||
|
||||
kfree(op);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
struct gdlm_ls *ls = (struct gdlm_ls *) lockspace;
|
||||
struct plock_op *op;
|
||||
int rv;
|
||||
|
||||
op = kzalloc(sizeof(*op), GFP_KERNEL);
|
||||
if (!op)
|
||||
return -ENOMEM;
|
||||
|
||||
op->info.optype = GDLM_PLOCK_OP_GET;
|
||||
op->info.pid = (uint32_t) fl->fl_owner;
|
||||
op->info.ex = (fl->fl_type == F_WRLCK);
|
||||
op->info.fsid = ls->id;
|
||||
op->info.number = name->ln_number;
|
||||
op->info.start = fl->fl_start;
|
||||
op->info.end = fl->fl_end;
|
||||
|
||||
send_op(op);
|
||||
wait_event(recv_wq, (op->done != 0));
|
||||
|
||||
spin_lock(&ops_lock);
|
||||
if (!list_empty(&op->list)) {
|
||||
printk("plock_get op on list\n");
|
||||
list_del(&op->list);
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
|
||||
rv = op->info.rv;
|
||||
|
||||
if (rv == 0)
|
||||
fl->fl_type = F_UNLCK;
|
||||
else if (rv > 0) {
|
||||
fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK;
|
||||
fl->fl_pid = op->info.pid;
|
||||
fl->fl_start = op->info.start;
|
||||
fl->fl_end = op->info.end;
|
||||
}
|
||||
|
||||
kfree(op);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* a read copies out one plock request from the send list */
|
||||
static ssize_t dev_read(struct file *file, char __user *u, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct gdlm_plock_info info;
|
||||
struct plock_op *op = NULL;
|
||||
|
||||
if (count < sizeof(info))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&ops_lock);
|
||||
if (!list_empty(&send_list)) {
|
||||
op = list_entry(send_list.next, struct plock_op, list);
|
||||
list_move(&op->list, &recv_list);
|
||||
memcpy(&info, &op->info, sizeof(info));
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
|
||||
if (!op)
|
||||
return -EAGAIN;
|
||||
|
||||
if (copy_to_user(u, &info, sizeof(info)))
|
||||
return -EFAULT;
|
||||
return sizeof(info);
|
||||
}
|
||||
|
||||
/* a write copies in one plock result that should match a plock_op
|
||||
on the recv list */
|
||||
static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct gdlm_plock_info info;
|
||||
struct plock_op *op;
|
||||
int found = 0;
|
||||
|
||||
if (count != sizeof(info))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&info, u, sizeof(info)))
|
||||
return -EFAULT;
|
||||
|
||||
if (check_version(&info))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&ops_lock);
|
||||
list_for_each_entry(op, &recv_list, list) {
|
||||
if (op->info.fsid == info.fsid &&
|
||||
op->info.number == info.number) {
|
||||
list_del_init(&op->list);
|
||||
found = 1;
|
||||
op->done = 1;
|
||||
memcpy(&op->info, &info, sizeof(info));
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
|
||||
if (found)
|
||||
wake_up(&recv_wq);
|
||||
else
|
||||
printk("gdlm dev_write no op %x %llx\n", info.fsid,
|
||||
info.number);
|
||||
return count;
|
||||
}
|
||||
|
||||
static unsigned int dev_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
poll_wait(file, &send_wq, wait);
|
||||
|
||||
spin_lock(&ops_lock);
|
||||
if (!list_empty(&send_list)) {
|
||||
spin_unlock(&ops_lock);
|
||||
return POLLIN | POLLRDNORM;
|
||||
}
|
||||
spin_unlock(&ops_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file_operations dev_fops = {
|
||||
.read = dev_read,
|
||||
.write = dev_write,
|
||||
.poll = dev_poll,
|
||||
.owner = THIS_MODULE
|
||||
};
|
||||
|
||||
static struct miscdevice plock_dev_misc = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = GDLM_PLOCK_MISC_NAME,
|
||||
.fops = &dev_fops
|
||||
};
|
||||
|
||||
int gdlm_plock_init(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
spin_lock_init(&ops_lock);
|
||||
INIT_LIST_HEAD(&send_list);
|
||||
INIT_LIST_HEAD(&recv_list);
|
||||
init_waitqueue_head(&send_wq);
|
||||
init_waitqueue_head(&recv_wq);
|
||||
|
||||
rv = misc_register(&plock_dev_misc);
|
||||
if (rv)
|
||||
printk("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");
|
||||
}
|
||||
|
@ -1,21 +1,25 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) 2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/stat.h>
|
||||
|
||||
#include "lock_dlm.h"
|
||||
|
||||
static ssize_t gdlm_block_show(struct gdlm_ls *ls, char *buf)
|
||||
extern struct lm_lockops gdlm_ops;
|
||||
|
||||
static ssize_t proto_name_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%s\n", gdlm_ops.lm_proto_name);
|
||||
}
|
||||
|
||||
static ssize_t block_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
int val = 0;
|
||||
@ -26,7 +30,7 @@ static ssize_t gdlm_block_show(struct gdlm_ls *ls, char *buf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_block_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
static ssize_t block_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
{
|
||||
ssize_t ret = len;
|
||||
int val;
|
||||
@ -43,43 +47,7 @@ static ssize_t gdlm_block_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_mounted_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
int val = -2;
|
||||
|
||||
if (test_bit(DFL_TERMINATE, &ls->flags))
|
||||
val = -1;
|
||||
else if (test_bit(DFL_LEAVE_DONE, &ls->flags))
|
||||
val = 0;
|
||||
else if (test_bit(DFL_JOIN_DONE, &ls->flags))
|
||||
val = 1;
|
||||
ret = sprintf(buf, "%d\n", val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_mounted_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
{
|
||||
ssize_t ret = len;
|
||||
int val;
|
||||
|
||||
val = simple_strtol(buf, NULL, 0);
|
||||
|
||||
if (val == 1)
|
||||
set_bit(DFL_JOIN_DONE, &ls->flags);
|
||||
else if (val == 0)
|
||||
set_bit(DFL_LEAVE_DONE, &ls->flags);
|
||||
else if (val == -1) {
|
||||
set_bit(DFL_TERMINATE, &ls->flags);
|
||||
set_bit(DFL_JOIN_DONE, &ls->flags);
|
||||
set_bit(DFL_LEAVE_DONE, &ls->flags);
|
||||
} else
|
||||
ret = -EINVAL;
|
||||
wake_up(&ls->wait_control);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_withdraw_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t withdraw_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
int val = 0;
|
||||
@ -90,7 +58,7 @@ static ssize_t gdlm_withdraw_show(struct gdlm_ls *ls, char *buf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_withdraw_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
static ssize_t withdraw_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
{
|
||||
ssize_t ret = len;
|
||||
int val;
|
||||
@ -105,67 +73,41 @@ static ssize_t gdlm_withdraw_store(struct gdlm_ls *ls, const char *buf, size_t l
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_jid_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t id_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%u\n", ls->jid);
|
||||
return sprintf(buf, "%u\n", ls->id);
|
||||
}
|
||||
|
||||
static ssize_t gdlm_jid_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
static ssize_t jid_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ls->jid = simple_strtol(buf, NULL, 0);
|
||||
return len;
|
||||
return sprintf(buf, "%d\n", ls->jid);
|
||||
}
|
||||
|
||||
static ssize_t gdlm_first_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t first_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%u\n", ls->first);
|
||||
return sprintf(buf, "%d\n", ls->first);
|
||||
}
|
||||
|
||||
static ssize_t gdlm_first_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
{
|
||||
ls->first = simple_strtol(buf, NULL, 0);
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_first_done_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t first_done_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", ls->first_done);
|
||||
}
|
||||
|
||||
static ssize_t gdlm_recover_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t recover_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%u\n", ls->recover_jid);
|
||||
return sprintf(buf, "%d\n", ls->recover_jid);
|
||||
}
|
||||
|
||||
static ssize_t gdlm_recover_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
static ssize_t recover_store(struct gdlm_ls *ls, const char *buf, size_t len)
|
||||
{
|
||||
ls->recover_jid = simple_strtol(buf, NULL, 0);
|
||||
ls->fscb(ls->fsdata, LM_CB_NEED_RECOVERY, &ls->recover_jid);
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_recover_done_show(struct gdlm_ls *ls, char *buf)
|
||||
static ssize_t recover_done_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
ret = sprintf(buf, "%d\n", ls->recover_done);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_cluster_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
ret = sprintf(buf, "%s\n", ls->clustername);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t gdlm_options_show(struct gdlm_ls *ls, char *buf)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
if (ls->fsflags & LM_MFLAG_SPECTATOR)
|
||||
ret += sprintf(buf, "spectator ");
|
||||
|
||||
return ret;
|
||||
return sprintf(buf, "%d\n", ls->recover_jid_done);
|
||||
}
|
||||
|
||||
struct gdlm_attr {
|
||||
@ -174,73 +116,29 @@ struct gdlm_attr {
|
||||
ssize_t (*store)(struct gdlm_ls *, const char *, size_t);
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_block = {
|
||||
.attr = {.name = "block", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_block_show,
|
||||
.store = gdlm_block_store
|
||||
};
|
||||
#define GDLM_ATTR(_name,_mode,_show,_store) \
|
||||
static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
|
||||
|
||||
static struct gdlm_attr gdlm_attr_mounted = {
|
||||
.attr = {.name = "mounted", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_mounted_show,
|
||||
.store = gdlm_mounted_store
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_withdraw = {
|
||||
.attr = {.name = "withdraw", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_withdraw_show,
|
||||
.store = gdlm_withdraw_store
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_jid = {
|
||||
.attr = {.name = "jid", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_jid_show,
|
||||
.store = gdlm_jid_store
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_first = {
|
||||
.attr = {.name = "first", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_first_show,
|
||||
.store = gdlm_first_store
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_first_done = {
|
||||
.attr = {.name = "first_done", .mode = S_IRUGO},
|
||||
.show = gdlm_first_done_show,
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_recover = {
|
||||
.attr = {.name = "recover", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_recover_show,
|
||||
.store = gdlm_recover_store
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_recover_done = {
|
||||
.attr = {.name = "recover_done", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_recover_done_show,
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_cluster = {
|
||||
.attr = {.name = "cluster", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_cluster_show,
|
||||
};
|
||||
|
||||
static struct gdlm_attr gdlm_attr_options = {
|
||||
.attr = {.name = "options", .mode = S_IRUGO | S_IWUSR},
|
||||
.show = gdlm_options_show,
|
||||
};
|
||||
GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
|
||||
GDLM_ATTR(block, 0644, block_show, block_store);
|
||||
GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
|
||||
GDLM_ATTR(id, 0444, id_show, NULL);
|
||||
GDLM_ATTR(jid, 0444, jid_show, NULL);
|
||||
GDLM_ATTR(first, 0444, first_show, NULL);
|
||||
GDLM_ATTR(first_done, 0444, first_done_show, NULL);
|
||||
GDLM_ATTR(recover, 0644, recover_show, recover_store);
|
||||
GDLM_ATTR(recover_done, 0444, recover_done_show, NULL);
|
||||
|
||||
static struct attribute *gdlm_attrs[] = {
|
||||
&gdlm_attr_proto_name.attr,
|
||||
&gdlm_attr_block.attr,
|
||||
&gdlm_attr_mounted.attr,
|
||||
&gdlm_attr_withdraw.attr,
|
||||
&gdlm_attr_id.attr,
|
||||
&gdlm_attr_jid.attr,
|
||||
&gdlm_attr_first.attr,
|
||||
&gdlm_attr_first_done.attr,
|
||||
&gdlm_attr_recover.attr,
|
||||
&gdlm_attr_recover_done.attr,
|
||||
&gdlm_attr_cluster.attr,
|
||||
&gdlm_attr_options.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -276,20 +174,25 @@ static struct kset gdlm_kset = {
|
||||
.ktype = &gdlm_ktype,
|
||||
};
|
||||
|
||||
int gdlm_kobject_setup(struct gdlm_ls *ls)
|
||||
int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = kobject_set_name(&ls->kobj, "%s", ls->fsname);
|
||||
if (error)
|
||||
error = kobject_set_name(&ls->kobj, "%s", "lock_module");
|
||||
if (error) {
|
||||
log_error("can't set kobj name %d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
ls->kobj.kset = &gdlm_kset;
|
||||
ls->kobj.ktype = &gdlm_ktype;
|
||||
ls->kobj.parent = fskobj;
|
||||
|
||||
error = kobject_register(&ls->kobj);
|
||||
if (error)
|
||||
log_error("can't register kobj %d", error);
|
||||
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
void gdlm_kobject_release(struct gdlm_ls *ls)
|
||||
|
@ -1,15 +1,11 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
** Copyright (C) 2004-2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include "lock_dlm.h"
|
||||
|
||||
@ -26,15 +22,10 @@ static void queue_submit(struct gdlm_lock *lp)
|
||||
wake_up(&ls->thread_wait);
|
||||
}
|
||||
|
||||
static void process_submit(struct gdlm_lock *lp)
|
||||
{
|
||||
gdlm_do_lock(lp, NULL);
|
||||
}
|
||||
|
||||
static void process_blocking(struct gdlm_lock *lp, int bast_mode)
|
||||
{
|
||||
struct gdlm_ls *ls = lp->ls;
|
||||
unsigned int cb;
|
||||
unsigned int cb = 0;
|
||||
|
||||
switch (gdlm_make_lmstate(bast_mode)) {
|
||||
case LM_ST_EXCLUSIVE:
|
||||
@ -47,7 +38,7 @@ static void process_blocking(struct gdlm_lock *lp, int bast_mode)
|
||||
cb = LM_CB_NEED_S;
|
||||
break;
|
||||
default:
|
||||
GDLM_ASSERT(0, printk("unknown bast mode %u\n",lp->bast_mode););
|
||||
gdlm_assert(0, "unknown bast mode %u", lp->bast_mode);
|
||||
}
|
||||
|
||||
ls->fscb(ls->fsdata, cb, &lp->lockname);
|
||||
@ -62,9 +53,9 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
memset(&acb, 0, sizeof(acb));
|
||||
|
||||
if (lp->lksb.sb_status == -DLM_ECANCEL) {
|
||||
log_all("complete dlm cancel %x,%"PRIx64" flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number,
|
||||
lp->flags);
|
||||
log_info("complete dlm cancel %x,%llx flags %lx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number,
|
||||
lp->flags);
|
||||
|
||||
lp->req = lp->cur;
|
||||
acb.lc_ret |= LM_OUT_CANCELED;
|
||||
@ -75,9 +66,9 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
|
||||
if (test_and_clear_bit(LFL_DLM_UNLOCK, &lp->flags)) {
|
||||
if (lp->lksb.sb_status != -DLM_EUNLOCK) {
|
||||
log_all("unlock sb_status %d %x,%"PRIx64" flags %lx",
|
||||
lp->lksb.sb_status, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->flags);
|
||||
log_info("unlock sb_status %d %x,%llx flags %lx",
|
||||
lp->lksb.sb_status, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->flags);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -108,8 +99,8 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
*/
|
||||
|
||||
if (test_and_clear_bit(LFL_CANCEL, &lp->flags)) {
|
||||
log_all("complete internal cancel %x,%"PRIx64"",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
log_info("complete internal cancel %x,%llx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
lp->req = lp->cur;
|
||||
acb.lc_ret |= LM_OUT_CANCELED;
|
||||
goto out;
|
||||
@ -130,9 +121,9 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
}
|
||||
|
||||
/* this could only happen with cancels I think */
|
||||
log_all("ast sb_status %d %x,%"PRIx64" flags %lx",
|
||||
lp->lksb.sb_status, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->flags);
|
||||
log_info("ast sb_status %d %x,%llx flags %lx",
|
||||
lp->lksb.sb_status, lp->lockname.ln_type,
|
||||
lp->lockname.ln_number, lp->flags);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,8 +143,10 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
*/
|
||||
|
||||
if (test_and_clear_bit(LFL_REREQUEST, &lp->flags)) {
|
||||
GDLM_ASSERT(lp->req == DLM_LOCK_NL,);
|
||||
GDLM_ASSERT(lp->prev_req > DLM_LOCK_NL,);
|
||||
gdlm_assert(lp->req == DLM_LOCK_NL, "%x,%llx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
gdlm_assert(lp->prev_req > DLM_LOCK_NL, "%x,%llx",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number);
|
||||
|
||||
lp->cur = DLM_LOCK_NL;
|
||||
lp->req = lp->prev_req;
|
||||
@ -189,7 +182,7 @@ static void process_complete(struct gdlm_lock *lp)
|
||||
lp->lkf |= DLM_LKF_CONVERT;
|
||||
lp->lkf &= ~DLM_LKF_CONVDEADLK;
|
||||
|
||||
log_debug("rereq %x,%"PRIx64" id %x %d,%d",
|
||||
log_debug("rereq %x,%llx id %x %d,%d",
|
||||
lp->lockname.ln_type, lp->lockname.ln_number,
|
||||
lp->lksb.sb_lkid, lp->cur, lp->req);
|
||||
|
||||
@ -315,7 +308,7 @@ static int gdlm_thread(void *data)
|
||||
process_blocking(lp, blocking);
|
||||
|
||||
else if (submit)
|
||||
process_submit(lp);
|
||||
gdlm_do_lock(lp, NULL);
|
||||
|
||||
if (drop)
|
||||
ls->fscb(ls->fsdata, LM_CB_DROPLOCKS, NULL);
|
||||
@ -334,7 +327,7 @@ int gdlm_init_threads(struct gdlm_ls *ls)
|
||||
p = kthread_run(gdlm_thread, ls, "lock_dlm1");
|
||||
error = IS_ERR(p);
|
||||
if (error) {
|
||||
log_all("can't start lock_dlm1 thread %d", error);
|
||||
log_error("can't start lock_dlm1 thread %d", error);
|
||||
return error;
|
||||
}
|
||||
ls->thread1 = p;
|
||||
@ -342,7 +335,7 @@ int gdlm_init_threads(struct gdlm_ls *ls)
|
||||
p = kthread_run(gdlm_thread, ls, "lock_dlm2");
|
||||
error = IS_ERR(p);
|
||||
if (error) {
|
||||
log_all("can't start lock_dlm2 thread %d", error);
|
||||
log_error("can't start lock_dlm2 thread %d", error);
|
||||
kthread_stop(ls->thread1);
|
||||
return error;
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/vermagic.h>
|
||||
#include <linux/compiler.h>
|
||||
|
||||
MODULE_INFO(vermagic, VERMAGIC_STRING);
|
||||
|
||||
#undef unix
|
||||
struct module __this_module
|
||||
__attribute__((section(".gnu.linkonce.this_module"))) = {
|
||||
.name = __stringify(KBUILD_MODNAME),
|
||||
.init = init_module,
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
.exit = cleanup_module,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct modversion_info ____versions[]
|
||||
__attribute_used__
|
||||
__attribute__((section("__versions"))) = {
|
||||
{ 0x316962fc, "struct_module" },
|
||||
{ 0x5a34a45c, "__kmalloc" },
|
||||
{ 0x724beef2, "malloc_sizes" },
|
||||
{ 0x3fa03a97, "memset" },
|
||||
{ 0xc16fe12d, "__memcpy" },
|
||||
{ 0xdd132261, "printk" },
|
||||
{ 0x859204af, "sscanf" },
|
||||
{ 0x3656bf5a, "lock_kernel" },
|
||||
{ 0x1e6d26a8, "strstr" },
|
||||
{ 0x41ede9df, "lm_register_proto" },
|
||||
{ 0xb1f975aa, "unlock_kernel" },
|
||||
{ 0x87b0b01f, "posix_lock_file_wait" },
|
||||
{ 0x75f29cfd, "kmem_cache_alloc" },
|
||||
{ 0x69384280, "lm_unregister_proto" },
|
||||
{ 0x37a0cba, "kfree" },
|
||||
{ 0x5d16bfe6, "posix_test_lock" },
|
||||
};
|
||||
|
||||
static const char __module_depends[]
|
||||
__attribute_used__
|
||||
__attribute__((section(".modinfo"))) =
|
||||
"depends=gfs2";
|
||||
|
||||
|
||||
MODULE_INFO(srcversion, "123E446F965A386A0C017C4");
|
@ -1,15 +1,11 @@
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
**
|
||||
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
** Copyright (C) 2004-2005 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.
|
||||
**
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
@ -27,23 +23,11 @@ struct nolock_lockspace {
|
||||
|
||||
struct lm_lockops nolock_ops;
|
||||
|
||||
/**
|
||||
* nolock_mount - mount a nolock lockspace
|
||||
* @table_name: the name of the space to mount
|
||||
* @host_data: host specific data
|
||||
* @cb: the callback
|
||||
* @fsdata:
|
||||
* @min_lvb_size:
|
||||
* @flags:
|
||||
* @lockstruct: the structure of crap to fill in
|
||||
*
|
||||
* Returns: 0 on success, -EXXX on failure
|
||||
*/
|
||||
|
||||
static int nolock_mount(char *table_name, char *host_data,
|
||||
lm_callback_t cb, lm_fsdata_t *fsdata,
|
||||
unsigned int min_lvb_size, int flags,
|
||||
struct lm_lockstruct *lockstruct)
|
||||
struct lm_lockstruct *lockstruct,
|
||||
struct kobject *fskobj)
|
||||
{
|
||||
char *c;
|
||||
unsigned int jid;
|
||||
@ -77,34 +61,16 @@ static int nolock_mount(char *table_name, char *host_data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_others_may_mount - unmount a lock space
|
||||
* @lockspace: the lockspace to unmount
|
||||
*
|
||||
*/
|
||||
|
||||
static void nolock_others_may_mount(lm_lockspace_t *lockspace)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_unmount - unmount a lock space
|
||||
* @lockspace: the lockspace to unmount
|
||||
*
|
||||
*/
|
||||
|
||||
static void nolock_unmount(lm_lockspace_t *lockspace)
|
||||
{
|
||||
struct nolock_lockspace *nl = (struct nolock_lockspace *)lockspace;
|
||||
kfree(nl);
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_withdraw - withdraw from a lock space
|
||||
* @lockspace: the lockspace
|
||||
*
|
||||
*/
|
||||
|
||||
static void nolock_withdraw(lm_lockspace_t *lockspace)
|
||||
{
|
||||
}
|
||||
@ -164,12 +130,6 @@ static unsigned int nolock_unlock(lm_lock_t *lock, unsigned int cur_state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_cancel - cancel a request on a lock
|
||||
* @lock: the lock to cancel request for
|
||||
*
|
||||
*/
|
||||
|
||||
static void nolock_cancel(lm_lock_t *lock)
|
||||
{
|
||||
}
|
||||
@ -219,16 +179,6 @@ static void nolock_sync_lvb(lm_lock_t *lock, char *lvb)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_plock_get -
|
||||
* @lockspace: the lockspace
|
||||
* @name:
|
||||
* @file:
|
||||
* @fl:
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
static int nolock_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
@ -244,17 +194,6 @@ static int nolock_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_plock -
|
||||
* @lockspace: the lockspace
|
||||
* @name:
|
||||
* @file:
|
||||
* @cmd:
|
||||
* @fl:
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
static int nolock_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, int cmd, struct file_lock *fl)
|
||||
{
|
||||
@ -265,16 +204,6 @@ static int nolock_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_punlock -
|
||||
* @lockspace: the lockspace
|
||||
* @name:
|
||||
* @file:
|
||||
* @fl:
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
static int nolock_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
struct file *file, struct file_lock *fl)
|
||||
{
|
||||
@ -285,13 +214,6 @@ static int nolock_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* nolock_recovery_done - reset the expired locks for a given jid
|
||||
* @lockspace: the lockspace
|
||||
* @jid: the jid
|
||||
*
|
||||
*/
|
||||
|
||||
static void nolock_recovery_done(lm_lockspace_t *lockspace, unsigned int jid,
|
||||
unsigned int message)
|
||||
{
|
||||
@ -318,17 +240,11 @@ struct lm_lockops nolock_ops = {
|
||||
.lm_owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
/**
|
||||
* init_nolock - Initialize the nolock module
|
||||
*
|
||||
* Returns: 0 on success, -EXXX on failure
|
||||
*/
|
||||
|
||||
int __init init_nolock(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = lm_register_proto(&nolock_ops);
|
||||
error = gfs_register_lockproto(&nolock_ops);
|
||||
if (error) {
|
||||
printk("lock_nolock: can't register protocol: %d\n", error);
|
||||
return error;
|
||||
@ -338,14 +254,9 @@ int __init init_nolock(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* exit_nolock - cleanup the nolock module
|
||||
*
|
||||
*/
|
||||
|
||||
void __exit exit_nolock(void)
|
||||
{
|
||||
lm_unregister_proto(&nolock_ops);
|
||||
gfs_unregister_lockproto(&nolock_ops);
|
||||
}
|
||||
|
||||
module_init(init_nolock);
|
||||
|
40
include/linux/lock_dlm_plock.h
Normal file
40
include/linux/lock_dlm_plock.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2005 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__
|
||||
|
||||
#define GDLM_PLOCK_MISC_NAME "lock_dlm_plock"
|
||||
|
||||
#define GDLM_PLOCK_VERSION_MAJOR 1
|
||||
#define GDLM_PLOCK_VERSION_MINOR 0
|
||||
#define GDLM_PLOCK_VERSION_PATCH 0
|
||||
|
||||
enum {
|
||||
GDLM_PLOCK_OP_LOCK = 1,
|
||||
GDLM_PLOCK_OP_UNLOCK,
|
||||
GDLM_PLOCK_OP_GET,
|
||||
};
|
||||
|
||||
struct gdlm_plock_info {
|
||||
__u32 version[3];
|
||||
__u8 optype;
|
||||
__u8 ex;
|
||||
__u8 wait;
|
||||
__u8 pad;
|
||||
__u32 pid;
|
||||
__s32 nodeid;
|
||||
__s32 rv;
|
||||
__u32 fsid;
|
||||
__u64 number;
|
||||
__u64 start;
|
||||
__u64 end;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user