Skip to content

Commit

Permalink
ocfs2: combine inode and generic blocking AST functions
Browse files Browse the repository at this point in the history
There is extremely little difference between the two now. We can remove the
callback from ocfs2_lock_res_ops as well.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
  • Loading branch information
Mark Fasheh committed Sep 24, 2006
1 parent 54a7e75 commit aa2623a
Showing 1 changed file with 11 additions and 112 deletions.
123 changes: 11 additions & 112 deletions fs/ocfs2/dlmglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ struct ocfs2_mask_waiter {
unsigned long mw_goal;
};

static void ocfs2_inode_bast_func(void *opaque,
int level);
static void ocfs2_dentry_bast_func(void *opaque,
int level);
static void ocfs2_super_bast_func(void *opaque,
int level);
static void ocfs2_rename_bast_func(void *opaque,
int level);
static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);

Expand Down Expand Up @@ -123,7 +115,6 @@ struct ocfs2_lock_res_ops {
* this callback if ->l_priv is not an ocfs2_super pointer
*/
struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *);
void (*bast)(void *, int);
int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *);
void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *);

Expand Down Expand Up @@ -152,40 +143,34 @@ static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb,

static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
.get_osb = ocfs2_get_inode_osb,
.bast = ocfs2_inode_bast_func,
.unblock = ocfs2_unblock_inode_lock,
.flags = 0,
};

static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = {
.get_osb = ocfs2_get_inode_osb,
.bast = ocfs2_inode_bast_func,
.unblock = ocfs2_unblock_meta,
.flags = LOCK_TYPE_REQUIRES_REFRESH,
};

static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = {
.get_osb = ocfs2_get_inode_osb,
.bast = ocfs2_inode_bast_func,
.unblock = ocfs2_unblock_data,
.flags = 0,
};

static struct ocfs2_lock_res_ops ocfs2_super_lops = {
.bast = ocfs2_super_bast_func,
.unblock = ocfs2_unblock_osb_lock,
.flags = LOCK_TYPE_REQUIRES_REFRESH,
};

static struct ocfs2_lock_res_ops ocfs2_rename_lops = {
.bast = ocfs2_rename_bast_func,
.unblock = ocfs2_unblock_osb_lock,
.flags = 0,
};

static struct ocfs2_lock_res_ops ocfs2_dentry_lops = {
.get_osb = ocfs2_get_dentry_osb,
.bast = ocfs2_dentry_bast_func,
.unblock = ocfs2_unblock_dentry_lock,
.post_unlock = ocfs2_dentry_post_unlock,
.flags = 0,
Expand All @@ -198,24 +183,6 @@ static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres)
lockres->l_type == OCFS2_LOCK_TYPE_RW;
}

static inline int ocfs2_is_super_lock(struct ocfs2_lock_res *lockres)
{
return lockres->l_type == OCFS2_LOCK_TYPE_SUPER;
}

static inline int ocfs2_is_rename_lock(struct ocfs2_lock_res *lockres)
{
return lockres->l_type == OCFS2_LOCK_TYPE_RENAME;
}

static inline struct ocfs2_super *ocfs2_lock_res_super(struct ocfs2_lock_res *lockres)
{
BUG_ON(!ocfs2_is_super_lock(lockres)
&& !ocfs2_is_rename_lock(lockres));

return (struct ocfs2_super *) lockres->l_priv;
}

static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres)
{
BUG_ON(!ocfs2_is_inode_lock(lockres));
Expand Down Expand Up @@ -663,17 +630,19 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres,
return needs_downconvert;
}

static void ocfs2_generic_bast_func(struct ocfs2_super *osb,
struct ocfs2_lock_res *lockres,
int level)
static void ocfs2_blocking_ast(void *opaque, int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
int needs_downconvert;
unsigned long flags;

mlog_entry_void();

BUG_ON(level <= LKM_NLMODE);

mlog(0, "BAST fired for lockres %s, blocking %d, level %d type %s\n",
lockres->l_name, level, lockres->l_level,
ocfs2_lock_type_string(lockres->l_type));

spin_lock_irqsave(&lockres->l_lock, flags);
needs_downconvert = ocfs2_generic_handle_bast(lockres, level);
if (needs_downconvert)
Expand All @@ -683,30 +652,6 @@ static void ocfs2_generic_bast_func(struct ocfs2_super *osb,
wake_up(&lockres->l_event);

ocfs2_kick_vote_thread(osb);

mlog_exit_void();
}

static void ocfs2_inode_bast_func(void *opaque, int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct inode *inode;
struct ocfs2_super *osb;

mlog_entry_void();

BUG_ON(!ocfs2_is_inode_lock(lockres));

inode = ocfs2_lock_res_inode(lockres);
osb = OCFS2_SB(inode->i_sb);

mlog(0, "BAST fired for inode %llu, blocking %d, level %d type %s\n",
(unsigned long long)OCFS2_I(inode)->ip_blkno, level,
lockres->l_level, ocfs2_lock_type_string(lockres->l_type));

ocfs2_generic_bast_func(osb, lockres, level);

mlog_exit_void();
}

static void ocfs2_locking_ast(void *opaque)
Expand Down Expand Up @@ -751,52 +696,6 @@ static void ocfs2_locking_ast(void *opaque)
spin_unlock_irqrestore(&lockres->l_lock, flags);
}

static void ocfs2_super_bast_func(void *opaque,
int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_super *osb;

mlog_entry_void();
mlog(0, "Superblock BAST fired\n");

BUG_ON(!ocfs2_is_super_lock(lockres));
osb = ocfs2_lock_res_super(lockres);
ocfs2_generic_bast_func(osb, lockres, level);

mlog_exit_void();
}

static void ocfs2_rename_bast_func(void *opaque,
int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_super *osb;

mlog_entry_void();

mlog(0, "Rename BAST fired\n");

BUG_ON(!ocfs2_is_rename_lock(lockres));

osb = ocfs2_lock_res_super(lockres);
ocfs2_generic_bast_func(osb, lockres, level);

mlog_exit_void();
}

static void ocfs2_dentry_bast_func(void *opaque, int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct ocfs2_dentry_lock *dl = lockres->l_priv;
struct ocfs2_super *osb = OCFS2_SB(dl->dl_inode->i_sb);

mlog(0, "Dentry bast: level: %d, name: %s\n", level,
lockres->l_name);

ocfs2_generic_bast_func(osb, lockres, level);
}

static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
int convert)
{
Expand Down Expand Up @@ -853,7 +752,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
OCFS2_LOCK_ID_MAX_LEN - 1,
ocfs2_locking_ast,
lockres,
lockres->l_ops->bast);
ocfs2_blocking_ast);
if (status != DLM_NORMAL) {
ocfs2_log_dlm_error("dlmlock", status, lockres);
ret = -EINVAL;
Expand Down Expand Up @@ -1043,7 +942,7 @@ static int ocfs2_cluster_lock(struct ocfs2_super *osb,
OCFS2_LOCK_ID_MAX_LEN - 1,
ocfs2_locking_ast,
lockres,
lockres->l_ops->bast);
ocfs2_blocking_ast);
if (status != DLM_NORMAL) {
if ((lkm_flags & LKM_NOQUEUE) &&
(status == DLM_NOTQUEUED))
Expand Down Expand Up @@ -2524,7 +2423,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
OCFS2_LOCK_ID_MAX_LEN - 1,
ocfs2_locking_ast,
lockres,
lockres->l_ops->bast);
ocfs2_blocking_ast);
if (status != DLM_NORMAL) {
ocfs2_log_dlm_error("dlmlock", status, lockres);
ret = -EINVAL;
Expand Down Expand Up @@ -3040,7 +2939,7 @@ static int ocfs2_unblock_osb_lock(struct ocfs2_lock_res *lockres,

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

osb = ocfs2_lock_res_super(lockres);
osb = ocfs2_get_lockres_osb(lockres);

status = ocfs2_generic_unblock_lock(osb,
lockres,
Expand Down

0 comments on commit aa2623a

Please sign in to comment.