From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 8/9] fuse: nfs export special lookups
Date: Fri, 09 May 2008 14:41:15 +0200 [thread overview]
Message-ID: <20080509124137.400676014@szeredi.hu> (raw)
In-Reply-To: <20080509124107.645600519@szeredi.hu>
[-- Attachment #1: fuse_nfs_export_lookup.patch --]
[-- Type: text/plain, Size: 5546 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Implement the get_parent export operation by sending a LOOKUP request
with ".." as the name.
Implement looking up an inode by node ID after it has been evicted
from the cache. This is done by seding a LOOKUP request with "." as
the name (for all file types, not just directories).
The filesystem can set the FUSE_EXPORT_SUPPORT flag in the INIT reply,
to indicate that it supports these special lookups.
Thanks to John Muir for the original implementation of this feature.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/fuse/fuse_i.h | 6 ++++
fs/fuse/inode.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++---
include/linux/fuse.h | 3 ++
3 files changed, 72 insertions(+), 3 deletions(-)
Index: linux-2.6/fs/fuse/fuse_i.h
===================================================================
--- linux-2.6.orig/fs/fuse/fuse_i.h 2008-05-09 14:04:50.000000000 +0200
+++ linux-2.6/fs/fuse/fuse_i.h 2008-05-09 14:04:51.000000000 +0200
@@ -363,6 +363,9 @@ struct fuse_conn {
/** Do not send separate SETATTR request before open(O_TRUNC) */
unsigned atomic_o_trunc : 1;
+ /** Filesystem supports NFS exporting. Only set in INIT */
+ unsigned export_support : 1;
+
/*
* The following bitfields are only for optimization purposes
* and hence races in setting them will not cause malfunction
@@ -473,6 +476,9 @@ struct inode *fuse_iget(struct super_blo
int generation, struct fuse_attr *attr,
u64 attr_valid, u64 attr_version);
+int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name,
+ struct fuse_entry_out *outarg, struct inode **inode);
+
/**
* Send FORGET command
*/
Index: linux-2.6/fs/fuse/inode.c
===================================================================
--- linux-2.6.orig/fs/fuse/inode.c 2008-05-09 14:04:50.000000000 +0200
+++ linux-2.6/fs/fuse/inode.c 2008-05-09 14:04:51.000000000 +0200
@@ -557,6 +557,7 @@ struct fuse_inode_handle
static struct dentry *fuse_get_dentry(struct super_block *sb,
struct fuse_inode_handle *handle)
{
+ struct fuse_conn *fc = get_fuse_conn_super(sb);
struct inode *inode;
struct dentry *entry;
int err = -ESTALE;
@@ -565,8 +566,27 @@ static struct dentry *fuse_get_dentry(st
goto out_err;
inode = ilookup5(sb, handle->nodeid, fuse_inode_eq, &handle->nodeid);
- if (!inode)
- goto out_err;
+ if (!inode) {
+ struct fuse_entry_out outarg;
+ struct qstr name;
+
+ if (!fc->export_support)
+ goto out_err;
+
+ name.len = 1;
+ name.name = ".";
+ err = fuse_lookup_name(sb, handle->nodeid, &name, &outarg,
+ &inode);
+ if (err && err != -ENOENT)
+ goto out_err;
+ if (err || !inode) {
+ err = -ESTALE;
+ goto out_err;
+ }
+ err = -EIO;
+ if (get_node_id(inode) != handle->nodeid)
+ goto out_iput;
+ }
err = -ESTALE;
if (inode->i_generation != handle->generation)
goto out_iput;
@@ -658,11 +678,46 @@ static struct dentry *fuse_fh_to_parent(
return fuse_get_dentry(sb, &parent);
}
+static struct dentry *fuse_get_parent(struct dentry *child)
+{
+ struct inode *child_inode = child->d_inode;
+ struct fuse_conn *fc = get_fuse_conn(child_inode);
+ struct inode *inode;
+ struct dentry *parent;
+ struct fuse_entry_out outarg;
+ struct qstr name;
+ int err;
+
+ if (!fc->export_support)
+ return ERR_PTR(-ESTALE);
+
+ name.len = 2;
+ name.name = "..";
+ err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode),
+ &name, &outarg, &inode);
+ if (err && err != -ENOENT)
+ return ERR_PTR(err);
+ if (err || !inode)
+ return ERR_PTR(-ESTALE);
+
+ parent = d_alloc_anon(inode);
+ if (!parent) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+ if (get_node_id(inode) != FUSE_ROOT_ID) {
+ parent->d_op = &fuse_dentry_operations;
+ fuse_invalidate_entry_cache(parent);
+ }
+
+ return parent;
+}
static const struct export_operations fuse_export_operations = {
.fh_to_dentry = fuse_fh_to_dentry,
.fh_to_parent = fuse_fh_to_parent,
.encode_fh = fuse_encode_fh,
+ .get_parent = fuse_get_parent,
};
static const struct super_operations fuse_super_operations = {
@@ -694,6 +749,11 @@ static void process_init_reply(struct fu
fc->no_lock = 1;
if (arg->flags & FUSE_ATOMIC_O_TRUNC)
fc->atomic_o_trunc = 1;
+ if (arg->minor >= 9) {
+ /* LOOKUP has dependency on proto version */
+ if (arg->flags & FUSE_EXPORT_SUPPORT)
+ fc->export_support = 1;
+ }
if (arg->flags & FUSE_BIG_WRITES)
fc->big_writes = 1;
} else {
@@ -720,7 +780,7 @@ static void fuse_send_init(struct fuse_c
arg->minor = FUSE_KERNEL_MINOR_VERSION;
arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
- FUSE_BIG_WRITES;
+ FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES;
req->in.h.opcode = FUSE_INIT;
req->in.numargs = 1;
req->in.args[0].size = sizeof(*arg);
Index: linux-2.6/include/linux/fuse.h
===================================================================
--- linux-2.6.orig/include/linux/fuse.h 2008-05-09 14:04:45.000000000 +0200
+++ linux-2.6/include/linux/fuse.h 2008-05-09 14:04:51.000000000 +0200
@@ -104,11 +104,14 @@ struct fuse_file_lock {
/**
* INIT request/reply flags
+ *
+ * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
*/
#define FUSE_ASYNC_READ (1 << 0)
#define FUSE_POSIX_LOCKS (1 << 1)
#define FUSE_FILE_OPS (1 << 2)
#define FUSE_ATOMIC_O_TRUNC (1 << 3)
+#define FUSE_EXPORT_SUPPORT (1 << 4)
#define FUSE_BIG_WRITES (1 << 5)
/**
--
next prev parent reply other threads:[~2008-05-09 12:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-09 12:41 [patch 0/9] file locking fixes + fuse nfs export support Miklos Szeredi
2008-05-09 12:41 ` [patch 1/9] lockd: dont return EAGAIN from blocking lock request Miklos Szeredi
2008-05-09 18:11 ` J. Bruce Fields
2008-05-09 18:30 ` Miklos Szeredi
2008-05-09 12:41 ` [patch 2/9] locks: add special return value for asynchronous locks Miklos Szeredi
2008-05-09 12:41 ` [patch 3/9] locks: cleanup code duplication Miklos Szeredi
2008-05-09 12:41 ` [patch 4/9] locks: allow ->lock() to return FILE_LOCK_DEFERRED Miklos Szeredi
2008-05-09 12:41 ` [patch 5/9] fuse: prepare lookup for nfs export Miklos Szeredi
2008-05-09 12:41 ` [patch 6/9] fuse: add export operations Miklos Szeredi
2008-05-09 19:40 ` Christoph Hellwig
2008-05-09 19:46 ` Christoph Hellwig
2008-05-13 8:34 ` Miklos Szeredi
2008-05-13 9:01 ` Christoph Hellwig
2008-05-15 13:07 ` Miklos Szeredi
2008-05-15 14:13 ` Christoph Hellwig
2008-05-09 20:02 ` Erez Zadok
2008-05-13 8:27 ` Miklos Szeredi
2008-05-09 12:41 ` [patch 7/9] fuse: add fuse_lookup_name() helper Miklos Szeredi
2008-05-09 12:41 ` Miklos Szeredi [this message]
2008-05-09 12:41 ` [patch 9/9] fuse: lockd support Miklos Szeredi
2008-05-09 15:50 ` [patch 0/9] file locking fixes + fuse nfs export support J. Bruce Fields
2008-05-09 15:58 ` Miklos Szeredi
2008-05-09 16:40 ` J. Bruce Fields
2008-05-13 21:05 ` Miklos Szeredi
2008-05-13 21:17 ` J. Bruce Fields
2008-05-13 21:21 ` Miklos Szeredi
2008-05-15 19:50 [patch 0/9] file locking fixes + fuse nfs export support (v2) Miklos Szeredi
2008-05-15 19:50 ` [patch 8/9] fuse: nfs export special lookups Miklos Szeredi
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=20080509124137.400676014@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--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®