Skip to content

Commit 0d5dc6c

Browse files
author
Mark Fasheh
committed
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: Mark Fasheh <mark.fasheh@oracle.com>
1 parent b5e500e commit 0d5dc6c

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

fs/ocfs2/dlmglue.c

+28-31
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
107107
* OCFS2 Lock Resource Operations
108108
*
109109
* These fine tune the behavior of the generic dlmglue locking infrastructure.
110+
*
111+
* The most basic of lock types can point ->l_priv to their respective
112+
* struct ocfs2_super and allow the default actions to manage things.
113+
*
114+
* Right now, each lock type also needs to implement an init function,
115+
* and trivial lock/unlock wrappers. ocfs2_simple_drop_lockres()
116+
* should be called when the lock is no longer needed (i.e., object
117+
* destruction time).
110118
*/
111119
struct ocfs2_lock_res_ops {
112120
/*
@@ -115,6 +123,15 @@ struct ocfs2_lock_res_ops {
115123
*/
116124
struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *);
117125

126+
/*
127+
* Optionally called in the downconvert (or "vote") thread
128+
* after a successful downconvert. The lockres will not be
129+
* referenced after this callback is called, so it is safe to
130+
* free memory, etc.
131+
*
132+
* The exact semantics of when this is called are controlled
133+
* by ->downconvert_worker()
134+
*/
118135
void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *);
119136

120137
/*
@@ -2230,16 +2247,8 @@ static void ocfs2_unlock_ast(void *opaque, enum dlm_status status)
22302247
mlog_exit_void();
22312248
}
22322249

2233-
typedef void (ocfs2_pre_drop_cb_t)(struct ocfs2_lock_res *, void *);
2234-
2235-
struct drop_lock_cb {
2236-
ocfs2_pre_drop_cb_t *drop_func;
2237-
void *drop_data;
2238-
};
2239-
22402250
static int ocfs2_drop_lock(struct ocfs2_super *osb,
2241-
struct ocfs2_lock_res *lockres,
2242-
struct drop_lock_cb *dcb)
2251+
struct ocfs2_lock_res *lockres)
22432252
{
22442253
enum dlm_status status;
22452254
unsigned long flags;
@@ -2274,8 +2283,12 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
22742283
spin_lock_irqsave(&lockres->l_lock, flags);
22752284
}
22762285

2277-
if (dcb)
2278-
dcb->drop_func(lockres, dcb->drop_data);
2286+
if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) {
2287+
if (lockres->l_flags & OCFS2_LOCK_ATTACHED &&
2288+
lockres->l_level == LKM_EXMODE &&
2289+
!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH))
2290+
lockres->l_ops->set_lvb(lockres);
2291+
}
22792292

22802293
if (lockres->l_flags & OCFS2_LOCK_BUSY)
22812294
mlog(ML_ERROR, "destroying busy lock: \"%s\"\n",
@@ -2355,7 +2368,7 @@ void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
23552368
int ret;
23562369

23572370
ocfs2_mark_lockres_freeing(lockres);
2358-
ret = ocfs2_drop_lock(osb, lockres, NULL);
2371+
ret = ocfs2_drop_lock(osb, lockres);
23592372
if (ret)
23602373
mlog_errno(ret);
23612374
}
@@ -2366,47 +2379,31 @@ static void ocfs2_drop_osb_locks(struct ocfs2_super *osb)
23662379
ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres);
23672380
}
23682381

2369-
static void ocfs2_meta_pre_drop(struct ocfs2_lock_res *lockres, void *data)
2370-
{
2371-
struct inode *inode = data;
2372-
2373-
/* the metadata lock requires a bit more work as we have an
2374-
* LVB to worry about. */
2375-
if (lockres->l_flags & OCFS2_LOCK_ATTACHED &&
2376-
lockres->l_level == LKM_EXMODE &&
2377-
!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH))
2378-
__ocfs2_stuff_meta_lvb(inode);
2379-
}
2380-
23812382
int ocfs2_drop_inode_locks(struct inode *inode)
23822383
{
23832384
int status, err;
2384-
struct drop_lock_cb meta_dcb = { ocfs2_meta_pre_drop, inode, };
23852385

23862386
mlog_entry_void();
23872387

23882388
/* No need to call ocfs2_mark_lockres_freeing here -
23892389
* ocfs2_clear_inode has done it for us. */
23902390

23912391
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
2392-
&OCFS2_I(inode)->ip_data_lockres,
2393-
NULL);
2392+
&OCFS2_I(inode)->ip_data_lockres);
23942393
if (err < 0)
23952394
mlog_errno(err);
23962395

23972396
status = err;
23982397

23992398
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
2400-
&OCFS2_I(inode)->ip_meta_lockres,
2401-
&meta_dcb);
2399+
&OCFS2_I(inode)->ip_meta_lockres);
24022400
if (err < 0)
24032401
mlog_errno(err);
24042402
if (err < 0 && !status)
24052403
status = err;
24062404

24072405
err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb),
2408-
&OCFS2_I(inode)->ip_rw_lockres,
2409-
NULL);
2406+
&OCFS2_I(inode)->ip_rw_lockres);
24102407
if (err < 0)
24112408
mlog_errno(err);
24122409
if (err < 0 && !status)

0 commit comments

Comments
 (0)