linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@suse.de>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 00/26] VFS based Union Mount (V2)
Date: Thu, 2 Aug 2007 12:17:50 +0200	[thread overview]
Message-ID: <20070802101750.GV5101@hasse.suse.de> (raw)
In-Reply-To: <20070802064943.GB24152@in.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Thu, Aug 02, Bharata B Rao wrote:

> On Mon, Jul 30, 2007 at 06:13:23PM +0200, Jan Blunck wrote:
> > Here is another post of the VFS based union mount implementation. Unlike the
> > traditional mount which hides the contents of the mount point, union mounts
> > present the merged view of the mount point and the mounted filesytem.
> 
> Doesn't compile without CONFIG_DEBUG_UNION_MOUNT.
> 
> fs/namei.c: In function `hash_lookup_union':
> fs/namei.c:1798: error: implicit declaration of function `UM_DEBUG_LOOKUP'
> make[1]: *** [fs/namei.o] Error 1

Umm, typo in the debug infrastruture patch. Here is the fixed version.

Thanks,
Jan

[-- Attachment #2: union-mount-debug-infrastructure.diff --]
[-- Type: text/x-patch, Size: 10830 bytes --]

Subject: union-mount: Debug Infrastructure

This adds debugfs/relay based debugging infrastructure helpful when doing
development of the union-mount code itself. The debgging output can be enabled
during runtime by:

 echo 1 > /proc/sys/fs/union-debug

This registers the relayfs files where the debug code is writing its output
to. There are different levels of debugging output available which can be ORed
together. For the valid sysctl values see include/linux/union_debug.h.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 include/linux/union_debug.h |   91 ++++++++++++++
 lib/Kconfig.debug           |    9 +
 lib/Makefile                |    2 
 lib/union_debug.c           |  268 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 370 insertions(+)

--- /dev/null
+++ b/include/linux/union_debug.h
@@ -0,0 +1,91 @@
+/*
+ * VFS based union mount for Linux
+ *
+ * Copyright (C) 2004-2007 IBM Corporation, IBM Deutschland Entwicklung GmbH.
+ * Copyright (C) 2007 Novell Inc.
+ *   Author(s): Jan Blunck (j.blunck@tu-harburg.de)
+ *
+ * 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; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#ifndef __LINUX_UNION_DEBUG_H
+#define __LINUX_UNION_DEBUG_H
+
+#ifdef __KERNEL__
+
+#ifdef CONFIG_DEBUG_UNION_MOUNT
+
+#include <linux/sched.h>
+
+/* This is taken from klog debugging facility */
+extern void klog(const void *data, int len);
+extern void klog_printk(const char *fmt, ...);
+extern void klog_printk_dentry(const char *func, struct dentry *dentry);
+
+extern int sysctl_union_debug;
+
+#define UNION_MOUNT_DEBUG		1
+#define UNION_MOUNT_DEBUG_DCACHE	2
+#define UNION_MOUNT_DEBUG_LOCK		4
+#define UNION_MOUNT_DEBUG_READDIR	8
+#define UNION_MOUNT_DEBUG_LOOKUP	16
+
+#define UM_DEBUG(fmt, args...)						\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG)			\
+		klog_printk("%s: " fmt, __FUNCTION__, ## args);		\
+} while (0)
+#define UM_DEBUG_DENTRY(dentry)						\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG)			\
+		klog_printk_dentry(__FUNCTION__, (dentry));		\
+} while (0)
+#define UM_DEBUG_DCACHE(fmt, args...)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_DCACHE)		\
+		klog_printk("%s: " fmt, __FUNCTION__, ## args);		\
+} while (0)
+#define UM_DEBUG_DCACHE_DENTRY(dentry)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_DCACHE)		\
+		klog_printk_dentry(__FUNCTION__, (dentry));		\
+} while (0)
+#define UM_DEBUG_LOCK(fmt, args...)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_LOCK)		\
+		klog_printk("%s: " fmt, __FUNCTION__, ## args);		\
+} while (0)
+#define UM_DEBUG_READDIR(fmt, args...)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_READDIR)		\
+		klog_printk("%s: " fmt, __FUNCTION__, ## args);		\
+} while (0)
+#define UM_DEBUG_LOOKUP(fmt, args...)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_LOOKUP)		\
+		klog_printk("%s: " fmt, __FUNCTION__, ## args);		\
+} while (0)
+#define UM_DEBUG_LOOKUP_DENTRY(dentry)					\
+do {									\
+	if (sysctl_union_debug & UNION_MOUNT_DEBUG_LOOKUP)		\
+		klog_printk_dentry(__FUNCTION__, (dentry));		\
+} while (0)
+
+#else	/* CONFIG_DEBUG_UNION_MOUNT */
+
+#define UM_DEBUG(fmt, args...)			do { /* empty */ } while (0)
+#define UM_DEBUG_DENTRY(fmt, args...)		do { /* empty */ } while (0)
+#define UM_DEBUG_DCACHE(fmt, args...)		do { /* empty */ } while (0)
+#define UM_DEBUG_DCACHE_DENTRY(fmt, args...)	do { /* empty */ } while (0)
+#define UM_DEBUG_LOCK(fmt, args...)		do { /* empty */ } while (0)
+#define UM_DEBUG_READDIR(fmt, args...)		do { /* empty */ } while (0)
+#define UM_DEBUG_LOOKUP(fmt, args...)		do { /* empty */ } while (0)
+#define UM_DEBUG_LOOKUP_DENTRY(fmt, args...)	do { /* empty */ } while (0)
+
+#endif	/* CONFIG_DEBUG_UNION_MOUNT */
+
+#endif	/* __KERNEL__ */
+#endif	/*  __LINUX_UNION_DEBUG_H */
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -393,6 +393,15 @@ config DEBUG_LIST
 
 	  If unsure, say N.
 
+config DEBUG_UNION_MOUNT
+	bool "Debug VFS based union mounts"
+	depends on DEBUG_KERNEL && UNION_MOUNT
+	select DEBUG_FS
+	default n
+	help
+	  If you say Y here, the union mount debugging code will be
+	  compiled in.
+
 config FRAME_POINTER
 	bool "Compile the kernel with frame pointers"
 	depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN)
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,6 +35,8 @@ obj-$(CONFIG_PLIST) += plist.o
 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
 obj-$(CONFIG_DEBUG_LIST) += list_debug.o
 
+obj-$(CONFIG_DEBUG_UNION_MOUNT) += union_debug.o
+
 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
   lib-y += dec_and_lock.o
 endif
--- /dev/null
+++ b/lib/union_debug.c
@@ -0,0 +1,268 @@
+/*
+ * VFS based union mount for Linux
+ *
+ * Copyright (C) 2007 SUSE Linux
+ *   Author(s): Jan Blunck (jblunck@suse.de)
+ *
+ * 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; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/sysctl.h>
+#include <linux/init.h>
+#include <linux/relay.h>
+#include <linux/debugfs.h>
+
+int sysctl_union_debug;
+EXPORT_SYMBOL_GPL(sysctl_union_debug);
+
+static struct rchan *debug_rchan;
+static struct dentry *debug_logdir;
+#define SUBBUF_SIZE 262144
+#define N_SUBBUF 4
+
+static struct dentry *create_buf_file(const char *filename,
+				      struct dentry *parent, int mode,
+				      struct rchan_buf *buf, int *is_global)
+{
+	return debugfs_create_file(filename, mode, parent, buf,
+				   &relay_file_operations);
+}
+
+static int remove_buf_file(struct dentry *dentry)
+{
+	debugfs_remove(dentry);
+	return 0;
+}
+
+static int subbuf_start(struct rchan_buf *buf, void *subbuf, void *prev_subbuf,
+			unsigned int prev_padding)
+{
+	return 1;
+}
+
+static struct rchan_callbacks debug_relay_cb = {
+	.create_buf_file = create_buf_file,
+	.remove_buf_file = remove_buf_file,
+	.subbuf_start = subbuf_start,
+};
+
+static int union_debug_relay_init(void)
+{
+	struct dentry *dentry;
+	struct rchan *rchan;
+
+	if (!debug_logdir) {
+		dentry = debugfs_create_dir("union", NULL);
+		if (IS_ERR(dentry)) {
+			printk(KERN_INFO
+			       "%s: debugfs directory creation failed\n",
+			       __FUNCTION__);
+			return PTR_ERR(dentry);
+		}
+
+		debug_logdir = dentry;
+	}
+
+	if (!debug_rchan) {
+		rchan = relay_open("logfile", debug_logdir,
+				   SUBBUF_SIZE, N_SUBBUF,
+				   &debug_relay_cb, NULL);
+		if (!rchan) {
+			printk(KERN_INFO "%s: relay channel creation failed\n",
+			       __FUNCTION__);
+			debugfs_remove(debug_logdir);
+			return -ENOMEM;
+		}
+
+		debug_rchan = rchan;
+	}
+
+	return 0;
+}
+
+static void union_debug_relay_exit(void)
+{
+	if (debug_rchan)
+		relay_close(debug_rchan);
+	debug_rchan = NULL;
+	if (debug_logdir)
+		debugfs_remove(debug_logdir);
+	debug_logdir = NULL;
+}
+
+/*
+ * klog operations
+ */
+struct klog_operations
+{
+	/*
+	 * klog - called when klog called, same params
+	 */
+	void (*klog) (const void *data, int len);
+};
+
+/* maximum size of klog formatting buffer beyond which truncation will occur */
+#define KLOG_TMPBUF_SIZE (1024)
+/* per-cpu klog formatting temporary buffer */
+static char klog_buf[NR_CPUS][KLOG_TMPBUF_SIZE];
+
+/*
+ * do-nothing default klog handler, called if nothing registered
+ */
+static void default_klog(const void *data, int len)
+{
+}
+
+/*
+ * default klog operations, used if nothing registered
+ */
+static struct klog_operations default_klog_ops =
+{
+	.klog = default_klog,
+};
+
+static struct klog_operations *cur_klog_ops = &default_klog_ops;
+
+/**
+ *      register_klog_handler - register klog handler
+ *      @klog_ops: klog operations callbacks
+ *
+ *      replaces default klog handler with passed-in version
+ */
+int register_klog_handler(struct klog_operations *klog_ops)
+{
+	if (!klog_ops)
+		return -EINVAL;
+
+	if (!klog_ops->klog)
+		klog_ops->klog = default_klog;
+
+	cur_klog_ops = klog_ops;
+	return 0;
+}
+
+/**
+ *      unregister_klog_handler - unregister klog handler
+ *
+ *      default handler will be in effect after this
+ */
+void unregister_klog_handler(void)
+{
+	cur_klog_ops = &default_klog_ops;
+}
+
+/**
+ *      klog - send raw data to klog handler
+ */
+void klog(const void *data, int len)
+{
+	cur_klog_ops->klog(data, len);
+}
+
+/**
+ *      klog_printk - send a formatted string to the klog handler
+ *      @fmt: format string, same as printk
+ */
+void klog_printk(const char *fmt, ...)
+{
+	va_list args;
+	int len;
+	char *cbuf;
+	unsigned long flags;
+
+	local_irq_save(flags);
+	cbuf = klog_buf[smp_processor_id()];
+	va_start(args, fmt);
+	len = vsnprintf(cbuf, KLOG_TMPBUF_SIZE, fmt, args);
+	va_end(args);
+	klog(cbuf, len);
+	local_irq_restore(flags);
+}
+EXPORT_SYMBOL_GPL(klog_printk);
+
+void klog_printk_dentry(const char *func, struct dentry *dentry)
+{
+	klog_printk("%s: %p{i=%p/%lx,c=%d,n=\"%s\"}\n",
+		    func,
+		    dentry,
+		    dentry->d_inode,
+		    dentry->d_inode ?
+		    dentry->d_inode->i_ino : 0UL,
+		    atomic_read(&dentry->d_count),
+		    dentry->d_name.name);
+}
+EXPORT_SYMBOL_GPL(klog_printk_dentry);
+
+static void log_data(const void *data, int len)
+{
+	relay_write(debug_rchan, data, len);
+}
+
+static struct klog_operations klog_handler =
+{
+	.klog = log_data,
+};
+
+static int union_debug_sysctl_handler(ctl_table *table, int write,
+				      struct file *file,
+				      void __user *buffer, size_t *length,
+				      loff_t *ppos)
+{
+	proc_dointvec_minmax(table, write, file, buffer, length, ppos);
+
+	if (!write)
+		return 0;
+
+	printk(KERN_INFO "sysctl.fs.union-debug: %d\n", sysctl_union_debug);
+
+	switch (sysctl_union_debug) {
+	case 0:
+		unregister_klog_handler();
+		union_debug_relay_exit();
+		break;
+	default:
+		union_debug_relay_init();
+		if (register_klog_handler(&klog_handler))
+			union_debug_relay_exit();
+		break;
+	}
+
+	return 0;
+}
+
+static ctl_table union_table[] = {
+	{
+		.ctl_name = CTL_UNNUMBERED,
+		.procname = "union-debug",
+		.data = &sysctl_union_debug,
+		.maxlen = sizeof(int),
+		.mode = 0644,
+		.proc_handler = &union_debug_sysctl_handler,
+	},
+	{.ctl_name = 0}
+};
+
+static ctl_table fs_root[] = {
+	{
+		.ctl_name = CTL_FS,
+		.procname = "fs",
+		.maxlen = 0,
+		.mode = 0555,
+		.child = union_table,
+	},
+	{.ctl_name = 0}
+};
+
+static struct ctl_table_header *sysctl_header;
+
+static int union_debug_init(void)
+{
+	sysctl_header = register_sysctl_table(fs_root);
+	return 0;
+}
+
+late_initcall(union_debug_init);

      reply	other threads:[~2007-08-02 10:17 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-30 16:13 [RFC 00/26] VFS based Union Mount (V2) Jan Blunck
2007-07-30 16:13 ` [RFC 01/26] [PATCH 14/18] shmem: convert to using splice instead of sendfile() Jan Blunck
2007-07-30 16:13 ` [RFC 02/26] VFS: Export dput_path() and path_to_nameidata() Jan Blunck
2007-07-30 16:13 ` [RFC 03/26] VFS: Make lookup_hash() return a struct path Jan Blunck
2007-07-30 16:13 ` [RFC 04/26] VFS: Make lookup_create() " Jan Blunck
2007-07-30 16:13 ` [RFC 05/26] VFS: cache_lookup() cleanup Jan Blunck
2007-07-30 16:13 ` [RFC 06/26] VFS: Make real_lookup() return a struct path Jan Blunck
2007-07-30 16:13 ` [RFC 07/26] VFS: Introduce dput() variante that maintains a kill-list Jan Blunck
2007-07-30 16:13 ` [RFC 08/26] VFS: Export lives_below_in_same_fs() Jan Blunck
2007-07-30 16:13 ` [RFC 09/26] linux/stat.h: Add the filetype white-out Jan Blunck
2007-07-30 16:13 ` [RFC 10/26] VFS white-out handling Jan Blunck
2007-07-30 16:13 ` [RFC 11/26] tmpfs white-out support Jan Blunck
2007-08-01 15:13   ` Hugh Dickins
2007-08-02  2:48     ` Matt Mackall
2007-07-30 16:13 ` [RFC 12/26] ext2 " Jan Blunck
2007-07-31  3:45   ` Theodore Tso
2007-07-31  7:44     ` Jan Blunck
2007-07-31  8:32       ` Andreas Dilger
2007-07-31  9:08         ` Jan Blunck
2007-07-31 10:53       ` Theodore Tso
2007-08-02 19:31         ` Pavel Machek
2007-07-31 16:36   ` Josef Sipek
2007-07-31 17:00     ` Jan Blunck
2007-07-31 17:11       ` Josef Sipek
2007-08-01 15:23         ` Dave Kleikamp
2007-08-01 18:44           ` Josef Sipek
2007-08-01 19:10             ` Dave Kleikamp
2007-08-01 19:33               ` Josef Sipek
2007-08-01 19:52                 ` Dave Kleikamp
2007-08-01 22:06                   ` Erez Zadok
2007-08-02 12:05                     ` Jan Blunck
2007-08-02 11:55                 ` Jan Blunck
2007-08-02 17:50                 ` Jörn Engel
2007-08-02  5:24             ` Ph. Marek
2007-08-02 12:12               ` Jan Blunck
2007-08-02 10:26         ` Jan Blunck
2007-08-01 10:00       ` Hans-Peter Jansen
2007-08-01 11:43         ` Josef Sipek
2007-08-01 18:01         ` Jan Engelhardt
2007-07-31 17:03     ` Mark Williamson
2007-07-31 17:16       ` Josef Sipek
2007-08-01 17:58     ` Jan Engelhardt
2007-08-01 18:03       ` Josef Sipek
2007-07-30 16:13 ` [RFC 13/26] ext3 whiteout support Jan Blunck
2007-07-30 16:13 ` [RFC 14/26] union-mount: Documentation Jan Blunck
2007-07-30 16:13 ` [RFC 15/26] union-mount: Add union-mount mount flag Jan Blunck
2007-07-30 16:13 ` [RFC 16/26] union-mount: Introduce union_mount structure Jan Blunck
2007-08-06  5:57   ` Bharata B Rao
2007-07-30 16:13 ` [RFC 17/26] union-mount: Drive the union cache via dcache Jan Blunck
2007-07-30 16:13 ` [RFC 18/26] union-mount: Changes to the namespace handling Jan Blunck
2007-08-08 10:10   ` Bharata B Rao
2007-07-30 16:13 ` [RFC 19/26] union-mount: Make lookup work for union-mounted file systems Jan Blunck
2007-08-09  5:42   ` Bharata B Rao
2007-07-30 16:13 ` [RFC 20/26] union-mount: Simple union-mount readdir implementation Jan Blunck
2007-08-06 11:08   ` Bharata B Rao
2007-07-30 16:13 ` [RFC 21/26] union-mount: in-kernel file copy between union mounted filesystems Jan Blunck
2007-07-30 16:13 ` [RFC 22/26] union-mount: white-out changes for copy-on-open Jan Blunck
2007-07-30 16:13 ` [RFC 23/26] union-mount: copyup on rename Jan Blunck
2007-07-30 16:13 ` [RFC 24/26] union-mount: dont report EROFS for union mounts Jan Blunck
2007-07-30 16:13 ` [RFC 25/26] union-mount: Debug Infrastructure Jan Blunck
2007-07-30 16:13 ` [RFC 26/26] union-mount: Debug code Jan Blunck
2007-07-30 18:23 ` [RFC 00/26] VFS based Union Mount (V2) Al Boldi
2007-08-02  6:49 ` Bharata B Rao
2007-08-02 10:17   ` Jan Blunck [this message]

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=20070802101750.GV5101@hasse.suse.de \
    --to=jblunck@suse.de \
    --cc=bharata@linux.vnet.ibm.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).