public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [RFC PATCH 2/2] xfs: sysfs attributes for the current log state
Date: Fri, 16 May 2014 14:12:46 -0400	[thread overview]
Message-ID: <1400263966-35541-3-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1400263966-35541-1-git-send-email-bfoster@redhat.com>

Create sysfs attributes to export the current runtime state of the log
to userspace. Note that the filesystem should be frozen for best
accuracy/consistency when reading these values, but is not required.
This is for testing and debug purposes only.

Create the following per-mount attributes: log_head_lsn, log_tail_lsn,
reserve_head_lsn and write_head_lsn. These represent the physical log
head, tail and reserve and write grant heads respectively. All values
are exported as raw log sequence numbers (LSN). Note that the grant
heads are in units of bytes while other LSNs are in units of basic
blocks.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_mount.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 9ed9dd0..d0d0617 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -42,6 +42,7 @@
 #include "xfs_trace.h"
 #include "xfs_icache.h"
 #include "xfs_dinode.h"
+#include "xfs_log_priv.h"
 
 
 #ifdef HAVE_PERCPU_SB
@@ -2037,7 +2038,60 @@ struct xfs_sysfs_attr {
 
 #define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr
 
+/* sysfs attributes */
+
+STATIC ssize_t
+log_head_lsn_show(
+	struct xfs_mount	*mp,
+	char			*buf)
+{
+	struct xlog *log = mp->m_log;
+	int ret;
+
+	spin_lock(&log->l_icloglock);
+	ret = snprintf(buf, PAGE_SIZE, "0x%llx\n",
+		xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block));
+	spin_unlock(&log->l_icloglock);
+
+	return ret;
+}
+XFS_SYSFS_ATTR_RO(log_head_lsn);
+
+STATIC ssize_t
+log_tail_lsn_show(
+	struct xfs_mount	*mp,
+	char			*buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+		atomic64_read(&mp->m_log->l_tail_lsn));
+}
+XFS_SYSFS_ATTR_RO(log_tail_lsn);
+
+STATIC ssize_t
+reserve_head_lsn_show(
+	struct xfs_mount	*mp,
+	char			*buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+		atomic64_read(&mp->m_log->l_reserve_head.grant));
+}
+XFS_SYSFS_ATTR_RO(reserve_head_lsn);
+
+STATIC ssize_t
+write_head_lsn_show(
+	struct xfs_mount	*mp,
+	char			*buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+		atomic64_read(&mp->m_log->l_write_head.grant));
+}
+XFS_SYSFS_ATTR_RO(write_head_lsn);
+
 static struct attribute *xfs_sysfs_attrs[] = {
+	ATTR_LIST(log_head_lsn),
+	ATTR_LIST(log_tail_lsn),
+	ATTR_LIST(reserve_head_lsn),
+	ATTR_LIST(write_head_lsn),
 	NULL,
 };
 
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2014-05-16 18:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 18:12 [RFC PATCH 0/2] xfs: sysfs attribute support Brian Foster
2014-05-16 18:12 ` [RFC PATCH 1/2] xfs: add basic per-mount " Brian Foster
2014-05-20 12:16   ` Dave Chinner
2014-05-16 18:12 ` Brian Foster [this message]
2014-05-19 21:56   ` [RFC PATCH 2/2] xfs: sysfs attributes for the current log state Dave Chinner
2014-05-20 11:17     ` Brian Foster
2014-05-20 11:52       ` Dave Chinner
2014-05-21 14:48 ` [RFC PATCH 0/2] xfs: sysfs attribute support Christoph Hellwig
2014-05-22 13:16   ` Brian Foster

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=1400263966-35541-3-git-send-email-bfoster@redhat.com \
    --to=bfoster@redhat.com \
    --cc=xfs@oss.sgi.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