linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. R. Okajima" <hooanon05@yahoo.co.jp>
To: linux-kernel@vger.kernel.org
Cc: greg@kroah.com, linux-fsdevel@vger.kernel.org,
	"J. R. Okajima" <hooanon05@yahoo.co.jp>
Subject: [RFC Aufs2 #5 06/29] aufs object lifetime management via sysfs
Date: Fri, 10 Apr 2009 16:02:20 +0900	[thread overview]
Message-ID: <1239346963-30953-7-git-send-email-hooanon05@yahoo.co.jp> (raw)
In-Reply-To: <1239346963-30953-1-git-send-email-hooanon05@yahoo.co.jp>

initial commit
some aufs objects have a corresponding entry under sysfs, so the
lifetime will be managed by struct kref even if CONFIG_SYSFS is
disabled.
This file is compiled unconditionally.

Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp>
---
 Documentation/ABI/testing/sysfs-aufs |   25 ++++++++
 fs/aufs/sysaufs.c                    |   95 +++++++++++++++++++++++++++++
 fs/aufs/sysaufs.h                    |  109 ++++++++++++++++++++++++++++++++++
 3 files changed, 229 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-aufs
 create mode 100644 fs/aufs/sysaufs.c
 create mode 100644 fs/aufs/sysaufs.h

diff --git a/Documentation/ABI/testing/sysfs-aufs b/Documentation/ABI/testing/sysfs-aufs
new file mode 100644
index 0000000..ca49330
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-aufs
@@ -0,0 +1,25 @@
+What:		/sys/fs/aufs/si_<id>/
+Date:		March 2009
+Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
+Description:
+		Under /sys/fs/aufs, a directory named si_<id> is created
+		per aufs mount, where <id> is a unique id generated
+		internally.
+
+What:		/sys/fs/aufs/si_<id>/br0, br1 ... brN
+Date:		March 2009
+Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
+Description:
+		It shows the abolute path of a member directory (which
+		is called branch) in aufs, and its permission.
+
+What:		/sys/fs/aufs/si_<id>/xi_path
+Date:		March 2009
+Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
+Description:
+		It shows the abolute path of XINO (External Inode Number
+		Bitmap, Translation Table and Generation Table) file
+		even if it is the default path.
+		When the aufs mount option 'noxino' is specified, it
+		will be empty. About XINO files, see
+		Documentation/filesystems/aufs/aufs.5 in detail.
diff --git a/fs/aufs/sysaufs.c b/fs/aufs/sysaufs.c
new file mode 100644
index 0000000..623f2e6
--- /dev/null
+++ b/fs/aufs/sysaufs.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2005-2009 Junjiro R. Okajima
+ *
+ * This program, aufs 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+/*
+ * sysfs interface and lifetime management
+ * they are necessary regardless sysfs is disabled.
+ */
+
+#include <linux/fs.h>
+#include <linux/random.h>
+#include <linux/sysfs.h>
+#include "aufs.h"
+
+unsigned long sysaufs_si_mask;
+struct kset *sysaufs_ket;
+
+#define AuSiAttr(_name) { \
+	.attr   = { .name = __stringify(_name), .mode = 0444 },	\
+	.show   = sysaufs_si_##_name,				\
+}
+
+static struct sysaufs_si_attr sysaufs_si_attr_xi_path = AuSiAttr(xi_path);
+struct attribute *sysaufs_si_attrs[] = {
+	&sysaufs_si_attr_xi_path.attr,
+	NULL,
+};
+
+static struct sysfs_ops au_sbi_ops = {
+	.show   = sysaufs_si_show
+};
+
+static struct kobj_type au_sbi_ktype = {
+	.release	= au_si_free,
+	.sysfs_ops	= &au_sbi_ops,
+	.default_attrs	= sysaufs_si_attrs
+};
+
+/* ---------------------------------------------------------------------- */
+
+int sysaufs_si_init(struct au_sbinfo *sbinfo)
+{
+	int err;
+
+	sbinfo->si_kobj.kset = sysaufs_ket;
+	/* cf. sysaufs_name() */
+	err = kobject_init_and_add
+		(&sbinfo->si_kobj, &au_sbi_ktype, /*&sysaufs_ket->kobj*/NULL,
+		 SysaufsSiNamePrefix "%lx", sysaufs_si_id(sbinfo));
+
+	dbgaufs_si_null(sbinfo);
+	if (!err) {
+		err = dbgaufs_si_init(sbinfo);
+		if (unlikely(err))
+			kobject_put(&sbinfo->si_kobj);
+	}
+	return err;
+}
+
+void sysaufs_fin(void)
+{
+	dbgaufs_fin();
+	sysfs_remove_group(&sysaufs_ket->kobj, sysaufs_attr_group);
+	kset_unregister(sysaufs_ket);
+}
+
+int __init sysaufs_init(void)
+{
+	int err;
+
+	do {
+		get_random_bytes(&sysaufs_si_mask, sizeof(sysaufs_si_mask));
+	} while (!sysaufs_si_mask);
+
+	sysaufs_ket = kset_create_and_add(AUFS_NAME, NULL, fs_kobj);
+	err = PTR_ERR(sysaufs_ket);
+	if (IS_ERR(sysaufs_ket))
+		goto out;
+	err = sysfs_create_group(&sysaufs_ket->kobj, sysaufs_attr_group);
+	if (unlikely(err)) {
+		kset_unregister(sysaufs_ket);
+		goto out;
+	}
+
+	err = dbgaufs_init();
+	if (unlikely(err))
+		sysaufs_fin();
+ out:
+	return err;
+}
diff --git a/fs/aufs/sysaufs.h b/fs/aufs/sysaufs.h
new file mode 100644
index 0000000..c1202fa
--- /dev/null
+++ b/fs/aufs/sysaufs.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2005-2009 Junjiro R. Okajima
+ *
+ * This program, aufs 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+/*
+ * sysfs interface and mount lifetime management
+ */
+
+#ifndef __SYSAUFS_H__
+#define __SYSAUFS_H__
+
+#ifdef __KERNEL__
+
+#include <linux/fs.h>
+#include <linux/sysfs.h>
+#include <linux/aufs_type.h>
+#include "module.h"
+
+struct sysaufs_si_attr {
+	struct attribute attr;
+	int (*show)(struct seq_file *seq, struct super_block *sb);
+};
+
+/* ---------------------------------------------------------------------- */
+
+/* sysaufs.c */
+extern unsigned long sysaufs_si_mask;
+extern struct kset *sysaufs_ket;
+extern struct attribute *sysaufs_si_attrs[];
+int sysaufs_si_init(struct au_sbinfo *sbinfo);
+int __init sysaufs_init(void);
+void sysaufs_fin(void);
+
+/* ---------------------------------------------------------------------- */
+
+/* some people doesn't like to show a pointer in kernel */
+static inline unsigned long sysaufs_si_id(struct au_sbinfo *sbinfo)
+{
+	return sysaufs_si_mask ^ (unsigned long)sbinfo;
+}
+
+#define SysaufsSiNamePrefix	"si_"
+#define SysaufsSiNameLen	(sizeof(SysaufsSiNamePrefix) + 16)
+static inline void sysaufs_name(struct au_sbinfo *sbinfo, char *name)
+{
+	snprintf(name, SysaufsSiNameLen, SysaufsSiNamePrefix "%lx",
+		 sysaufs_si_id(sbinfo));
+}
+
+struct au_branch;
+#ifdef CONFIG_SYSFS
+/* sysfs.c */
+extern struct attribute_group *sysaufs_attr_group;
+
+int sysaufs_si_xi_path(struct seq_file *seq, struct super_block *sb);
+ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr,
+			 char *buf);
+
+void sysaufs_br_init(struct au_branch *br);
+void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex);
+void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex);
+
+#define sysaufs_brs_init()	do {} while (0)
+
+#else
+#define sysaufs_attr_group	NULL
+
+static inline
+int sysaufs_si_xi_path(struct seq_file *seq, struct super_block *sb)
+{
+	return 0;
+}
+
+static inline
+ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr,
+			 char *buf)
+{
+	return 0;
+}
+
+static inline void sysaufs_br_init(struct au_branch *br)
+{
+	/* empty */
+}
+
+static inline void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex)
+{
+	/* nothing */
+}
+
+static inline void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex)
+{
+	/* nothing */
+}
+
+static inline void sysaufs_brs_init(void)
+{
+	sysaufs_brs = 0;
+}
+
+#endif /* CONFIG_SYSFS */
+
+#endif /* __KERNEL__ */
+#endif /* __SYSAUFS_H__ */
-- 
1.6.1.284.g5dc13


  parent reply	other threads:[~2009-04-10  7:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-10  7:02 [RFC Aufs2 #5 00/29] souce files J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 01/29] aufs documents J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 02/29] aufs module global J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 03/29] aufs super_block J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 04/29] aufs branch directory/filesystem J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 05/29] aufs xino J. R. Okajima
2009-04-10  7:02 ` J. R. Okajima [this message]
2009-04-10  7:02 ` [RFC Aufs2 #5 07/29] aufs mount options/flags J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 08/29] aufs workqueue J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 09/29] aufs sub-VFS J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 10/29] aufs sub-dcache J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 11/29] aufs copy-up J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 12/29] aufs whiteout J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 13/29] aufs pseudo-link J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 14/29] aufs policies to select one among multiple writable branches J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 15/29] aufs dentry and lookup J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 16/29] aufs file J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 17/29] aufs direcotry J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 18/29] aufs inode J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 19/29] aufs ioctl J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 20/29] aufs sysfs entries J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 21/29] aufs debugfs entries J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 22/29] aufs branch for loopback block device J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 23/29] aufs internal inotify J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 24/29] aufs test for fstype J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 25/29] aufs debug J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 26/29] aufs public header file J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 27/29] export splice functions J. R. Okajima
2009-04-10  7:02 ` [RFC Aufs2 #5 28/29] export lookup functions J. R. Okajima
2009-04-10 16:28   ` Christoph Hellwig
2009-04-10 16:47     ` hooanon05
2009-04-10 16:54       ` Christoph Hellwig
2009-04-10 17:03         ` hooanon05
2009-04-10 17:05           ` Christoph Hellwig
2009-04-10 17:26             ` hooanon05
2009-04-10 17:41               ` Christoph Hellwig
2009-04-10  7:02 ` [RFC Aufs2 #5 29/29] kbuild aufs J. R. Okajima

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=1239346963-30953-7-git-send-email-hooanon05@yahoo.co.jp \
    --to=hooanon05@yahoo.co.jp \
    --cc=greg@kroah.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).