mirror of
https://github.com/versity/scoutfs.git
synced 2026-04-21 22:10:30 +00:00
scoutfs: count some lock events by type
We use a new event callback in dlmglue so that scout has a chance to do some per-lock type counters. I included the most important dlmglue events - basically those which can cost us network or disk traffic. Right now scout just counts downconvert events since those are the most interesting to us. We also just count on the ino and index locks for now. Signed-off-by: Mark Fasheh <mfasheh@versity.com>
This commit is contained in:
@@ -60,6 +60,8 @@
|
||||
EXPAND_COUNTER(lock_busy_wait) \
|
||||
EXPAND_COUNTER(lock_free) \
|
||||
EXPAND_COUNTER(lock_incompat_wait) \
|
||||
EXPAND_COUNTER(lock_type_ino_downconvert) \
|
||||
EXPAND_COUNTER(lock_type_idx_downconvert) \
|
||||
EXPAND_COUNTER(manifest_compact_migrate) \
|
||||
EXPAND_COUNTER(manifest_hard_stale_error) \
|
||||
EXPAND_COUNTER(seg_alloc) \
|
||||
|
||||
@@ -104,6 +104,13 @@ static inline void lockres_name(struct ocfs2_lock_res *lockres, char *buf,
|
||||
snprintf(buf, len, "%s", lockres->l_name);
|
||||
}
|
||||
|
||||
static inline void lockres_notify_event(struct ocfs2_lock_res *lockres,
|
||||
enum ocfs2_lock_events event)
|
||||
{
|
||||
if (lockres->l_ops->notify_event)
|
||||
lockres->l_ops->notify_event(lockres, event);
|
||||
}
|
||||
|
||||
static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres,
|
||||
int wanted);
|
||||
static void __ocfs2_cluster_unlock(struct ocfs2_super *osb,
|
||||
@@ -1220,10 +1227,13 @@ again:
|
||||
gen = lockres_set_pending(lockres);
|
||||
spin_unlock_irqrestore(&lockres->l_lock, flags);
|
||||
|
||||
if (lkm_flags & DLM_LKF_CONVERT)
|
||||
if (lkm_flags & DLM_LKF_CONVERT) {
|
||||
scoutfs_inc_counter(osb->sb, dlm_convert_request);
|
||||
else
|
||||
lockres_notify_event(lockres, EVENT_DLM_CONVERT);
|
||||
} else {
|
||||
scoutfs_inc_counter(osb->sb, dlm_lock_request);
|
||||
lockres_notify_event(lockres, EVENT_DLM_LOCK);
|
||||
}
|
||||
|
||||
BUG_ON(level == DLM_LOCK_IV);
|
||||
BUG_ON(level == DLM_LOCK_NL);
|
||||
@@ -2161,6 +2171,7 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
|
||||
lockres->l_name);
|
||||
|
||||
scoutfs_inc_counter(osb->sb, dlm_unlock_request);
|
||||
lockres_notify_event(lockres, EVENT_DLM_UNLOCK);
|
||||
|
||||
ocfs2_wait_on_busy_lock(lockres);
|
||||
out:
|
||||
@@ -2366,6 +2377,7 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb,
|
||||
mlog(ML_BASTS, "lockres %s\n", lockres->l_name);
|
||||
|
||||
scoutfs_inc_counter(osb->sb, dlm_cancel_convert);
|
||||
lockres_notify_event(lockres, EVENT_DLM_CONVERT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -2532,6 +2544,8 @@ recheck:
|
||||
|
||||
spin_unlock_irqrestore(&lockres->l_lock, flags);
|
||||
|
||||
lockres_notify_event(lockres, EVENT_DLM_DOWNCONVERT_WORK);
|
||||
|
||||
ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking);
|
||||
|
||||
if (ctl->unblock_action == UNBLOCK_STOP_POST) {
|
||||
|
||||
@@ -199,6 +199,14 @@ enum ocfs2_unblock_action {
|
||||
* ->post_unlock() callback. */
|
||||
};
|
||||
|
||||
enum ocfs2_lock_events {
|
||||
EVENT_DLM_LOCK = 0,
|
||||
EVENT_DLM_UNLOCK,
|
||||
EVENT_DLM_CONVERT,
|
||||
EVENT_DLM_CANCEL_CONVERT,
|
||||
EVENT_DLM_DOWNCONVERT_WORK,
|
||||
};
|
||||
|
||||
/*
|
||||
* OCFS2 Lock Resource Operations
|
||||
*
|
||||
@@ -269,6 +277,12 @@ struct ocfs2_lock_res_ops {
|
||||
*/
|
||||
void (*print)(struct ocfs2_lock_res *, char *, unsigned int);
|
||||
|
||||
/*
|
||||
* Optional: Lightweight event callback, intended for quick
|
||||
* operations like collecting stats, etc.
|
||||
*/
|
||||
void (*notify_event)(struct ocfs2_lock_res *, enum ocfs2_lock_events);
|
||||
|
||||
/*
|
||||
* LOCK_TYPE_* flags which describe the specific requirements
|
||||
* of a lock type. Descriptions of each individual flag follow.
|
||||
|
||||
@@ -332,17 +332,45 @@ static void lock_name_string(struct ocfs2_lock_res *lockres, char *buf,
|
||||
snprintf(buf, len, LN_FMT, LN_ARG(&lock->lock_name));
|
||||
}
|
||||
|
||||
static void count_ino_lock_event(struct ocfs2_lock_res *lockres,
|
||||
enum ocfs2_lock_events event)
|
||||
{
|
||||
struct scoutfs_lock *lock = container_of(lockres, struct scoutfs_lock,
|
||||
lockres);
|
||||
struct super_block *sb = lock->sb;
|
||||
|
||||
if (event == EVENT_DLM_DOWNCONVERT_WORK)
|
||||
scoutfs_inc_counter(sb, lock_type_ino_downconvert);
|
||||
}
|
||||
|
||||
static void count_idx_lock_event(struct ocfs2_lock_res *lockres,
|
||||
enum ocfs2_lock_events event)
|
||||
{
|
||||
struct scoutfs_lock *lock = container_of(lockres, struct scoutfs_lock,
|
||||
lockres);
|
||||
struct super_block *sb = lock->sb;
|
||||
|
||||
/*
|
||||
* Treat all indicies together. Later we can decode the
|
||||
* lockres name to get at specific indicies.
|
||||
*/
|
||||
if (event == EVENT_DLM_DOWNCONVERT_WORK)
|
||||
scoutfs_inc_counter(sb, lock_type_idx_downconvert);
|
||||
}
|
||||
|
||||
static struct ocfs2_lock_res_ops scoufs_ino_lops = {
|
||||
.get_osb = get_ino_lock_osb,
|
||||
.downconvert_worker = ino_lock_downconvert,
|
||||
/* XXX: .check_downconvert that queries the item cache for dirty items */
|
||||
.print = lock_name_string,
|
||||
.notify_event = count_ino_lock_event,
|
||||
.flags = LOCK_TYPE_REQUIRES_REFRESH,
|
||||
};
|
||||
|
||||
static struct ocfs2_lock_res_ops scoufs_ino_index_lops = {
|
||||
.get_osb = get_ino_lock_osb,
|
||||
.downconvert_worker = ino_lock_downconvert,
|
||||
.notify_event = count_idx_lock_event,
|
||||
/* XXX: .check_downconvert that queries the item cache for dirty items */
|
||||
.print = lock_name_string,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user