fs/ocfs2/dlm/dlmdebug.c

Source file repositories/reference/linux-study-clean/fs/ocfs2/dlm/dlmdebug.c

File Facts

System
Linux kernel
Corpus path
fs/ocfs2/dlm/dlmdebug.c
Extension
.c
Size
22926 bytes
Lines
845
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations debug_purgelist_fops = {
	.open =		debug_purgelist_open,
	.release =	debug_release,
	.read =		debug_read,
	.llseek =	generic_file_llseek,
};
/* end - purge list funcs */

/* begin - debug mle funcs */
static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len)
{
	struct dlm_master_list_entry *mle;
	struct hlist_head *bucket;
	int i, out = 0;
	unsigned long total = 0, longest = 0, bucket_count = 0;

	out += scnprintf(buf + out, len - out,
			"Dumping MLEs for Domain: %s\n", dlm->name);

	spin_lock(&dlm->master_lock);
	for (i = 0; i < DLM_HASH_BUCKETS; i++) {
		bucket = dlm_master_hash(dlm, i);
		hlist_for_each_entry(mle, bucket, master_hash_node) {
			++total;
			++bucket_count;
			if (len - out < 200)
				continue;
			out += dump_mle(mle, buf + out, len - out);
		}
		longest = max(longest, bucket_count);
		bucket_count = 0;
	}
	spin_unlock(&dlm->master_lock);

	out += scnprintf(buf + out, len - out,
			"Total: %lu, Longest: %lu\n", total, longest);
	return out;
}

static int debug_mle_open(struct inode *inode, struct file *file)
{
	struct dlm_ctxt *dlm = inode->i_private;
	char *buf = NULL;

	buf = kzalloc(PAGE_SIZE, GFP_NOFS);
	if (!buf)
		return -ENOMEM;

	i_size_write(inode, debug_mle_print(dlm, buf, PAGE_SIZE - 1));

	file->private_data = buf;

	return 0;
}

static const struct file_operations debug_mle_fops = {
	.open =		debug_mle_open,
	.release =	debug_release,
	.read =		debug_read,
	.llseek =	generic_file_llseek,
};

/* end - debug mle funcs */

/* begin - debug lockres funcs */
static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len)
{
	int out;

#define DEBUG_LOCK_VERSION	1
	spin_lock(&lock->spinlock);
	out = scnprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d,"
		       "%d,%d,%d,%d\n",
		       DEBUG_LOCK_VERSION,
		       list_type, lock->ml.type, lock->ml.convert_type,
		       lock->ml.node,
		       dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
		       dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
		       !list_empty(&lock->ast_list),
		       !list_empty(&lock->bast_list),
		       lock->ast_pending, lock->bast_pending,
		       lock->convert_pending, lock->lock_pending,
		       lock->cancel_pending, lock->unlock_pending,
		       kref_read(&lock->lock_refs));
	spin_unlock(&lock->spinlock);

	return out;
}

static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len)

Annotation

Implementation Notes