Commit 0d5dc6c2 authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: Teach ocfs2_drop_lock() to use ->set_lvb() callback

With this, we don't need to pass an additional struct with function pointer.

Now that the callbacks are fully used, comment the remaining API.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent b5e500e2
...@@ -107,6 +107,14 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb, ...@@ -107,6 +107,14 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
* OCFS2 Lock Resource Operations * OCFS2 Lock Resource Operations
* *
* These fine tune the behavior of the generic dlmglue locking infrastructure. * These fine tune the behavior of the generic dlmglue locking infrastructure.
*
* The most basic of lock types can point ->l_priv to their respective
* struct ocfs2_super and allow the default actions to manage things.
*
* Right now, each lock type also needs to implement an init function,
* and trivial lock/unlock wrappers. ocfs2_simple_drop_lockres()
* should be called when the lock is no longer needed (i.e., object
* destruction time).
*/ */
struct ocfs2_lock_res_ops { struct ocfs2_lock_res_ops {
/* /*
...@@ -115,6 +123,15 @@ struct ocfs2_lock_res_ops { ...@@ -115,6 +123,15 @@ struct ocfs2_lock_res_ops {
*/ */
struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *); struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *);
/*
* Optionally called in the downconvert (or "vote") thread
* after a successful downconvert. The lockres will not be
* referenced after this callback is called, so it is safe to
* free memory, etc.
*
* The exact semantics of when this is called are controlled
* by ->downconvert_worker()
*/
void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *); void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *);
/* /*
...@@ -2230,16 +2247,8 @@ static void ocfs2_unlock_ast(void *opaque, enum dlm_status status) ...@@ -2230,16 +2247,8 @@ static void ocfs2_unlock_ast(void *opaque, enum dlm_status status)
mlog_exit_void(); mlog_exit_void();
} }
typedef void (ocfs2_pre_drop_cb_t)(struct ocfs2_lock_res *, void *);
struct drop_lock_cb {
ocfs2_pre_drop_cb_t *drop_func;
void *drop_data;
};
static int ocfs2_drop_lock(struct ocfs2_super *osb, static int ocfs2_drop_lock(struct ocfs2_super *osb,
struct ocfs2_lock_res *lockres, struct ocfs2_lock_res *lockres)
struct drop_lock_cb *dcb)
{ {
enum dlm_status status; enum dlm_status status;
unsigned long flags; unsigned long flags;
...@@ -2274,8 +2283,12 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb, ...@@ -2274,8 +2283,12 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
spin_lock_irqsave(&lockres->l_lock, flags); spin_lock_irqsave(&lockres->l_lock, flags);
} }
if (dcb) if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) {
dcb->drop_func(lockres, dcb->drop_data); if (lockres->l_flags & OCFS2_LOCK_ATTACHED &&
lockres->l_level == LKM_EXMODE &&
!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH))
lockres->l_ops->set_lvb(lockres);
}
if (lockres->l_flags & OCFS2_LOCK_BUSY) if (lockres->l_flags & OCFS2_LOCK_BUSY)
mlog(ML_ERROR, "destroying busy lock: \"%s\"\n", mlog(ML_ERROR, "destroying busy lock: \"%s\"\n",
...@@ -2355,7 +2368,7 @@ void ocfs2_simple_drop_lockres(struct ocfs2_super *osb, ...@@ -2355,7 +2368,7 @@ void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
int ret; int ret;
ocfs2_mark_lockres_freeing(lockres); ocfs2_mark_lockres_freeing(lockres);
ret = ocfs2_drop_lock(osb, lockres, NULL); ret = ocfs2_drop_lock(osb, lockres);
if (ret) if (ret)
mlog_errno(ret); mlog_errno(ret);
} }
...@@ -2366,22 +2379,9 @@ static void ocfs2_drop_osb_locks(struct ocfs2_super *osb) ...@@ -2366,22 +2379,9 @@ static void ocfs2_drop_osb_locks(struct ocfs2_super *osb)
ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres); ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres);
} }
static void ocfs2_meta_pre_drop(struct ocfs2_lock_res *lockres, void *data)
{
struct inode *inode = data;
/* the metadata lock requires a bit more work as we have an
* LVB to worry about. */
if (lockres->l_flags & OCFS2_LOCK_ATTACHED &&
lockres->l_level == LKM_EXMODE &&
!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH))
__ocfs2_stuff_meta_lvb(inode);
}
int ocfs2_drop_inode_locks(struct inode *inode) int ocfs2_drop_inode_locks(struct inode *inode)
{ {
int status, err; int status, err;
struct drop_lock_cb meta_dcb = { ocfs2_meta_pre_drop, inode, };
mlog_entry_void(); mlog_entry_void();
...@@ -2389,24 +2389,21 @@ int ocfs2_drop_inode_locks(struct inode *inode) ...@@ -2389,24 +2389,21 @@ int ocfs2_drop_inode_locks(struct inode *inode)
* ocfs2_clear_inode has done it for us. */ * ocfs2_clear_inode has done it for us. */
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
&OCFS2_I(inode)->ip_data_lockres, &OCFS2_I(inode)->ip_data_lockres);
NULL);
if (err < 0) if (err < 0)
mlog_errno(err); mlog_errno(err);
status = err; status = err;
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
&OCFS2_I(inode)->ip_meta_lockres, &OCFS2_I(inode)->ip_meta_lockres);
&meta_dcb);
if (err < 0) if (err < 0)
mlog_errno(err); mlog_errno(err);
if (err < 0 && !status) if (err < 0 && !status)
status = err; status = err;
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
&OCFS2_I(inode)->ip_rw_lockres, &OCFS2_I(inode)->ip_rw_lockres);
NULL);
if (err < 0) if (err < 0)
mlog_errno(err); mlog_errno(err);
if (err < 0 && !status) if (err < 0 && !status)
......
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