mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-05 23:56:58 +00:00
scoutfs: provide a debug print method to dlmglue
This allows us to decode our binary locknames into a string buffer which dlmglue can then print. Signed-off-by: Mark Fasheh <mfasheh@versity.com>
This commit is contained in:
+12
-9
@@ -92,6 +92,15 @@ static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *l
|
||||
return (struct ocfs2_super *)lockres->l_priv;
|
||||
}
|
||||
|
||||
static inline void lockres_name(struct ocfs2_lock_res *lockres, char *buf,
|
||||
unsigned int len)
|
||||
{
|
||||
if (lockres->l_ops->print)
|
||||
lockres->l_ops->print(lockres, buf, len);
|
||||
else
|
||||
snprintf(buf, len, "%s", lockres->l_name);
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -1687,20 +1696,14 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
|
||||
int i;
|
||||
char *lvb;
|
||||
struct ocfs2_lock_res *lockres = v;
|
||||
char lockname[256];
|
||||
|
||||
if (!lockres)
|
||||
return -EINVAL;
|
||||
|
||||
seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION);
|
||||
lockres_name(lockres, lockname, 256);
|
||||
|
||||
#if 0
|
||||
if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY)
|
||||
seq_printf(m, "%.*s%08x\t", OCFS2_DENTRY_LOCK_INO_START - 1,
|
||||
lockres->l_name,
|
||||
(unsigned int)ocfs2_get_dentry_lock_ino(lockres));
|
||||
else
|
||||
#endif
|
||||
seq_printf(m, "%.*s\t", OCFS2_LOCK_ID_MAX_LEN, lockres->l_name);
|
||||
seq_printf(m, "0x%x\t%s\t", OCFS2_DLM_DEBUG_STR_VERSION, lockname);
|
||||
|
||||
seq_printf(m, "%d\t"
|
||||
"0x%lx\t"
|
||||
|
||||
@@ -256,6 +256,11 @@ struct ocfs2_lock_res_ops {
|
||||
*/
|
||||
int (*downconvert_worker)(struct ocfs2_lock_res *, int);
|
||||
|
||||
/*
|
||||
* Optional: pretty print the lockname into a buffer
|
||||
*/
|
||||
void (*print)(struct ocfs2_lock_res *, char *, unsigned int);
|
||||
|
||||
/*
|
||||
* LOCK_TYPE_* flags which describe the specific requirements
|
||||
* of a lock type. Descriptions of each individual flag follow.
|
||||
|
||||
@@ -170,10 +170,19 @@ static int ino_lock_downconvert(struct ocfs2_lock_res *lockres, int blocking)
|
||||
return UNBLOCK_CONTINUE;
|
||||
}
|
||||
|
||||
static void lock_name_string(struct ocfs2_lock_res *lockres, char *buf,
|
||||
unsigned int len)
|
||||
{
|
||||
struct scoutfs_lock *lock = lockres->l_priv;
|
||||
|
||||
snprintf(buf, len, LN_FMT, LN_ARG(&lock->lock_name));
|
||||
}
|
||||
|
||||
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,
|
||||
.flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_RECURSIVE,
|
||||
};
|
||||
|
||||
@@ -181,12 +190,14 @@ static struct ocfs2_lock_res_ops scoufs_ino_index_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,
|
||||
.flags = LOCK_TYPE_RECURSIVE,
|
||||
};
|
||||
|
||||
static struct ocfs2_lock_res_ops scoutfs_global_lops = {
|
||||
.get_osb = get_ino_lock_osb,
|
||||
/* XXX: .check_downconvert that queries the item cache for dirty items */
|
||||
.print = lock_name_string,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
@@ -194,6 +205,7 @@ static struct ocfs2_lock_res_ops scoutfs_node_id_lops = {
|
||||
.get_osb = get_ino_lock_osb,
|
||||
/* XXX: .check_downconvert that queries the item cache for dirty items */
|
||||
.downconvert_worker = ino_lock_downconvert,
|
||||
.print = lock_name_string,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user