mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: ocfs2-devel@oss.oracle.com, Joel Becker <joel.becker@oracle.com>,
	Sunil Mushran <sunil.mushran@oracle.com>,
	Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 03/32] ocfs2: Expose the file system state via debugfs
Date: Tue, 17 Mar 2009 13:00:53 -0700	[thread overview]
Message-ID: <1237320082-12921-4-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1237320082-12921-1-git-send-email-mfasheh@suse.com>

From: Sunil Mushran <sunil.mushran@oracle.com>

This patch creates a per mount debugfs file, fs_state, which exposes
information like, cluster stack in use, states of the downconvert, recovery
and commit threads, number of journal txns, some allocation stats, list of
all slots, etc.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/ocfs2.h |    1 +
 fs/ocfs2/super.c |  176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 946d3c3..18d8542 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -308,6 +308,7 @@ struct ocfs2_super
 	struct ocfs2_dlm_debug *osb_dlm_debug;
 
 	struct dentry *osb_debug_root;
+	struct dentry *osb_ctxt;
 
 	wait_queue_head_t recovery_event;
 
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 7ac83a8..4eaf0e6 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -201,6 +201,170 @@ static const match_table_t tokens = {
 	{Opt_err, NULL}
 };
 
+#ifdef CONFIG_DEBUG_FS
+static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
+{
+	int out = 0;
+	int i;
+	struct ocfs2_cluster_connection *cconn = osb->cconn;
+	struct ocfs2_recovery_map *rm = osb->recovery_map;
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Id: %-s  Uuid: %-s  Gen: 0x%X  Label: %-s\n",
+			"Device", osb->dev_str, osb->uuid_str,
+			osb->fs_generation, osb->vol_label);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => State: %d  Flags: 0x%lX\n", "Volume",
+			atomic_read(&osb->vol_state), osb->osb_flags);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Block: %lu  Cluster: %d\n", "Sizes",
+			osb->sb->s_blocksize, osb->s_clustersize);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Compat: 0x%X  Incompat: 0x%X  "
+			"ROcompat: 0x%X\n",
+			"Features", osb->s_feature_compat,
+			osb->s_feature_incompat, osb->s_feature_ro_compat);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Opts: 0x%lX  AtimeQuanta: %u\n", "Mount",
+			osb->s_mount_opt, osb->s_atime_quantum);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Stack: %s  Name: %*s  Version: %d.%d\n",
+			"Cluster",
+			(*osb->osb_cluster_stack == '\0' ?
+			 "o2cb" : osb->osb_cluster_stack),
+			cconn->cc_namelen, cconn->cc_name,
+			cconn->cc_version.pv_major, cconn->cc_version.pv_minor);
+
+	spin_lock(&osb->dc_task_lock);
+	out += snprintf(buf + out, len - out,
+			"%10s => Pid: %d  Count: %lu  WakeSeq: %lu  "
+			"WorkSeq: %lu\n", "DownCnvt",
+			task_pid_nr(osb->dc_task), osb->blocked_lock_count,
+			osb->dc_wake_sequence, osb->dc_work_sequence);
+	spin_unlock(&osb->dc_task_lock);
+
+	spin_lock(&osb->osb_lock);
+	out += snprintf(buf + out, len - out, "%10s => Pid: %d  Nodes:",
+			"Recovery",
+			(osb->recovery_thread_task ?
+			 task_pid_nr(osb->recovery_thread_task) : -1));
+	if (rm->rm_used == 0)
+		out += snprintf(buf + out, len - out, " None\n");
+	else {
+		for (i = 0; i < rm->rm_used; i++)
+			out += snprintf(buf + out, len - out, " %d",
+					rm->rm_entries[i]);
+		out += snprintf(buf + out, len - out, "\n");
+	}
+	spin_unlock(&osb->osb_lock);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => Pid: %d  Interval: %lu  Needs: %d\n", "Commit",
+			task_pid_nr(osb->commit_task), osb->osb_commit_interval,
+			atomic_read(&osb->needs_checkpoint));
+
+	out += snprintf(buf + out, len - out,
+			"%10s => State: %d  NumTxns: %d  TxnId: %lu\n",
+			"Journal", osb->journal->j_state,
+			atomic_read(&osb->journal->j_num_trans),
+			osb->journal->j_trans_id);
+
+	out += snprintf(buf + out, len - out,
+			"%10s => GlobalAllocs: %d  LocalAllocs: %d  "
+			"SubAllocs: %d  LAWinMoves: %d  SAExtends: %d\n",
+			"Stats",
+			atomic_read(&osb->alloc_stats.bitmap_data),
+			atomic_read(&osb->alloc_stats.local_data),
+			atomic_read(&osb->alloc_stats.bg_allocs),
+			atomic_read(&osb->alloc_stats.moves),
+			atomic_read(&osb->alloc_stats.bg_extends));
+
+	out += snprintf(buf + out, len - out,
+			"%10s => State: %u  Descriptor: %llu  Size: %u bits  "
+			"Default: %u bits\n",
+			"LocalAlloc", osb->local_alloc_state,
+			(unsigned long long)osb->la_last_gd,
+			osb->local_alloc_bits, osb->local_alloc_default_bits);
+
+	spin_lock(&osb->osb_lock);
+	out += snprintf(buf + out, len - out,
+			"%10s => Slot: %d  NumStolen: %d\n", "Steal",
+			osb->s_inode_steal_slot,
+			atomic_read(&osb->s_num_inodes_stolen));
+	spin_unlock(&osb->osb_lock);
+
+	out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
+			"Slots", "Num", "RecoGen");
+
+	for (i = 0; i < osb->max_slots; ++i) {
+		out += snprintf(buf + out, len - out,
+				"%10s  %c %3d  %10d\n",
+				" ",
+				(i == osb->slot_num ? '*' : ' '),
+				i, osb->slot_recovery_generations[i]);
+	}
+
+	return out;
+}
+
+static int ocfs2_osb_debug_open(struct inode *inode, struct file *file)
+{
+	struct ocfs2_super *osb = inode->i_private;
+	char *buf = NULL;
+
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!buf)
+		goto bail;
+
+	i_size_write(inode, ocfs2_osb_dump(osb, buf, PAGE_SIZE));
+
+	file->private_data = buf;
+
+	return 0;
+bail:
+	return -ENOMEM;
+}
+
+static int ocfs2_debug_release(struct inode *inode, struct file *file)
+{
+	kfree(file->private_data);
+	return 0;
+}
+
+static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
+				size_t nbytes, loff_t *ppos)
+{
+	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
+				       i_size_read(file->f_mapping->host));
+}
+#else
+static int ocfs2_osb_debug_open(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+static int ocfs2_debug_release(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
+				size_t nbytes, loff_t *ppos)
+{
+	return 0;
+}
+#endif	/* CONFIG_DEBUG_FS */
+
+static struct file_operations ocfs2_osb_debug_fops = {
+	.open =		ocfs2_osb_debug_open,
+	.release =	ocfs2_debug_release,
+	.read =		ocfs2_debug_read,
+	.llseek =	generic_file_llseek,
+};
+
 /*
  * write_super and sync_fs ripped right out of ext3.
  */
@@ -926,6 +1090,16 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 		goto read_super_error;
 	}
 
+	osb->osb_ctxt = debugfs_create_file("fs_state", S_IFREG|S_IRUSR,
+					    osb->osb_debug_root,
+					    osb,
+					    &ocfs2_osb_debug_fops);
+	if (!osb->osb_ctxt) {
+		status = -EINVAL;
+		mlog_errno(status);
+		goto read_super_error;
+	}
+
 	status = ocfs2_mount_volume(sb);
 	if (osb->root_inode)
 		inode = igrab(osb->root_inode);
@@ -1620,6 +1794,8 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
 	osb = OCFS2_SB(sb);
 	BUG_ON(!osb);
 
+	debugfs_remove(osb->osb_ctxt);
+
 	ocfs2_disable_quotas(osb);
 
 	ocfs2_shutdown_local_alloc(osb);
-- 
1.5.6


  parent reply	other threads:[~2009-03-17 20:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-17 20:00 [git patches] Ocfs2 updates for 2.6.30 Mark Fasheh
2009-03-17 20:00 ` [PATCH 01/32] ocfs2/hb: Expose the list of heartbeating nodes via debugfs Mark Fasheh
2009-03-17 20:00 ` [PATCH 02/32] ocfs2: Move struct recovery_map to a header file Mark Fasheh
2009-03-17 20:00 ` Mark Fasheh [this message]
2009-03-17 20:00 ` [PATCH 04/32] ocfs2: Remove debugfs file local_alloc_stats Mark Fasheh
2009-03-17 20:00 ` [PATCH 05/32] ocfs2: Introduce dir lookup helper struct Mark Fasheh
2009-03-17 20:00 ` [PATCH 06/32] ocfs2: Add a name indexed b-tree to directory inodes Mark Fasheh
2009-03-17 20:00 ` [PATCH 07/32] ocfs2: Store dir index records inline Mark Fasheh
2009-03-17 20:00 ` [PATCH 08/32] ocfs2: Introduce dir free space list Mark Fasheh
2009-03-17 20:00 ` [PATCH 09/32] ocfs2: Increase max links count Mark Fasheh
2009-03-17 20:01 ` [PATCH 10/32] ocfs2: Add total entry count to dx_root_block Mark Fasheh
2009-03-17 20:01 ` [PATCH 11/32] ocfs2: Enable indexed directories Mark Fasheh
2009-03-17 20:01 ` [PATCH 12/32] ocfs2: re-order ocfs2_empty_dir checks Mark Fasheh
2009-03-17 20:01 ` [PATCH 13/32] ocfs2: fix leaf start calculation in ocfs2_dx_dir_rebalance() Mark Fasheh
2009-03-17 20:01 ` [PATCH 14/32] ocfs2: Optimize inode allocation by remembering last group Mark Fasheh
2009-03-17 20:01 ` [PATCH 15/32] ocfs2: Allocate inode groups from global_bitmap Mark Fasheh
2009-03-17 20:01 ` [PATCH 16/32] ocfs2: Optimize inode group allocation by recording last used group Mark Fasheh
2009-03-17 20:01 ` [PATCH 17/32] ocfs2/dlm: Encapsulate adding and removing of mle from dlm->master_list Mark Fasheh
2009-03-17 20:01 ` [PATCH 18/32] ocfs2/dlm: Clean up struct dlm_lock_name Mark Fasheh
2009-03-17 20:01 ` [PATCH 19/32] ocfs2/dlm: Refactor dlm_clean_master_list() Mark Fasheh
2009-03-17 20:01 ` [PATCH 20/32] ocfs2/dlm: Create and destroy the dlm->master_hash Mark Fasheh
2009-03-17 20:01 ` [PATCH 21/32] ocfs2/dlm: Activate dlm->master_hash for master list entries Mark Fasheh
2009-03-17 20:01 ` [PATCH 22/32] ocfs2/dlm: Indent dlm_cleanup_master_list() Mark Fasheh
2009-03-17 20:01 ` [PATCH 23/32] ocfs2/dlm: Track number of mles Mark Fasheh
2009-03-17 20:01 ` [PATCH 24/32] ocfs2/dlm: Improve lockres counts Mark Fasheh
2009-03-17 20:01 ` [PATCH 25/32] ocfs2/dlm: dlm_set_lockres_owner() and dlm_change_lockres_owner() inlined Mark Fasheh
2009-03-17 20:01 ` [PATCH 26/32] ocfs2/dlm: Show the number of lockres/mles in dlm_state Mark Fasheh
2009-03-17 20:01 ` [PATCH 27/32] ocfs2/dlm: Remove struct dlm_lock_name in struct dlm_master_list_entry Mark Fasheh
2009-03-17 20:01 ` [PATCH 28/32] ocfs2/dlm: Do not purge lockres that is being migrated dlm_purge_lockres() Mark Fasheh
2009-03-17 20:01 ` [PATCH 29/32] ocfs2/dlm: Tweak mle_state output Mark Fasheh
2009-03-17 20:01 ` [PATCH 30/32] ocfs2: fix rare stale inode errors when exporting via nfs Mark Fasheh
2009-03-17 20:01 ` [PATCH 31/32] ocfs2: Pagecache usage optimization on ocfs2 Mark Fasheh
2009-03-17 20:01 ` [PATCH 32/32] ocfs2: recover orphans in offline slots during recovery and mount Mark Fasheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1237320082-12921-4-git-send-email-mfasheh@suse.com \
    --to=mfasheh@suse.com \
    --cc=joel.becker@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=sunil.mushran@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®