From: "J. R. Okajima" <hooanon05@yahoo.co.jp>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, "J. R. Okajima" <hooanon05@yahoo.co.jp>
Subject: [RFC Aufs2 #2 22/28] aufs branch for loopback block device
Date: Mon, 16 Mar 2009 16:20:34 +0900 [thread overview]
Message-ID: <1237188040-11404-23-git-send-email-hooanon05@yahoo.co.jp> (raw)
In-Reply-To: <1237188040-11404-1-git-send-email-hooanon05@yahoo.co.jp>
initial commit
support and test loopback block device as a branch
Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp>
---
fs/aufs/loop.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
fs/aufs/loop.h | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 0 deletions(-)
create mode 100644 fs/aufs/loop.c
create mode 100644 fs/aufs/loop.h
diff --git a/fs/aufs/loop.c b/fs/aufs/loop.c
new file mode 100644
index 0000000..84a940f
--- /dev/null
+++ b/fs/aufs/loop.c
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/*
+ * support for loopback block device as a branch
+ */
+
+#include <linux/loop.h>
+#include "aufs.h"
+
+/*
+ * test if two lower dentries have overlapping branches.
+ */
+int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1,
+ struct dentry *h_d2)
+{
+ struct inode *h_inode;
+ struct loop_device *l;
+
+ h_inode = h_d1->d_inode;
+ if (MAJOR(h_inode->i_sb->s_dev) != LOOP_MAJOR)
+ return 0;
+
+ l = h_inode->i_sb->s_bdev->bd_disk->private_data;
+ h_d1 = l->lo_backing_file->f_dentry;
+ /* h_d1 can be local NFS. in this case aufs cannot detect the loop */
+ if (unlikely(h_d1->d_sb == sb))
+ return 1;
+ return !!au_test_subdir(h_d1, h_d2);
+}
+
+/* true if a kernel thread named 'loop[0-9].*' accesses a file */
+int au_test_loopback_kthread(void)
+{
+ const char c = current->comm[4];
+
+ return current->mm == NULL
+ && '0' <= c && c <= '9'
+ && strncmp(current->comm, "loop", 4) == 0;
+}
diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h
new file mode 100644
index 0000000..1c0ee40
--- /dev/null
+++ b/fs/aufs/loop.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/*
+ * support for loopback mount as a branch
+ */
+
+#ifndef __AUFS_LOOP_H__
+#define __AUFS_LOOP_H__
+
+#ifdef __KERNEL__
+
+#include <linux/fs.h>
+
+#ifdef CONFIG_AUFS_BDEV_LOOP
+/* loop.c */
+int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1,
+ struct dentry *h_d2);
+int au_test_loopback_kthread(void);
+#else
+static inline
+int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1,
+ struct dentry *h_d2)
+{
+ return 0;
+}
+
+static inline int au_test_loopback_kthread(void)
+{
+ return 0;
+}
+#endif /* BLK_DEV_LOOP */
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_LOOP_H__ */
--
1.6.1.284.g5dc13
next prev parent reply other threads:[~2009-03-16 7:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-16 7:20 [RFC Aufs2 #2 00/28] source files J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 01/28] aufs documents J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 02/28] aufs public header file J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 03/28] aufs module global J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 04/28] aufs super_block J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 05/28] aufs branch directory/filesystem J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 06/28] aufs xino J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 07/28] aufs object lifetime management via sysfs J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 08/28] aufs mount options/flags J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 09/28] aufs workqueue J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 10/28] aufs sub-VFS J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 11/28] aufs sub-dcache J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 12/28] aufs copy-up J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 13/28] aufs whiteout J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 14/28] aufs pseudo-link J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 15/28] aufs policies to select one among multiple writable branches J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 16/28] aufs dentry and lookup J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 17/28] aufs file J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 18/28] aufs direcotry J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 19/28] aufs inode J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 20/28] aufs ioctl J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 21/28] aufs sysfs entries J. R. Okajima
2009-03-16 18:05 ` Greg KH
2009-03-17 3:26 ` hooanon05
2009-03-17 3:37 ` Greg KH
2009-03-17 4:05 ` hooanon05
2009-03-17 4:22 ` Greg KH
2009-03-17 4:50 ` hooanon05
2009-03-17 10:39 ` Evgeniy Polyakov
2009-03-17 12:56 ` hooanon05
2009-03-19 8:04 ` hooanon05
2009-03-16 7:20 ` J. R. Okajima [this message]
2009-03-16 7:20 ` [RFC Aufs2 #2 23/28] aufs internal inotify J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 24/28] aufs test for fstype J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 25/28] aufs debug J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 26/28] export splice functions J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 27/28] export lookup functions J. R. Okajima
2009-03-16 7:20 ` [RFC Aufs2 #2 28/28] 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=1237188040-11404-23-git-send-email-hooanon05@yahoo.co.jp \
--to=hooanon05@yahoo.co.jp \
--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
all inboxes | Powered by JetHome®