Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185453
b: refs/heads/master
c: a796d28
h: refs/heads/master
i:
  185451: bbc82cb
v: v3
  • Loading branch information
Joel Becker committed Feb 26, 2010
1 parent bba8958 commit 157e080
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 77 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 34a9dd7e29e9129fec40c645a03f1bbbe810e771
refs/heads/master: a796d2862aed8117acc9f470f3429a5ee852912e
34 changes: 17 additions & 17 deletions trunk/fs/ocfs2/dlmglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres)
lockres->l_type == OCFS2_LOCK_TYPE_OPEN;
}

static inline struct ocfs2_lock_res *ocfs2_lksb_to_lock_res(union ocfs2_dlm_lksb *lksb)
{
return container_of(lksb, struct ocfs2_lock_res, l_lksb);
}

static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres)
{
BUG_ON(!ocfs2_is_inode_lock(lockres));
Expand Down Expand Up @@ -1041,9 +1046,9 @@ static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres)
}


static void ocfs2_blocking_ast(void *opaque, int level)
static void ocfs2_blocking_ast(union ocfs2_dlm_lksb *lksb, int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
int needs_downconvert;
unsigned long flags;
Expand Down Expand Up @@ -1072,9 +1077,9 @@ static void ocfs2_blocking_ast(void *opaque, int level)
ocfs2_wake_downconvert_thread(osb);
}

static void ocfs2_locking_ast(void *opaque)
static void ocfs2_locking_ast(union ocfs2_dlm_lksb *lksb)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
unsigned long flags;
int status;
Expand Down Expand Up @@ -1189,8 +1194,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
&lockres->l_lksb,
dlm_flags,
lockres->l_name,
OCFS2_LOCK_ID_MAX_LEN - 1,
lockres);
OCFS2_LOCK_ID_MAX_LEN - 1);
lockres_clear_pending(lockres, gen, osb);
if (ret) {
ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
Expand Down Expand Up @@ -1421,8 +1425,7 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
&lockres->l_lksb,
lkm_flags,
lockres->l_name,
OCFS2_LOCK_ID_MAX_LEN - 1,
lockres);
OCFS2_LOCK_ID_MAX_LEN - 1);
lockres_clear_pending(lockres, gen, osb);
if (ret) {
if (!(lkm_flags & DLM_LKF_NOQUEUE) ||
Expand Down Expand Up @@ -1859,8 +1862,7 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
spin_unlock_irqrestore(&lockres->l_lock, flags);

ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags,
lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1,
lockres);
lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1);
if (ret) {
if (!trylock || (ret != -EAGAIN)) {
ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
Expand Down Expand Up @@ -3056,9 +3058,9 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
mlog_exit_void();
}

static void ocfs2_unlock_ast(void *opaque, int error)
static void ocfs2_unlock_ast(union ocfs2_dlm_lksb *lksb, int error)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
unsigned long flags;

mlog_entry_void();
Expand Down Expand Up @@ -3167,8 +3169,7 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,

mlog(0, "lock %s\n", lockres->l_name);

ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags,
lockres);
ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags);
if (ret) {
ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres);
mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags);
Expand Down Expand Up @@ -3309,8 +3310,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
&lockres->l_lksb,
dlm_flags,
lockres->l_name,
OCFS2_LOCK_ID_MAX_LEN - 1,
lockres);
OCFS2_LOCK_ID_MAX_LEN - 1);
lockres_clear_pending(lockres, generation, osb);
if (ret) {
ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
Expand Down Expand Up @@ -3365,7 +3365,7 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb,
mlog(0, "lock %s\n", lockres->l_name);

ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb,
DLM_LKF_CANCEL, lockres);
DLM_LKF_CANCEL);
if (ret) {
ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres);
ocfs2_recover_from_dlm_error(lockres, 0);
Expand Down
22 changes: 13 additions & 9 deletions trunk/fs/ocfs2/stack_o2cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,26 @@ static int dlm_status_to_errno(enum dlm_status status)

static void o2dlm_lock_ast_wrapper(void *astarg)
{
union ocfs2_dlm_lksb *lksb = astarg;

BUG_ON(o2cb_stack.sp_proto == NULL);

o2cb_stack.sp_proto->lp_lock_ast(astarg);
o2cb_stack.sp_proto->lp_lock_ast(lksb);
}

static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
{
union ocfs2_dlm_lksb *lksb = astarg;

BUG_ON(o2cb_stack.sp_proto == NULL);

o2cb_stack.sp_proto->lp_blocking_ast(astarg, level);
o2cb_stack.sp_proto->lp_blocking_ast(lksb, level);
}

static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
{
union ocfs2_dlm_lksb *lksb = astarg;

int error = dlm_status_to_errno(status);

BUG_ON(o2cb_stack.sp_proto == NULL);
Expand All @@ -193,16 +199,15 @@ static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
if (status == DLM_CANCELGRANT)
return;

o2cb_stack.sp_proto->lp_unlock_ast(astarg, error);
o2cb_stack.sp_proto->lp_unlock_ast(lksb, error);
}

static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
int mode,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen,
void *astarg)
unsigned int namelen)
{
enum dlm_status status;
int o2dlm_mode = mode_to_o2dlm(mode);
Expand All @@ -211,23 +216,22 @@ static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,

status = dlmlock(conn->cc_lockspace, o2dlm_mode, &lksb->lksb_o2dlm,
o2dlm_flags, name, namelen,
o2dlm_lock_ast_wrapper, astarg,
o2dlm_lock_ast_wrapper, lksb,
o2dlm_blocking_ast_wrapper);
ret = dlm_status_to_errno(status);
return ret;
}

static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *astarg)
u32 flags)
{
enum dlm_status status;
int o2dlm_flags = flags_to_o2dlm(flags);
int ret;

status = dlmunlock(conn->cc_lockspace, &lksb->lksb_o2dlm,
o2dlm_flags, o2dlm_unlock_ast_wrapper, astarg);
o2dlm_flags, o2dlm_unlock_ast_wrapper, lksb);
ret = dlm_status_to_errno(status);
return ret;
}
Expand Down
29 changes: 11 additions & 18 deletions trunk/fs/ocfs2/stack_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/reboot.h>
#include <asm/uaccess.h>

#include "ocfs2.h" /* For struct ocfs2_lock_res */
#include "stackglue.h"

#include <linux/dlm_plock.h>
Expand Down Expand Up @@ -664,16 +663,10 @@ static void ocfs2_control_exit(void)
-rc);
}

static struct dlm_lksb *fsdlm_astarg_to_lksb(void *astarg)
{
struct ocfs2_lock_res *res = astarg;
return &res->l_lksb.lksb_fsdlm;
}

static void fsdlm_lock_ast_wrapper(void *astarg)
{
struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg);
int status = lksb->sb_status;
union ocfs2_dlm_lksb *lksb = astarg;
int status = lksb->lksb_fsdlm.sb_status;

BUG_ON(ocfs2_user_plugin.sp_proto == NULL);

Expand All @@ -688,25 +681,26 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
*/

if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL)
ocfs2_user_plugin.sp_proto->lp_unlock_ast(astarg, 0);
ocfs2_user_plugin.sp_proto->lp_unlock_ast(lksb, 0);
else
ocfs2_user_plugin.sp_proto->lp_lock_ast(astarg);
ocfs2_user_plugin.sp_proto->lp_lock_ast(lksb);
}

static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
{
union ocfs2_dlm_lksb *lksb = astarg;

BUG_ON(ocfs2_user_plugin.sp_proto == NULL);

ocfs2_user_plugin.sp_proto->lp_blocking_ast(astarg, level);
ocfs2_user_plugin.sp_proto->lp_blocking_ast(lksb, level);
}

static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
int mode,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen,
void *astarg)
unsigned int namelen)
{
int ret;

Expand All @@ -716,20 +710,19 @@ static int user_dlm_lock(struct ocfs2_cluster_connection *conn,

ret = dlm_lock(conn->cc_lockspace, mode, &lksb->lksb_fsdlm,
flags|DLM_LKF_NODLCKWT, name, namelen, 0,
fsdlm_lock_ast_wrapper, astarg,
fsdlm_lock_ast_wrapper, lksb,
fsdlm_blocking_ast_wrapper);
return ret;
}

static int user_dlm_unlock(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *astarg)
u32 flags)
{
int ret;

ret = dlm_unlock(conn->cc_lockspace, lksb->lksb_fsdlm.sb_lkid,
flags, &lksb->lksb_fsdlm, astarg);
flags, &lksb->lksb_fsdlm, lksb);
return ret;
}

Expand Down
19 changes: 8 additions & 11 deletions trunk/fs/ocfs2/stackglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,35 +233,32 @@ EXPORT_SYMBOL_GPL(ocfs2_stack_glue_set_locking_protocol);


/*
* The ocfs2_dlm_lock() and ocfs2_dlm_unlock() functions take
* "struct ocfs2_lock_res *astarg" instead of "void *astarg" because the
* underlying stack plugins need to pilfer the lksb off of the lock_res.
* If some other structure needs to be passed as an astarg, the plugins
* will need to be given a different avenue to the lksb.
* The ocfs2_dlm_lock() and ocfs2_dlm_unlock() functions take no argument
* for the ast and bast functions. They will pass the lksb to the ast
* and bast. The caller can wrap the lksb with their own structure to
* get more information.
*/
int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
int mode,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen,
struct ocfs2_lock_res *astarg)
unsigned int namelen)
{
BUG_ON(lproto == NULL);

return active_stack->sp_ops->dlm_lock(conn, mode, lksb, flags,
name, namelen, astarg);
name, namelen);
}
EXPORT_SYMBOL_GPL(ocfs2_dlm_lock);

int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
struct ocfs2_lock_res *astarg)
u32 flags)
{
BUG_ON(lproto == NULL);

return active_stack->sp_ops->dlm_unlock(conn, lksb, flags, astarg);
return active_stack->sp_ops->dlm_unlock(conn, lksb, flags);
}
EXPORT_SYMBOL_GPL(ocfs2_dlm_unlock);

Expand Down
42 changes: 21 additions & 21 deletions trunk/fs/ocfs2/stackglue.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ struct ocfs2_protocol_version {
u8 pv_minor;
};

/*
* The ocfs2_locking_protocol defines the handlers called on ocfs2's behalf.
*/
struct ocfs2_locking_protocol {
struct ocfs2_protocol_version lp_max_version;
void (*lp_lock_ast)(void *astarg);
void (*lp_blocking_ast)(void *astarg, int level);
void (*lp_unlock_ast)(void *astarg, int error);
};


/*
* The dlm_lockstatus struct includes lvb space, but the dlm_lksb struct only
* has a pointer to separately allocated lvb space. This struct exists only to
Expand All @@ -87,6 +76,17 @@ union ocfs2_dlm_lksb {
struct fsdlm_lksb_plus_lvb padding;
};

/*
* The ocfs2_locking_protocol defines the handlers called on ocfs2's behalf.
*/
struct ocfs2_locking_protocol {
struct ocfs2_protocol_version lp_max_version;
void (*lp_lock_ast)(union ocfs2_dlm_lksb *lksb);
void (*lp_blocking_ast)(union ocfs2_dlm_lksb *lksb, int level);
void (*lp_unlock_ast)(union ocfs2_dlm_lksb *lksb, int error);
};


/*
* A cluster connection. Mostly opaque to ocfs2, the connection holds
* state for the underlying stack. ocfs2 does use cc_version to determine
Expand Down Expand Up @@ -155,27 +155,29 @@ struct ocfs2_stack_operations {
*
* ast and bast functions are not part of the call because the
* stack will likely want to wrap ast and bast calls before passing
* them to stack->sp_proto.
* them to stack->sp_proto. There is no astarg. The lksb will
* be passed back to the ast and bast functions. The caller can
* use this to find their object.
*/
int (*dlm_lock)(struct ocfs2_cluster_connection *conn,
int mode,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen,
void *astarg);
unsigned int namelen);

/*
* Call the underlying dlm unlock function. The ->dlm_unlock()
* function should convert the flags as appropriate.
*
* The unlock ast is not passed, as the stack will want to wrap
* it before calling stack->sp_proto->lp_unlock_ast().
* it before calling stack->sp_proto->lp_unlock_ast(). There is
* no astarg. The lksb will be passed back to the unlock ast
* function. The caller can use this to find their object.
*/
int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *astarg);
u32 flags);

/*
* Return the status of the current lock status block. The fs
Expand Down Expand Up @@ -249,12 +251,10 @@ int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen,
struct ocfs2_lock_res *astarg);
unsigned int namelen);
int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
union ocfs2_dlm_lksb *lksb,
u32 flags,
struct ocfs2_lock_res *astarg);
u32 flags);

int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb);
int ocfs2_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb);
Expand Down

0 comments on commit 157e080

Please sign in to comment.