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>
|
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"
|
|
|
|
|
2007-02-12 01:55:41 -07:00
|
|
|
static const struct super_operations v9fs_super_ops;
|
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
|
2008-03-05 06:08:09 -07:00
|
|
|
* @flags: flags propagated from v9fs_get_sb()
|
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;
|
|
|
|
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
|
|
|
|
|
|
|
save_mount_options(sb, data);
|
2005-09-09 14:04:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v9fs_get_sb - mount a superblock
|
|
|
|
* @fs_type: file system type
|
|
|
|
* @flags: mount flags
|
|
|
|
* @dev_name: device name that was mounted
|
|
|
|
* @data: mount options
|
[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
|
|
|
* @mnt: mountpoint record to be instantiated
|
2005-09-09 14:04:20 -06:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
[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
|
|
|
static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
|
|
|
|
const char *dev_name, void *data,
|
|
|
|
struct vfsmount *mnt)
|
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;
|
2008-10-16 07:30:07 -06:00
|
|
|
struct p9_wstat *st = NULL;
|
2005-09-09 14:04:20 -06:00
|
|
|
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)
|
[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
|
|
|
return -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);
|
2008-05-08 19:26:37 -06:00
|
|
|
goto close_session;
|
2007-07-10 16:57:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
st = p9_client_stat(fid);
|
|
|
|
if (IS_ERR(st)) {
|
|
|
|
retval = PTR_ERR(st);
|
2008-05-08 19:26:37 -06:00
|
|
|
goto clunk_fid;
|
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);
|
2008-05-08 19:26:37 -06:00
|
|
|
goto free_stat;
|
[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
|
|
|
|
|
|
|
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;
|
2007-07-10 16:57:28 -06:00
|
|
|
root->d_inode->i_ino = v9fs_qid2ino(&st->qid);
|
2008-10-16 07:30:07 -06:00
|
|
|
|
2007-07-10 16:57:28 -06:00
|
|
|
v9fs_stat2inode(st, root->d_inode, sb);
|
2008-10-16 07:30:07 -06:00
|
|
|
|
2007-07-10 16:57:28 -06:00
|
|
|
v9fs_fid_add(root, fid);
|
2008-10-16 07:30:07 -06:00
|
|
|
p9stat_free(st);
|
2007-11-06 07:02:53 -07:00
|
|
|
kfree(st);
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2009-03-04 13:06:34 -07:00
|
|
|
P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
|
|
|
|
simple_set_mnt(mnt, sb);
|
|
|
|
return 0;
|
2005-09-09 14:04:20 -06:00
|
|
|
|
2008-05-08 19:26:37 -06:00
|
|
|
free_stat:
|
2009-07-19 13:41:52 -06:00
|
|
|
p9stat_free(st);
|
2008-05-08 19:26:37 -06:00
|
|
|
kfree(st);
|
|
|
|
|
|
|
|
clunk_fid:
|
|
|
|
p9_client_clunk(fid);
|
|
|
|
|
|
|
|
close_session:
|
|
|
|
v9fs_session_close(v9ses);
|
|
|
|
kfree(v9ses);
|
2009-07-19 13:41:52 -06:00
|
|
|
return retval;
|
2008-05-08 19:26:37 -06:00
|
|
|
|
2009-07-19 13:41:52 -06:00
|
|
|
release_sb:
|
|
|
|
p9stat_free(st);
|
|
|
|
kfree(st);
|
|
|
|
deactivate_locked_super(sb);
|
[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
|
|
|
return 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
|
|
|
|
2010-01-25 04:16:19 -07:00
|
|
|
if (s->s_root)
|
|
|
|
v9fs_dentry_release(s->s_root); /* clunk root */
|
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
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
.clear_inode = v9fs_clear_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
|
|
|
};
|
|
|
|
|
|
|
|
struct file_system_type v9fs_fs_type = {
|
2006-03-25 04:07:29 -07:00
|
|
|
.name = "9p",
|
2005-09-09 14:04:20 -06:00
|
|
|
.get_sb = v9fs_get_sb,
|
|
|
|
.kill_sb = v9fs_kill_super,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
};
|