linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Jeff Garzik <jeff@garzik.org>,
	open-osd mailing-list <osd-dev@open-osd.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Cc: Evgeniy Polyakov <zbr@ioremap.net>,
	Marcin Slusarz <marcin.slusarz@gmail.com>
Subject: [PATCH 3/3] exofs: export_operations
Date: Wed, 25 Mar 2009 12:07:32 +0200	[thread overview]
Message-ID: <49CA0264.9070501@panasas.com> (raw)
In-Reply-To: <49C9FD2E.3030201@panasas.com>


implement export_operations and set in superblock.
It is now posible to export exofs via nfs

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 fs/exofs/dir.c   |   15 +++++++++++++++
 fs/exofs/exofs.h |    2 ++
 fs/exofs/super.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index 0ca733a..55ebbb1 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -380,6 +380,21 @@ struct exofs_dir_entry *exofs_dotdot(struct inode *dir, struct page **p)
 	return de;
 }
 
+ino_t exofs_parent_ino(struct dentry *child)
+{
+	struct page *page;
+	struct exofs_dir_entry *de;
+	ino_t ino;
+
+	de = exofs_dotdot(child->d_inode, &page);
+	if (!de)
+		return 0;
+
+	ino = le64_to_cpu(de->inode_no);
+	exofs_put_page(page);
+	return ino;
+}
+
 ino_t exofs_inode_by_name(struct inode *dir, struct dentry *dentry)
 {
 	ino_t res = 0;
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h
index d54753d..da1397a 100644
--- a/fs/exofs/exofs.h
+++ b/fs/exofs/exofs.h
@@ -152,6 +152,7 @@ struct exofs_dir_entry *exofs_find_entry(struct inode *, struct dentry *,
 					 struct page **);
 int exofs_empty_dir(struct inode *);
 struct exofs_dir_entry *exofs_dotdot(struct inode *, struct page **);
+ino_t exofs_parent_ino(struct dentry *child);
 int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *,
 		    struct inode *);
 
@@ -174,6 +175,7 @@ extern const struct inode_operations exofs_special_inode_operations;
 
 /* super.c           */
 extern const struct super_operations exofs_sops;
+extern const struct export_operations exofs_export_ops;
 
 /* symlink.c         */
 extern const struct inode_operations exofs_symlink_inode_operations;
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 7fd8866..8a07d6d 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -37,6 +37,7 @@
 #include <linux/parser.h>
 #include <linux/vfs.h>
 #include <linux/random.h>
+#include <linux/exportfs.h>
 
 #include "exofs.h"
 
@@ -357,6 +358,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
 
 	/* set up operation vectors */
 	sb->s_op = &exofs_sops;
+	sb->s_export_op = &exofs_export_ops;
 	root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF);
 	if (IS_ERR(root)) {
 		EXOFS_ERR("ERROR: exofs_iget failed\n");
@@ -484,6 +486,55 @@ const struct super_operations exofs_sops = {
 };
 
 /******************************************************************************
+ * EXPORT OPERATIONS
+ *****************************************************************************/
+struct dentry *exofs_get_parent(struct dentry *child)
+{
+	unsigned long ino = exofs_parent_ino(child);
+
+	if (!ino)
+		return NULL;
+
+	return d_obtain_alias(exofs_iget(child->d_inode->i_sb, ino));
+}
+
+static struct inode *exofs_nfs_get_inode(struct super_block *sb,
+		u64 ino, u32 generation)
+{
+	struct inode *inode;
+
+	inode = exofs_iget(sb, ino);
+	if (IS_ERR(inode))
+		return ERR_CAST(inode);
+	if (generation && inode->i_generation != generation) {
+		/* we didn't find the right inode.. */
+		iput(inode);
+		return ERR_PTR(-ESTALE);
+	}
+	return inode;
+}
+
+static struct dentry *exofs_fh_to_dentry(struct super_block *sb,
+				struct fid *fid, int fh_len, int fh_type)
+{
+	return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+				    exofs_nfs_get_inode);
+}
+
+static struct dentry *exofs_fh_to_parent(struct super_block *sb,
+				struct fid *fid, int fh_len, int fh_type)
+{
+	return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+				    exofs_nfs_get_inode);
+}
+
+const struct export_operations exofs_export_ops = {
+	.fh_to_dentry = exofs_fh_to_dentry,
+	.fh_to_parent = exofs_fh_to_parent,
+	.get_parent = exofs_get_parent,
+};
+
+/******************************************************************************
  * INSMOD/RMMOD
  *****************************************************************************/
 
-- 
1.6.2.1



      parent reply	other threads:[~2009-03-25 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25  9:45 [PATCHSET 0/3] exofs: Exportable by NFS Boaz Harrosh
2009-03-25  9:47 ` [PATCH 1/3] [SQUASHME] prints in hex Boaz Harrosh
2009-03-25  9:50 ` [PATCH 2/3] [SQUASHME] exofs does support 64bit file sizes Boaz Harrosh
2009-03-25 10:07 ` Boaz Harrosh [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=49CA0264.9070501@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=akpm@linux-foundation.org \
    --cc=jeff@garzik.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=osd-dev@open-osd.org \
    --cc=zbr@ioremap.net \
    /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).