2005-09-09 14:04:20 -06:00
|
|
|
/*
|
|
|
|
* linux/fs/9p/vfs_super.c
|
|
|
|
*
|
|
|
|
* This file contians superblock ops for 9P2000. It is intended that
|
|
|
|
* you mount this file system on directories.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
|
|
|
|
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2006-03-25 04:07:28 -07:00
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
2005-09-09 14:04:20 -06:00
|
|
|
*
|
|
|
|
* 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/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/inet.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/mount.h>
|
|
|
|
#include <linux/idr.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-20 15:22:52 -06:00
|
|
|
#include <linux/sched.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2010-03-25 06:45:30 -06:00
|
|
|
#include <linux/statfs.h>
|
2010-09-27 02:47:24 -06:00
|
|
|
#include <linux/magic.h>
|
2007-07-10 16:57:28 -06:00
|
|
|
#include <net/9p/9p.h>
|
|
|
|
#include <net/9p/client.h>
|
2005-09-09 14:04:20 -06:00
|
|
|
|
|
|
|
#include "v9fs.h"
|
|
|
|
#include "v9fs_vfs.h"
|
|
|
|
#include "fid.h"
|
2010-05-31 01:52:56 -06:00
|
|
|
#include "xattr.h"
|
2010-09-27 12:57:39 -06:00
|
|
|
#include "acl.h"
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2010-03-25 06:41:54 -06:00
|
|
|
static const struct super_operations v9fs_super_ops, v9fs_super_ops_dotl;
|
2005-09-09 14:04:20 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v9fs_set_super - set the superblock
|
|
|
|
* @s: super block
|
|
|
|
* @data: file system specific data
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int v9fs_set_super(struct super_block *s, void *data)
|
|
|
|
{
|
|
|
|
s->s_fs_info = data;
|
|
|
|
return set_anon_super(s, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v9fs_fill_super - populate superblock with info
|
|
|
|
* @sb: superblock
|
|
|
|
* @v9ses: session information
|
2010-07-25 13:56:43 -06:00
|
|
|
* @flags: flags propagated from v9fs_mount()
|
2005-09-09 14:04:20 -06:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
|
2009-08-17 15:42:28 -06:00
|
|
|
int flags, void *data)
|
2005-09-09 14:04:20 -06:00
|
|
|
{
|
|
|
|
sb->s_maxbytes = MAX_LFS_FILESIZE;
|
|
|
|
sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
|
|
|
|
sb->s_blocksize = 1 << sb->s_blocksize_bits;
|
|
|
|
sb->s_magic = V9FS_MAGIC;
|
2010-05-31 01:52:56 -06:00
|
|
|
if (v9fs_proto_dotl(v9ses)) {
|
2010-03-25 06:41:54 -06:00
|
|
|
sb->s_op = &v9fs_super_ops_dotl;
|
2010-05-31 01:52:56 -06:00
|
|
|
sb->s_xattr = v9fs_xattr_handlers;
|
|
|
|
} else
|
2010-03-25 06:41:54 -06:00
|
|
|
sb->s_op = &v9fs_super_ops;
|
2010-04-22 03:42:00 -06:00
|
|
|
sb->s_bdi = &v9ses->bdi;
|
2005-09-09 14:04:20 -06:00
|
|
|
|
|
|
|
sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
|
2006-01-09 21:52:15 -07:00
|
|
|
MS_NOATIME;
|
2009-08-17 15:42:28 -06:00
|
|
|
|
2010-09-27 12:57:39 -06:00
|
|
|
#ifdef CONFIG_9P_FS_POSIX_ACL
|
2010-09-27 12:57:41 -06:00
|
|
|
if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)
|
|
|
|
sb->s_flags |= MS_POSIXACL;
|
2010-09-27 12:57:39 -06:00
|
|
|
#endif
|
|
|
|
|
2009-08-17 15:42:28 -06:00
|
|
|
save_mount_options(sb, data);
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-25 13:56:43 -06:00
|
|
|
* v9fs_mount - mount a superblock
|
2005-09-09 14:04:20 -06:00
|
|
|
* @fs_type: file system type
|
|
|
|
* @flags: mount flags
|
|
|
|
* @dev_name: device name that was mounted
|
|
|
|
* @data: mount options
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-25 13:56:43 -06:00
|
|
|
static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
|
|
|
|
const char *dev_name, void *data)
|
2005-09-09 14:04:20 -06:00
|
|
|
{
|
|
|
|
struct super_block *sb = NULL;
|
|
|
|
struct inode *inode = NULL;
|
|
|
|
struct dentry *root = NULL;
|
|
|
|
struct v9fs_session_info *v9ses = NULL;
|
|
|
|
int mode = S_IRWXUGO | S_ISVTX;
|
2007-07-10 16:57:28 -06:00
|
|
|
struct p9_fid *fid;
|
2005-09-09 14:04:20 -06:00
|
|
|
int retval = 0;
|
|
|
|
|
2007-07-10 16:57:28 -06:00
|
|
|
P9_DPRINTK(P9_DEBUG_VFS, " \n");
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2006-01-08 02:05:02 -07:00
|
|
|
v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL);
|
2005-09-09 14:04:20 -06:00
|
|
|
if (!v9ses)
|
2010-07-25 13:56:43 -06:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2007-07-10 16:57:28 -06:00
|
|
|
fid = v9fs_session_init(v9ses, dev_name, data);
|
|
|
|
if (IS_ERR(fid)) {
|
|
|
|
retval = PTR_ERR(fid);
|
2010-08-24 04:30:49 -06:00
|
|
|
/*
|
|
|
|
* we need to call session_close to tear down some
|
|
|
|
* of the data structure setup by session_init
|
|
|
|
*/
|
2008-05-08 19:26:37 -06:00
|
|
|
goto close_session;
|
2007-07-10 16:57:28 -06:00
|
|
|
}
|
|
|
|
|
2005-09-09 14:04:20 -06:00
|
|
|
sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 03:02:57 -06:00
|
|
|
if (IS_ERR(sb)) {
|
|
|
|
retval = PTR_ERR(sb);
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 08:37:23 -06:00
|
|
|
goto clunk_fid;
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 03:02:57 -06:00
|
|
|
}
|
2009-08-17 15:42:28 -06:00
|
|
|
v9fs_fill_super(sb, v9ses, flags, data);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2011-01-12 15:10:55 -07:00
|
|
|
if (v9ses->cache)
|
|
|
|
sb->s_d_op = &v9fs_cached_dentry_operations;
|
|
|
|
else
|
|
|
|
sb->s_d_op = &v9fs_dentry_operations;
|
|
|
|
|
2005-09-09 14:04:20 -06:00
|
|
|
inode = v9fs_get_inode(sb, S_IFDIR | mode);
|
|
|
|
if (IS_ERR(inode)) {
|
|
|
|
retval = PTR_ERR(inode);
|
2008-05-08 19:26:37 -06:00
|
|
|
goto release_sb;
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
root = d_alloc_root(inode);
|
|
|
|
if (!root) {
|
2009-05-05 23:35:04 -06:00
|
|
|
iput(inode);
|
2005-09-09 14:04:20 -06:00
|
|
|
retval = -ENOMEM;
|
2008-05-08 19:26:37 -06:00
|
|
|
goto release_sb;
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
sb->s_root = root;
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 08:37:23 -06:00
|
|
|
if (v9fs_proto_dotl(v9ses)) {
|
|
|
|
struct p9_stat_dotl *st = NULL;
|
|
|
|
st = p9_client_getattr_dotl(fid, P9_STATS_BASIC);
|
|
|
|
if (IS_ERR(st)) {
|
|
|
|
retval = PTR_ERR(st);
|
2010-08-24 04:30:49 -06:00
|
|
|
goto release_sb;
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 08:37:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
v9fs_stat2inode_dotl(st, root->d_inode);
|
|
|
|
kfree(st);
|
|
|
|
} else {
|
|
|
|
struct p9_wstat *st = NULL;
|
|
|
|
st = p9_client_stat(fid);
|
|
|
|
if (IS_ERR(st)) {
|
|
|
|
retval = PTR_ERR(st);
|
2010-08-24 04:30:49 -06:00
|
|
|
goto release_sb;
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 08:37:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
root->d_inode->i_ino = v9fs_qid2ino(&st->qid);
|
|
|
|
v9fs_stat2inode(st, root->d_inode, sb);
|
|
|
|
|
|
|
|
p9stat_free(st);
|
|
|
|
kfree(st);
|
|
|
|
}
|
2010-09-27 12:57:39 -06:00
|
|
|
retval = v9fs_get_acl(inode, fid);
|
|
|
|
if (retval)
|
|
|
|
goto release_sb;
|
2007-07-10 16:57:28 -06:00
|
|
|
v9fs_fid_add(root, fid);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2010-08-24 04:30:49 -06:00
|
|
|
P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
|
2010-07-25 13:56:43 -06:00
|
|
|
return dget(sb->s_root);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2008-05-08 19:26:37 -06:00
|
|
|
clunk_fid:
|
|
|
|
p9_client_clunk(fid);
|
|
|
|
close_session:
|
|
|
|
v9fs_session_close(v9ses);
|
|
|
|
kfree(v9ses);
|
2010-07-25 13:56:43 -06:00
|
|
|
return ERR_PTR(retval);
|
|
|
|
|
2009-07-19 13:41:52 -06:00
|
|
|
release_sb:
|
2010-08-24 04:30:49 -06:00
|
|
|
/*
|
|
|
|
* we will do the session_close and root dentry release
|
|
|
|
* in the below call. But we need to clunk fid, because we haven't
|
|
|
|
* attached the fid to dentry so it won't get clunked
|
|
|
|
* automatically.
|
|
|
|
*/
|
|
|
|
p9_client_clunk(fid);
|
2009-07-19 13:41:52 -06:00
|
|
|
deactivate_locked_super(sb);
|
2010-07-25 13:56:43 -06:00
|
|
|
return ERR_PTR(retval);
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v9fs_kill_super - Kill Superblock
|
|
|
|
* @s: superblock
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void v9fs_kill_super(struct super_block *s)
|
|
|
|
{
|
|
|
|
struct v9fs_session_info *v9ses = s->s_fs_info;
|
|
|
|
|
2007-07-10 16:57:28 -06:00
|
|
|
P9_DPRINTK(P9_DEBUG_VFS, " %p\n", s);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
|
|
|
kill_anon_super(s);
|
|
|
|
|
2010-03-29 17:13:59 -06:00
|
|
|
v9fs_session_cancel(v9ses);
|
2005-09-09 14:04:20 -06:00
|
|
|
v9fs_session_close(v9ses);
|
|
|
|
kfree(v9ses);
|
2009-07-19 13:41:52 -06:00
|
|
|
s->s_fs_info = NULL;
|
2007-07-10 16:57:28 -06:00
|
|
|
P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n");
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
|
2005-09-09 14:04:23 -06:00
|
|
|
static void
|
2008-04-24 05:21:56 -06:00
|
|
|
v9fs_umount_begin(struct super_block *sb)
|
2005-09-09 14:04:23 -06:00
|
|
|
{
|
2009-04-24 01:06:53 -06:00
|
|
|
struct v9fs_session_info *v9ses;
|
2005-09-09 14:04:23 -06:00
|
|
|
|
2009-04-24 01:06:53 -06:00
|
|
|
v9ses = sb->s_fs_info;
|
2010-03-29 17:13:59 -06:00
|
|
|
v9fs_session_begin_cancel(v9ses);
|
2005-09-09 14:04:23 -06:00
|
|
|
}
|
|
|
|
|
2010-03-25 06:45:30 -06:00
|
|
|
static int v9fs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
|
|
|
{
|
|
|
|
struct v9fs_session_info *v9ses;
|
|
|
|
struct p9_fid *fid;
|
|
|
|
struct p9_rstatfs rs;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
fid = v9fs_fid_lookup(dentry);
|
|
|
|
if (IS_ERR(fid)) {
|
|
|
|
res = PTR_ERR(fid);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
v9ses = v9fs_inode2v9ses(dentry->d_inode);
|
|
|
|
if (v9fs_proto_dotl(v9ses)) {
|
|
|
|
res = p9_client_statfs(fid, &rs);
|
|
|
|
if (res == 0) {
|
2010-09-27 02:47:24 -06:00
|
|
|
buf->f_type = V9FS_MAGIC;
|
2010-03-25 06:45:30 -06:00
|
|
|
buf->f_bsize = rs.bsize;
|
|
|
|
buf->f_blocks = rs.blocks;
|
|
|
|
buf->f_bfree = rs.bfree;
|
|
|
|
buf->f_bavail = rs.bavail;
|
|
|
|
buf->f_files = rs.files;
|
|
|
|
buf->f_ffree = rs.ffree;
|
|
|
|
buf->f_fsid.val[0] = rs.fsid & 0xFFFFFFFFUL;
|
|
|
|
buf->f_fsid.val[1] = (rs.fsid >> 32) & 0xFFFFFFFFUL;
|
|
|
|
buf->f_namelen = rs.namelen;
|
|
|
|
}
|
|
|
|
if (res != -ENOSYS)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
res = simple_statfs(dentry, buf);
|
|
|
|
done:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-02-12 01:55:41 -07:00
|
|
|
static const struct super_operations v9fs_super_ops = {
|
2009-09-23 12:00:27 -06:00
|
|
|
#ifdef CONFIG_9P_FSCACHE
|
|
|
|
.alloc_inode = v9fs_alloc_inode,
|
|
|
|
.destroy_inode = v9fs_destroy_inode,
|
|
|
|
#endif
|
2005-09-09 14:04:20 -06:00
|
|
|
.statfs = simple_statfs,
|
2010-06-07 12:34:48 -06:00
|
|
|
.evict_inode = v9fs_evict_inode,
|
2009-08-17 15:42:28 -06:00
|
|
|
.show_options = generic_show_options,
|
2005-09-09 14:04:23 -06:00
|
|
|
.umount_begin = v9fs_umount_begin,
|
2005-09-09 14:04:20 -06:00
|
|
|
};
|
|
|
|
|
2010-03-25 06:41:54 -06:00
|
|
|
static const struct super_operations v9fs_super_ops_dotl = {
|
|
|
|
#ifdef CONFIG_9P_FSCACHE
|
|
|
|
.alloc_inode = v9fs_alloc_inode,
|
|
|
|
.destroy_inode = v9fs_destroy_inode,
|
|
|
|
#endif
|
2010-03-25 06:45:30 -06:00
|
|
|
.statfs = v9fs_statfs,
|
2010-06-07 12:34:48 -06:00
|
|
|
.evict_inode = v9fs_evict_inode,
|
2010-03-25 06:41:54 -06:00
|
|
|
.show_options = generic_show_options,
|
|
|
|
.umount_begin = v9fs_umount_begin,
|
|
|
|
};
|
|
|
|
|
2005-09-09 14:04:20 -06:00
|
|
|
struct file_system_type v9fs_fs_type = {
|
2006-03-25 04:07:29 -07:00
|
|
|
.name = "9p",
|
2010-07-25 13:56:43 -06:00
|
|
|
.mount = v9fs_mount,
|
2005-09-09 14:04:20 -06:00
|
|
|
.kill_sb = v9fs_kill_super,
|
|
|
|
.owner = THIS_MODULE,
|
2010-06-30 07:48:50 -06:00
|
|
|
.fs_flags = FS_RENAME_DOES_D_MOVE,
|
2005-09-09 14:04:20 -06:00
|
|
|
};
|