* [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport
@ 2005-07-28 13:57 ericvh
2005-07-28 14:17 ` Christoph Hellwig
2005-07-28 14:38 ` [V9fs-developer] " Russ Cox
0 siblings, 2 replies; 5+ messages in thread
From: ericvh @ 2005-07-28 13:57 UTC (permalink / raw)
To: linux-kernel; +Cc: v9fs-developer, akpm, linux-fsdevel
v9fs: add file-descriptor based transport as was requested by LANL and
Plan 9 from User Space folks.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
---
commit e65b41c8081e0f7227a16d39a4bc65e2924d7680
tree 4cfd78c690d2e9852736499fe9d0a311c78beee8
parent eefccf73f82b2bdf353cd05b8e5d6142210bc80f
author Eric Van Hensbergen <ericvh@gmail.com> Thu, 28 Jul 2005 08:45:14 -0500
committer Eric Van Hensbergen <ericvh@gmail.com> Thu, 28 Jul 2005 08:45:14 -0500
Documentation/filesystems/v9fs.txt | 13 +++
fs/9p/Makefile | 1
fs/9p/trans_fd.c | 136 ++++++++++++++++++++++++++++++++++++
fs/9p/transport.h | 1
fs/9p/v9fs.c | 27 +++++++
fs/9p/v9fs.h | 4 +
6 files changed, 178 insertions(+), 4 deletions(-)
diff --git a/Documentation/filesystems/v9fs.txt b/Documentation/filesystems/v9fs.txt
--- a/Documentation/filesystems/v9fs.txt
+++ b/Documentation/filesystems/v9fs.txt
@@ -26,9 +26,12 @@ OPTIONS
=======
proto=name select an alternative transport. Valid options are
- currently either unix (specifying a named pipe mount
- point) or tcp (specifying a normal TCP/IP connection)
-
+ currently:
+ unix - specifying a named pipe mount point
+ tcp - specifying a normal TCP/IP connection
+ fd - used passed file descriptors for connection
+ (see rfdno and wfdno)
+
name=name user name to attempt mount as on the remote server. The
server may override or ignore this value. Certain user
names may require authentication.
@@ -46,6 +49,10 @@ OPTIONS
0x40 = display transport debug
0x80 = display allocation debug
+ rfdno=n the file descriptor for reading with proto=fd
+
+ wfdno=n the file descriptor for writing with proto=fd
+
maxdata=n the number of bytes to use for 9P packet payload (msize)
port=n port to connect to on the remote server
diff --git a/fs/9p/Makefile b/fs/9p/Makefile
--- a/fs/9p/Makefile
+++ b/fs/9p/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_9P_FS) := 9p2000.o
vfs_dentry.o \
error.o \
mux.o \
+ trans_fd.o \
trans_sock.o \
9p.o \
conv.o \
diff --git a/fs/9p/trans_fd.c b/fs/9p/trans_fd.c
new file mode 100644
--- /dev/null
+++ b/fs/9p/trans_fd.c
@@ -0,0 +1,136 @@
+/*
+ * linux/fs/9p/trans_fd.c
+ *
+ * File Descriptor Transport Layer
+ *
+ * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to:
+ * Free Software Foundation
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02111-1301 USA
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/net.h>
+#include <linux/ipv6.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/un.h>
+#include <asm/uaccess.h>
+#include <linux/inet.h>
+#include <linux/idr.h>
+#include <linux/file.h>
+
+#include "debug.h"
+#include "v9fs.h"
+#include "transport.h"
+
+struct v9fs_trans_fd {
+ struct file *in_file;
+ struct file *out_file;
+};
+
+/**
+ * v9fs_fd_recv - receive from a socket
+ * @v9ses: session information
+ * @v: buffer to receive data into
+ * @len: size of receive buffer
+ *
+ */
+
+static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len)
+{
+ struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
+
+ return kernel_read(ts->in_file, ts->in_file->f_pos, v, len);
+}
+
+/**
+ * v9fs_fd_send - send to a socket
+ * @v9ses: session information
+ * @v: buffer to send data from
+ * @len: size of send buffer
+ *
+ */
+
+static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len)
+{
+ struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
+ mm_segment_t oldfs = get_fs();
+ int ret = 0;
+
+ set_fs(get_ds());
+ /* The cast to a user pointer is valid due to the set_fs() */
+ ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos);
+ set_fs(oldfs);
+
+ return ret;
+}
+
+/**
+ * v9fs_fd_init - initialize file descriptor transport
+ * @v9ses: session information
+ * @addr: address of server to mount
+ * @data: mount options
+ *
+ */
+
+static int
+v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
+{
+ struct v9fs_trans_fd *ts = NULL;
+ struct v9fs_transport *trans = v9ses->transport;
+
+ sema_init(&trans->writelock, 1);
+ sema_init(&trans->readlock, 1);
+
+ ts = kmalloc(sizeof(struct v9fs_trans_fd), GFP_KERNEL);
+
+ if (!ts)
+ return -ENOMEM;
+
+ trans->priv = ts;
+
+ ts->in_file = fget( v9ses->rfdno );
+ ts->out_file = fget( v9ses->wfdno );
+
+ trans->status = Connected;
+
+ return 0;
+}
+
+
+/**
+ * v9fs_fd_close - shutdown file descriptor
+ * @trans: private socket structure
+ *
+ */
+
+static void v9fs_fd_close(struct v9fs_transport *trans)
+{
+ struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
+
+ kfree(ts);
+}
+
+struct v9fs_transport v9fs_trans_fd = {
+ .init = v9fs_fd_init,
+ .write = v9fs_fd_send,
+ .read = v9fs_fd_recv,
+ .close = v9fs_fd_close,
+};
+
diff --git a/fs/9p/transport.h b/fs/9p/transport.h
--- a/fs/9p/transport.h
+++ b/fs/9p/transport.h
@@ -43,3 +43,4 @@ struct v9fs_transport {
extern struct v9fs_transport v9fs_trans_tcp;
extern struct v9fs_transport v9fs_trans_unix;
+extern struct v9fs_transport v9fs_trans_fd;
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -50,10 +50,11 @@ int v9fs_debug_level = 0; /* feature-rif
enum {
/* Options that take integer arguments */
Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug,
+ Opt_rfdno, Opt_wfdno,
/* String options */
Opt_name, Opt_remotename,
/* Options that take no arguments */
- Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp,
+ Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd,
/* Error token */
Opt_err
};
@@ -64,13 +65,17 @@ static match_table_t tokens = {
{Opt_uid, "uid=%u"},
{Opt_gid, "gid=%u"},
{Opt_afid, "afid=%u"},
+ {Opt_rfdno, "rfdno=%u"},
+ {Opt_wfdno, "wfdno=%u"},
{Opt_debug, "debug=%u"},
{Opt_name, "name=%s"},
{Opt_remotename, "aname=%s"},
{Opt_unix, "proto=unix"},
{Opt_tcp, "proto=tcp"},
+ {Opt_fd, "proto=fd"},
{Opt_tcp, "tcp"},
{Opt_unix, "unix"},
+ {Opt_fd, "fd"},
{Opt_legacy, "noextend"},
{Opt_nodevmap, "nodevmap"},
{Opt_err, NULL}
@@ -101,6 +106,8 @@ static void v9fs_parse_options(char *opt
v9ses->extended = 1;
v9ses->afid = ~0;
v9ses->debug = 0;
+ v9ses->rfdno = ~0;
+ v9ses->wfdno = ~0;
if (!options)
return;
@@ -134,6 +141,12 @@ static void v9fs_parse_options(char *opt
case Opt_afid:
v9ses->afid = option;
break;
+ case Opt_rfdno:
+ v9ses->rfdno = option;
+ break;
+ case Opt_wfdno:
+ v9ses->wfdno = option;
+ break;
case Opt_debug:
v9ses->debug = option;
break;
@@ -143,6 +156,9 @@ static void v9fs_parse_options(char *opt
case Opt_unix:
v9ses->proto = PROTO_UNIX;
break;
+ case Opt_fd:
+ v9ses->proto = PROTO_FD;
+ break;
case Opt_name:
match_strcpy(v9ses->name, &args[0]);
break;
@@ -277,6 +293,15 @@ v9fs_session_init(struct v9fs_session_in
trans_proto = &v9fs_trans_unix;
*v9ses->remotename = 0;
break;
+ case PROTO_FD:
+ trans_proto = &v9fs_trans_fd;
+ *v9ses->remotename = 0;
+ if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) {
+ printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n");
+ retval = -ENOPROTOOPT;
+ goto SessCleanUp;
+ }
+ break;
default:
printk(KERN_ERR "v9fs: Bad mount protocol %d\n", v9ses->proto);
retval = -ENOPROTOOPT;
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -46,6 +46,9 @@ struct v9fs_session_info {
unsigned short debug; /* debug level */
unsigned short proto; /* protocol to use */
unsigned int afid; /* authentication fid */
+ unsigned int rfdno; /* read file descriptor number */
+ unsigned int wfdno; /* write file descriptor number */
+
char *name; /* user name to mount as */
char *remotename; /* name of remote hierarchy being mounted */
@@ -78,6 +81,7 @@ struct v9fs_session_info {
enum {
PROTO_TCP,
PROTO_UNIX,
+ PROTO_FD,
};
int v9fs_session_init(struct v9fs_session_info *, const char *, char *);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport
2005-07-28 13:57 [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport ericvh
@ 2005-07-28 14:17 ` Christoph Hellwig
2005-07-28 14:19 ` [V9fs-developer] " Ronald G. Minnich
2005-07-28 14:38 ` [V9fs-developer] " Russ Cox
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2005-07-28 14:17 UTC (permalink / raw)
To: ericvh; +Cc: linux-kernel, v9fs-developer, akpm, linux-fsdevel
On Thu, Jul 28, 2005 at 08:57:23AM -0500, ericvh@gmail.com wrote:
> v9fs: add file-descriptor based transport as was requested by LANL and
> Plan 9 from User Space folks.
Couldn't the two other transports be implemented ontop of this one using
a mount helper doing the pipe or tcp setup?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [V9fs-developer] Re: [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport
2005-07-28 14:17 ` Christoph Hellwig
@ 2005-07-28 14:19 ` Ronald G. Minnich
2005-07-28 18:14 ` Eric Van Hensbergen
0 siblings, 1 reply; 5+ messages in thread
From: Ronald G. Minnich @ 2005-07-28 14:19 UTC (permalink / raw)
To: Christoph Hellwig
Cc: ericvh, linux-kernel, v9fs-developer, akpm, linux-fsdevel
On Thu, 28 Jul 2005, Christoph Hellwig wrote:
> Couldn't the two other transports be implemented ontop of this one using
> a mount helper doing the pipe or tcp setup?
that's how we did it in the version we did for 2.4. I don't see why not.
ron
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [V9fs-developer] Re: [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport
2005-07-28 14:19 ` [V9fs-developer] " Ronald G. Minnich
@ 2005-07-28 18:14 ` Eric Van Hensbergen
0 siblings, 0 replies; 5+ messages in thread
From: Eric Van Hensbergen @ 2005-07-28 18:14 UTC (permalink / raw)
To: Ronald G. Minnich
Cc: Christoph Hellwig, linux-kernel, v9fs-developer, akpm,
linux-fsdevel
On 7/28/05, Ronald G. Minnich <rminnich@lanl.gov> wrote:
>
>
> On Thu, 28 Jul 2005, Christoph Hellwig wrote:
>
> > Couldn't the two other transports be implemented ontop of this one using
> > a mount helper doing the pipe or tcp setup?
>
> that's how we did it in the version we did for 2.4. I don't see why not.
>
I strayed away from doing it this way originally for two reasons -
perhaps both are not really valid:
a) I really disliked requiring a helper application to mount a file
system. I really wanted to be able to boot a diskless system with no
initrd and have just 9P serving root. I figured if I could enable
people to use 9P without having a helper app, it would be used by more
folks -- of course the need for things like DNS resolution, etc. that
helper apps tend to provide sort of invalidates this piece of things.
b) I was concerned with additional copy overhead - one of the other
transports which isn't published yet uses shared memory (to
virtualized partitions) and it just seemed easier to deal with that in
the kernel rather than punting to a user-level application -- so in
short, I figured keeping the transport modules in the kernel made
sense. Of course, that doesn't have anything to do with the socket
interfaces being in the kernel -- I don't think there is any
additional copy overhead when using an fd versus a sock.
That being said, many things may be much easier with a user-level
helper - have user level security modules for instance.
I guess I'm not opposed to removing the TCP and named-pipe transports
if folks think that's a reasonable thing to do -- but I'd like to keep
the modular transport infrastructure to support things like the shared
memory transport. Of course we also need to get our act in gear and
make a reasonable mount-helper application available -- we've got
three versions right now and two of them rely on the Plan 9 from User
Space packages.
Anybody against taking this path?
-eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [V9fs-developer] [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport
2005-07-28 13:57 [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport ericvh
2005-07-28 14:17 ` Christoph Hellwig
@ 2005-07-28 14:38 ` Russ Cox
1 sibling, 0 replies; 5+ messages in thread
From: Russ Cox @ 2005-07-28 14:38 UTC (permalink / raw)
To: ericvh@gmail.com; +Cc: linux-kernel, v9fs-developer, akpm, linux-fsdevel
> +static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len)
> +{
> + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
> +
> + return kernel_read(ts->in_file, ts->in_file->f_pos, v, len);
> +}
> +static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len)
> +{
> + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
> + mm_segment_t oldfs = get_fs();
> + int ret = 0;
> +
> + set_fs(get_ds());
> + /* The cast to a user pointer is valid due to the set_fs() */
> + ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos);
> + set_fs(oldfs);
> +
> + return ret;
> +}
Perhaps there should be a kernel_write provided by the kernel?
Russ
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-07-28 18:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-28 13:57 [PATCH 2.6.13-rc3-mm2] v9fs: add fd based transport ericvh
2005-07-28 14:17 ` Christoph Hellwig
2005-07-28 14:19 ` [V9fs-developer] " Ronald G. Minnich
2005-07-28 18:14 ` Eric Van Hensbergen
2005-07-28 14:38 ` [V9fs-developer] " Russ Cox
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).