All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] xfs sysfs support
@ 2014-06-27 12:06 Brian Foster
  2014-06-27 12:06 ` [PATCH v2 1/6] xfs: fix a couple error sequence jumps in xfs_mountfs() Brian Foster
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:06 UTC (permalink / raw)
  To: xfs

Hi all,

Here's v2 of sysfs support for XFS. The previous version is available
here:

	http://oss.sgi.com/archives/xfs/2014-06/msg00141.html

This version is rebased onto the latest for-next and further cleans up
the code to use some abstractions for sysfs object maintenance and
associated helpers. As noted in the v1 thread, I think the current doc
patch already indicates that the sysfs attrs are not considered stable.
Unless there is further feedback on that front, I'll leave that patch as
is.

Brian

v2:
- Rebased to latest for-next (error negation, libxfs).
- Introduce xfs_kobj container for kobject and completion.
- Genericize kobject release function.
- Move snprintf() outside of iclog lock in log_head_lsn_show(). Clean up
  xlog handlers.
v1:
- Move sysfs infrastructure code to new source file, add helpers for
  object initialization, etc.
- Created an xfs_mount->xlog object heirarchy for attributes associated
  with the log.
- Renamed the reserve/write grant head attributes to
  '[reserve,write]_grant_head.'
- Use the 'cycle:block' or 'cycle:bytes' decimal format for attributes
  (rather than export encoded values).
- Included generic mountfs fix and doc.

Brian Foster (6):
  xfs: fix a couple error sequence jumps in xfs_mountfs()
  xfs: add a sysfs kset
  xfs: add xfs_mount sysfs kobject
  xfs: add xlog sysfs kobject and attribute handlers
  xfs: add log attributes for log lsn and grant head data
  xfs: document log sysfs attributes in testing ABI

 Documentation/ABI/testing/sysfs-fs-xfs |  39 ++++++++
 fs/xfs/Makefile                        |   1 +
 fs/xfs/xfs_linux.h                     |  11 +++
 fs/xfs/xfs_log.c                       |   9 ++
 fs/xfs/xfs_log_priv.h                  |   2 +
 fs/xfs/xfs_mount.c                     |  18 +++-
 fs/xfs/xfs_mount.h                     |   1 +
 fs/xfs/xfs_super.c                     |  12 ++-
 fs/xfs/xfs_sysfs.c                     | 165 +++++++++++++++++++++++++++++++++
 fs/xfs/xfs_sysfs.h                     |  59 ++++++++++++
 10 files changed, 313 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-fs-xfs
 create mode 100644 fs/xfs/xfs_sysfs.c
 create mode 100644 fs/xfs/xfs_sysfs.h

-- 
1.8.3.1

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/6] xfs: fix a couple error sequence jumps in xfs_mountfs()
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
@ 2014-06-27 12:06 ` Brian Foster
  2014-06-27 12:06 ` [PATCH v2 2/6] xfs: add a sysfs kset Brian Foster
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:06 UTC (permalink / raw)
  To: xfs

xfs_mountfs() has a couple failure conditions that do not jump to the
correct labels. Specifically:

- xfs_initialize_perag_data() failure does not deallocate the log even
  though it occurs after log initialization
- xfs_mount_reset_sbqflags() failure returns the error directly rather
  than jump to the error sequence

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_mount.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index d5c44a6..4e9dd4a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -855,7 +855,7 @@ xfs_mountfs(
 	     !mp->m_sb.sb_inprogress) {
 		error = xfs_initialize_perag_data(mp, sbp->sb_agcount);
 		if (error)
-			goto out_fail_wait;
+			goto out_log_dealloc;;
 	}
 
 	/*
@@ -927,7 +927,7 @@ xfs_mountfs(
 			xfs_notice(mp, "resetting quota flags");
 			error = xfs_mount_reset_sbqflags(mp);
 			if (error)
-				return error;
+				goto out_rtunmount;
 		}
 	}
 
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/6] xfs: add a sysfs kset
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
  2014-06-27 12:06 ` [PATCH v2 1/6] xfs: fix a couple error sequence jumps in xfs_mountfs() Brian Foster
@ 2014-06-27 12:06 ` Brian Foster
  2014-06-27 12:06 ` [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject Brian Foster
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:06 UTC (permalink / raw)
  To: xfs

Create a sysfs kset to contain all sub-objects associated with the XFS
module. The kset is created and removed on module initialization and
removal respectively. The kset uses fs_obj as a parent. This leads to
the creation of a /sys/fs/xfs directory when the kset exists.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_super.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f2e5f8a..986c557 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -61,6 +61,7 @@
 static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
+struct kset *xfs_kset;
 
 #define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
 #define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
@@ -1761,9 +1762,15 @@ init_xfs_fs(void)
 	if (error)
 		goto out_cleanup_procfs;
 
+	xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
+	if (!xfs_kset) {
+		error = -ENOMEM;
+		goto out_sysctl_unregister;;
+	}
+
 	error = xfs_qm_init();
 	if (error)
-		goto out_sysctl_unregister;
+		goto out_kset_unregister;
 
 	error = register_filesystem(&xfs_fs_type);
 	if (error)
@@ -1772,6 +1779,8 @@ init_xfs_fs(void)
 
  out_qm_exit:
 	xfs_qm_exit();
+ out_kset_unregister:
+	kset_unregister(xfs_kset);
  out_sysctl_unregister:
 	xfs_sysctl_unregister();
  out_cleanup_procfs:
@@ -1793,6 +1802,7 @@ exit_xfs_fs(void)
 {
 	xfs_qm_exit();
 	unregister_filesystem(&xfs_fs_type);
+	kset_unregister(xfs_kset);
 	xfs_sysctl_unregister();
 	xfs_cleanup_procfs();
 	xfs_buf_terminate();
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
  2014-06-27 12:06 ` [PATCH v2 1/6] xfs: fix a couple error sequence jumps in xfs_mountfs() Brian Foster
  2014-06-27 12:06 ` [PATCH v2 2/6] xfs: add a sysfs kset Brian Foster
@ 2014-06-27 12:06 ` Brian Foster
  2014-06-28  0:56   ` Dave Chinner
  2014-06-27 12:06 ` [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers Brian Foster
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:06 UTC (permalink / raw)
  To: xfs

Embed a base kobject into xfs_mount. This creates a kobject associated
with each XFS mount and a subdirectory in sysfs with the name of the
filesystem. The subdirectory lifecycle matches that of the mount. Also
add the new xfs_sysfs.[c,h] source files with some XFS sysfs
infrastructure to facilitate attribute creation.

Note that there are currently no attributes exported as part of the
xfs_mount kobject. It exists solely to serve as a per-mount container
for child objects.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/Makefile    |  1 +
 fs/xfs/xfs_linux.h | 11 +++++++++++
 fs/xfs/xfs_mount.c | 14 ++++++++++++-
 fs/xfs/xfs_mount.h |  1 +
 fs/xfs/xfs_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_sysfs.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 fs/xfs/xfs_sysfs.c
 create mode 100644 fs/xfs/xfs_sysfs.h

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 0dfa26d..d617999 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -86,6 +86,7 @@ xfs-y				+= xfs_aops.o \
 				   xfs_mru_cache.o \
 				   xfs_super.o \
 				   xfs_symlink.o \
+				   xfs_sysfs.o \
 				   xfs_trans.o \
 				   xfs_xattr.o \
 				   kmem.o \
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index f59b966..8312771 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -191,6 +191,17 @@ typedef __uint64_t __psunsigned_t;
 #define MAX(a,b)	(max(a,b))
 #define howmany(x, y)	(((x)+((y)-1))/(y))
 
+/*
+ * XFS wrapper structure for sysfs support. It depends on external data
+ * structures and is embedded in various internal data structures to implement
+ * the XFS sysfs object heirarchy. Define it here for broad access throughout
+ * the codebase.
+ */
+struct xfs_kobj {
+	struct kobject		kobject;
+	struct completion	complete;
+};
+
 /* Kernel uid/gid conversion. These are used to convert to/from the on disk
  * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally.
  * The conversion here is type only, the value will remain the same since we
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 4e9dd4a..c8a328e 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_sysfs.h"
 
 
 #ifdef HAVE_PERCPU_SB
@@ -60,6 +61,8 @@ static DEFINE_MUTEX(xfs_uuid_table_mutex);
 static int xfs_uuid_table_size;
 static uuid_t *xfs_uuid_table;
 
+extern struct kset *xfs_kset;
+
 /*
  * See if the UUID is unique among mounted XFS filesystems.
  * Mount fails if UUID is nil or a FS with the same UUID is already mounted.
@@ -731,10 +734,15 @@ xfs_mountfs(
 
 	xfs_set_maxicount(mp);
 
-	error = xfs_uuid_mount(mp);
+	mp->m_kobj.kobject.kset = xfs_kset;
+	error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
 	if (error)
 		goto out;
 
+	error = xfs_uuid_mount(mp);
+	if (error)
+		goto out_remove_sysfs;
+
 	/*
 	 * Set the minimum read and write sizes
 	 */
@@ -989,6 +997,8 @@ xfs_mountfs(
 	xfs_da_unmount(mp);
  out_remove_uuid:
 	xfs_uuid_unmount(mp);
+ out_remove_sysfs:
+	xfs_sysfs_del(&mp->m_kobj);
  out:
 	return error;
 }
@@ -1071,6 +1081,8 @@ xfs_unmountfs(
 	xfs_errortag_clearall(mp, 0);
 #endif
 	xfs_free_perag(mp);
+
+	xfs_sysfs_del(&mp->m_kobj);
 }
 
 int
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 7295a0b..b0447c8 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -166,6 +166,7 @@ typedef struct xfs_mount {
 						   on the next remount,rw */
 	int64_t			m_low_space[XFS_LOWSP_MAX];
 						/* low free space thresholds */
+	struct xfs_kobj		m_kobj;
 
 	struct workqueue_struct	*m_data_workqueue;
 	struct workqueue_struct	*m_unwritten_workqueue;
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
new file mode 100644
index 0000000..ae9aa7a
--- /dev/null
+++ b/fs/xfs/xfs_sysfs.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "xfs.h"
+#include "xfs_sysfs.h"
+
+struct xfs_sysfs_attr {
+	struct attribute attr;
+	ssize_t (*show)(char *buf, void *data);
+	ssize_t (*store)(const char *buf, size_t count, void *data);
+};
+
+static inline struct xfs_sysfs_attr *
+to_attr(struct attribute *attr)
+{
+	return container_of(attr, struct xfs_sysfs_attr, attr);
+}
+
+#define XFS_SYSFS_ATTR_RW(name) \
+	static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RW(name)
+#define XFS_SYSFS_ATTR_RO(name) \
+	static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RO(name)
+
+#define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr
+
+/*
+ * xfs_mount kobject. This currently has no attributes and thus no need for show
+ * and store helpers. The mp kobject serves as the per-mount parent object that
+ * is identified by the fsname under sysfs.
+ */
+
+struct kobj_type xfs_mp_ktype = {
+	.release = xfs_sysfs_release,
+};
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h
new file mode 100644
index 0000000..438976b
--- /dev/null
+++ b/fs/xfs/xfs_sysfs.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __XFS_SYSFS_H__
+#define __XFS_SYSFS_H__
+
+extern struct kobj_type xfs_mp_ktype;	/* xfs_mount */
+
+static inline struct xfs_kobj *
+to_kobj(struct kobject *kobject)
+{
+	return container_of(kobject, struct xfs_kobj, kobject);
+}
+
+static inline void
+xfs_sysfs_release(struct kobject *kobject)
+{
+	struct xfs_kobj *kobj = to_kobj(kobject);
+	complete(&kobj->complete);
+}
+
+static inline int
+xfs_sysfs_init(
+	struct xfs_kobj		*kobj,
+	struct kobj_type	*ktype,
+	struct xfs_kobj		*p_kobj,
+	const char		*name)
+{
+	init_completion(&kobj->complete);
+	return kobject_init_and_add(&kobj->kobject, ktype, &p_kobj->kobject,
+				    "%s", name);
+}
+
+static inline void
+xfs_sysfs_del(
+	struct xfs_kobj	*kobj)
+{
+	kobject_del(&kobj->kobject);
+	kobject_put(&kobj->kobject);
+	wait_for_completion(&kobj->complete);
+}
+
+#endif	/* __XFS_SYSFS_H__ */
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
                   ` (2 preceding siblings ...)
  2014-06-27 12:06 ` [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject Brian Foster
@ 2014-06-27 12:06 ` Brian Foster
  2014-07-10 23:33   ` Dave Chinner
  2014-06-27 12:07 ` [PATCH v2 5/6] xfs: add log attributes for log lsn and grant head data Brian Foster
  2014-06-27 12:07 ` [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI Brian Foster
  5 siblings, 1 reply; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:06 UTC (permalink / raw)
  To: xfs

Embed a kobject into the xfs log data structure (xlog). This creates a
'log' subdirectory for every XFS mount instance in sysfs. The lifecycle
of the log kobject is tied to the lifecycle of the log.

Also define a set of generic attribute handlers associated with the log
kobject in preparation for the addition of attributes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_log.c      |  9 +++++++++
 fs/xfs/xfs_log_priv.h |  2 ++
 fs/xfs/xfs_sysfs.c    | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_sysfs.h    |  1 +
 4 files changed, 64 insertions(+)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 7647818..149a4a5 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -34,6 +34,7 @@
 #include "xfs_trace.h"
 #include "xfs_fsops.h"
 #include "xfs_cksum.h"
+#include "xfs_sysfs.h"
 
 kmem_zone_t	*xfs_log_ticket_zone;
 
@@ -707,6 +708,11 @@ xfs_log_mount(
 		}
 	}
 
+	error = xfs_sysfs_init(&mp->m_log->l_kobj, &xfs_log_ktype, &mp->m_kobj,
+			       "log");
+	if (error)
+		goto out_destroy_ail;
+
 	/* Normal transactions can now occur */
 	mp->m_log->l_flags &= ~XLOG_ACTIVE_RECOVERY;
 
@@ -947,6 +953,9 @@ xfs_log_unmount(
 	xfs_log_quiesce(mp);
 
 	xfs_trans_ail_destroy(mp);
+
+	xfs_sysfs_del(&mp->m_log->l_kobj);
+
 	xlog_dealloc_log(mp->m_log);
 }
 
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 9bc403a..db7cbde 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -405,6 +405,8 @@ struct xlog {
 	struct xlog_grant_head	l_reserve_head;
 	struct xlog_grant_head	l_write_head;
 
+	struct xfs_kobj		l_kobj;
+
 	/* The following field are used for debugging; need to hold icloglock */
 #ifdef DEBUG
 	char			*l_iclog_bak[XLOG_MAX_ICLOGS];
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index ae9aa7a..88361d7 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -18,6 +18,9 @@
 
 #include "xfs.h"
 #include "xfs_sysfs.h"
+#include "xfs_log_format.h"
+#include "xfs_log.h"
+#include "xfs_log_priv.h"
 
 struct xfs_sysfs_attr {
 	struct attribute attr;
@@ -47,3 +50,52 @@ to_attr(struct attribute *attr)
 struct kobj_type xfs_mp_ktype = {
 	.release = xfs_sysfs_release,
 };
+
+/* xlog */
+
+static struct attribute *xfs_log_attrs[] = {
+	NULL,
+};
+
+static inline struct xlog *
+to_xlog(struct kobject *kobject)
+{
+	struct xfs_kobj *kobj = to_kobj(kobject);
+	return container_of(kobj, struct xlog, l_kobj);
+}
+
+STATIC ssize_t
+xfs_log_show(
+	struct kobject		*kobject,
+	struct attribute	*attr,
+	char			*buf)
+{
+	struct xlog *log = to_xlog(kobject);
+	struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+
+	return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
+}
+
+STATIC ssize_t
+xfs_log_store(
+	struct kobject		*kobject,
+	struct attribute	*attr,
+	const char		*buf,
+	size_t			count)
+{
+	struct xlog *log = to_xlog(kobject);
+	struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+
+	return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
+}
+
+static struct sysfs_ops xfs_log_ops = {
+	.show = xfs_log_show,
+	.store = xfs_log_store,
+};
+
+struct kobj_type xfs_log_ktype = {
+	.release = xfs_sysfs_release,
+	.sysfs_ops = &xfs_log_ops,
+	.default_attrs = xfs_log_attrs,
+};
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h
index 438976b..3dcfe80 100644
--- a/fs/xfs/xfs_sysfs.h
+++ b/fs/xfs/xfs_sysfs.h
@@ -20,6 +20,7 @@
 #define __XFS_SYSFS_H__
 
 extern struct kobj_type xfs_mp_ktype;	/* xfs_mount */
+extern struct kobj_type xfs_log_ktype;	/* xlog */
 
 static inline struct xfs_kobj *
 to_kobj(struct kobject *kobject)
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 5/6] xfs: add log attributes for log lsn and grant head data
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
                   ` (3 preceding siblings ...)
  2014-06-27 12:06 ` [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers Brian Foster
@ 2014-06-27 12:07 ` Brian Foster
  2014-06-27 12:07 ` [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI Brian Foster
  5 siblings, 0 replies; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:07 UTC (permalink / raw)
  To: xfs

Create log attributes to export the current runtime state of the log to
sysfs. Note that the filesystem should be frozen for consistency across
attributes.

The following per-mount attributes are created: log_head_lsn,
log_tail_lsn, reserve_grant_head and write_grant_head. These represent
the physical log head, tail and reserve and write grant heads
respectively. Attribute values are exported in the following format:

	"cycle:[block,byte]"

... where cycle represents the log cycle and [block,bytes] represents
either the basic block or byte offset of the log, depending on the
attribute.  Log sequence number (LSN) values are encoded in basic blocks
and grant heads are encoded in bytes. All values are in decimal format.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_sysfs.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 88361d7..9835139 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -53,7 +53,71 @@ struct kobj_type xfs_mp_ktype = {
 
 /* xlog */
 
+STATIC ssize_t
+log_head_lsn_show(
+	char	*buf,
+	void	*data)
+{
+	struct xlog *log = data;
+	int cycle;
+	int block;
+
+	spin_lock(&log->l_icloglock);
+	cycle = log->l_curr_cycle;
+	block = log->l_curr_block;
+	spin_unlock(&log->l_icloglock);
+
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
+}
+XFS_SYSFS_ATTR_RO(log_head_lsn);
+
+STATIC ssize_t
+log_tail_lsn_show(
+	char	*buf,
+	void	*data)
+{
+	struct xlog *log = data;
+	int cycle;
+	int block;
+
+	xlog_crack_atomic_lsn(&log->l_tail_lsn, &cycle, &block);
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
+}
+XFS_SYSFS_ATTR_RO(log_tail_lsn);
+
+STATIC ssize_t
+reserve_grant_head_show(
+	char	*buf,
+	void	*data)
+{
+	struct xlog *log = data;
+	int cycle;
+	int bytes;
+
+	xlog_crack_grant_head(&log->l_reserve_head.grant, &cycle, &bytes);
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
+}
+XFS_SYSFS_ATTR_RO(reserve_grant_head);
+
+STATIC ssize_t
+write_grant_head_show(
+	char	*buf,
+	void	*data)
+{
+	struct xlog *log = data;
+	int cycle;
+	int bytes;
+
+	xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &bytes);
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
+}
+XFS_SYSFS_ATTR_RO(write_grant_head);
+
 static struct attribute *xfs_log_attrs[] = {
+	ATTR_LIST(log_head_lsn),
+	ATTR_LIST(log_tail_lsn),
+	ATTR_LIST(reserve_grant_head),
+	ATTR_LIST(write_grant_head),
 	NULL,
 };
 
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI
  2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
                   ` (4 preceding siblings ...)
  2014-06-27 12:07 ` [PATCH v2 5/6] xfs: add log attributes for log lsn and grant head data Brian Foster
@ 2014-06-27 12:07 ` Brian Foster
  2014-07-10 23:32   ` Dave Chinner
  5 siblings, 1 reply; 10+ messages in thread
From: Brian Foster @ 2014-06-27 12:07 UTC (permalink / raw)
  To: xfs

Create a sysfs-fs-xfs ABI documentation file for newly added sysfs
attributes. This is created under the testing section.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 Documentation/ABI/testing/sysfs-fs-xfs | 39 ++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-fs-xfs

diff --git a/Documentation/ABI/testing/sysfs-fs-xfs b/Documentation/ABI/testing/sysfs-fs-xfs
new file mode 100644
index 0000000..b81aa08
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-fs-xfs
@@ -0,0 +1,39 @@
+What:		/sys/fs/xfs/<disk>/log/log_head_lsn
+Date:		June 2014
+KernelVersion:	3.16
+Contact:	xfs@oss.sgi.com
+Description:
+		The log sequence number (LSN) of the current head of the
+		log. The LSN is exported in "cycle:basic block" format.
+Users:		xfstests
+
+What:		/sys/fs/xfs/<disk>/log/log_tail_lsn
+Date:		June 2014
+KernelVersion:	3.16
+Contact:	xfs@oss.sgi.com
+Description:
+		The log sequence number (LSN) of the current tail of the
+		log. The LSN is exported in "cycle:basic block" format.
+
+What:		/sys/fs/xfs/<disk>/log/reserve_grant_head
+Date:		June 2014
+KernelVersion:	3.16
+Contact:	xfs@oss.sgi.com
+Description:
+		The current state of the log reserve grant head. It
+		represents the total log reservation of all currently
+		outstanding transactions. The grant head is exported in
+		"cycle:bytes" format.
+Users:		xfstests
+
+What:		/sys/fs/xfs/<disk>/log/write_grant_head
+Date:		June 2014
+KernelVersion:	3.16
+Contact:	xfs@oss.sgi.com
+Description:
+		The current state of the log write grant head. It
+		represents the total log reservation of all currently
+		oustanding transactions, including regrants due to
+		rolling transactions. The grant head is exported in
+		"cycle:bytes" format.
+Users:		xfstests
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject
  2014-06-27 12:06 ` [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject Brian Foster
@ 2014-06-28  0:56   ` Dave Chinner
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Chinner @ 2014-06-28  0:56 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Fri, Jun 27, 2014 at 08:06:58AM -0400, Brian Foster wrote:
> Embed a base kobject into xfs_mount. This creates a kobject associated
> with each XFS mount and a subdirectory in sysfs with the name of the
> filesystem. The subdirectory lifecycle matches that of the mount. Also
> add the new xfs_sysfs.[c,h] source files with some XFS sysfs
> infrastructure to facilitate attribute creation.
> 
> Note that there are currently no attributes exported as part of the
> xfs_mount kobject. It exists solely to serve as a per-mount container
> for child objects.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

One minor thing I can clean up directly:

> +static inline int
> +xfs_sysfs_init(
> +	struct xfs_kobj		*kobj,
> +	struct kobj_type	*ktype,
> +	struct xfs_kobj		*p_kobj,
                                 ^^^^^^

parent_kobj would be better - that looks too much like hungarian
notation... :)

Other than that,

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI
  2014-06-27 12:07 ` [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI Brian Foster
@ 2014-07-10 23:32   ` Dave Chinner
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Chinner @ 2014-07-10 23:32 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Fri, Jun 27, 2014 at 08:07:01AM -0400, Brian Foster wrote:
> Create a sysfs-fs-xfs ABI documentation file for newly added sysfs
> attributes. This is created under the testing section.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>  Documentation/ABI/testing/sysfs-fs-xfs | 39 ++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-fs-xfs
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-xfs b/Documentation/ABI/testing/sysfs-fs-xfs
> new file mode 100644
> index 0000000..b81aa08
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-fs-xfs
> @@ -0,0 +1,39 @@
> +What:		/sys/fs/xfs/<disk>/log/log_head_lsn
> +Date:		June 2014
> +KernelVersion:	3.16

3.17, actually, but I can fix that up.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers
  2014-06-27 12:06 ` [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers Brian Foster
@ 2014-07-10 23:33   ` Dave Chinner
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Chinner @ 2014-07-10 23:33 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Fri, Jun 27, 2014 at 08:06:59AM -0400, Brian Foster wrote:
> Embed a kobject into the xfs log data structure (xlog). This creates a
> 'log' subdirectory for every XFS mount instance in sysfs. The lifecycle
> of the log kobject is tied to the lifecycle of the log.
> 
> Also define a set of generic attribute handlers associated with the log
> kobject in preparation for the addition of attributes.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks fine.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-07-10 23:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 12:06 [PATCH v2 0/6] xfs sysfs support Brian Foster
2014-06-27 12:06 ` [PATCH v2 1/6] xfs: fix a couple error sequence jumps in xfs_mountfs() Brian Foster
2014-06-27 12:06 ` [PATCH v2 2/6] xfs: add a sysfs kset Brian Foster
2014-06-27 12:06 ` [PATCH v2 3/6] xfs: add xfs_mount sysfs kobject Brian Foster
2014-06-28  0:56   ` Dave Chinner
2014-06-27 12:06 ` [PATCH v2 4/6] xfs: add xlog sysfs kobject and attribute handlers Brian Foster
2014-07-10 23:33   ` Dave Chinner
2014-06-27 12:07 ` [PATCH v2 5/6] xfs: add log attributes for log lsn and grant head data Brian Foster
2014-06-27 12:07 ` [PATCH v2 6/6] xfs: document log sysfs attributes in testing ABI Brian Foster
2014-07-10 23:32   ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.