2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000-2001 Christoph Hellwig.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL").
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Veritas filesystem driver - superblock related routines.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/vfs.h>
|
2006-06-23 05:02:58 -04:00
|
|
|
#include <linux/mount.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
#include "vxfs.h"
|
|
|
|
#include "vxfs_extern.h"
|
|
|
|
#include "vxfs_dir.h"
|
|
|
|
#include "vxfs_inode.h"
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Christoph Hellwig");
|
|
|
|
MODULE_DESCRIPTION("Veritas Filesystem (VxFS) driver");
|
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
|
|
|
|
|
|
|
MODULE_ALIAS("vxfs"); /* makes mount -t vxfs autoload the module */
|
|
|
|
|
|
|
|
|
|
|
|
static void vxfs_put_super(struct super_block *);
|
2006-06-23 05:02:58 -04:00
|
|
|
static int vxfs_statfs(struct dentry *, struct kstatfs *);
|
2005-04-16 18:20:36 -04:00
|
|
|
static int vxfs_remount(struct super_block *, int *, char *);
|
|
|
|
|
2007-02-12 03:55:41 -05:00
|
|
|
static const struct super_operations vxfs_super_ops = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.read_inode = vxfs_read_inode,
|
|
|
|
.clear_inode = vxfs_clear_inode,
|
|
|
|
.put_super = vxfs_put_super,
|
|
|
|
.statfs = vxfs_statfs,
|
|
|
|
.remount_fs = vxfs_remount,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* vxfs_put_super - free superblock resources
|
|
|
|
* @sbp: VFS superblock.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* vxfs_put_super frees all resources allocated for @sbp
|
|
|
|
* after the last instance of the filesystem is unmounted.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
vxfs_put_super(struct super_block *sbp)
|
|
|
|
{
|
|
|
|
struct vxfs_sb_info *infp = VXFS_SBI(sbp);
|
|
|
|
|
|
|
|
vxfs_put_fake_inode(infp->vsi_fship);
|
|
|
|
vxfs_put_fake_inode(infp->vsi_ilist);
|
|
|
|
vxfs_put_fake_inode(infp->vsi_stilist);
|
|
|
|
|
|
|
|
brelse(infp->vsi_bp);
|
|
|
|
kfree(infp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* vxfs_statfs - get filesystem information
|
2006-06-23 05:02:58 -04:00
|
|
|
* @dentry: VFS dentry to locate superblock
|
2005-04-16 18:20:36 -04:00
|
|
|
* @bufp: output buffer
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* vxfs_statfs fills the statfs buffer @bufp with information
|
2006-06-23 05:02:58 -04:00
|
|
|
* about the filesystem described by @dentry.
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Zero.
|
|
|
|
*
|
|
|
|
* Locking:
|
|
|
|
* No locks held.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This is everything but complete...
|
|
|
|
*/
|
|
|
|
static int
|
2006-06-23 05:02:58 -04:00
|
|
|
vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2006-06-23 05:02:58 -04:00
|
|
|
struct vxfs_sb_info *infp = VXFS_SBI(dentry->d_sb);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
bufp->f_type = VXFS_SUPER_MAGIC;
|
2006-06-23 05:02:58 -04:00
|
|
|
bufp->f_bsize = dentry->d_sb->s_blocksize;
|
2005-04-16 18:20:36 -04:00
|
|
|
bufp->f_blocks = infp->vsi_raw->vs_dsize;
|
|
|
|
bufp->f_bfree = infp->vsi_raw->vs_free;
|
|
|
|
bufp->f_bavail = 0;
|
|
|
|
bufp->f_files = 0;
|
|
|
|
bufp->f_ffree = infp->vsi_raw->vs_ifree;
|
|
|
|
bufp->f_namelen = VXFS_NAMELEN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vxfs_remount(struct super_block *sb, int *flags, char *data)
|
|
|
|
{
|
|
|
|
*flags |= MS_RDONLY;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* vxfs_read_super - read superblock into memory and initalize filesystem
|
|
|
|
* @sbp: VFS superblock (to fill)
|
|
|
|
* @dp: fs private mount data
|
|
|
|
* @silent: do not complain loudly when sth is wrong
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* We are called on the first mount of a filesystem to read the
|
|
|
|
* superblock into memory and do some basic setup.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The superblock on success, else %NULL.
|
|
|
|
*
|
|
|
|
* Locking:
|
|
|
|
* We are under the bkl and @sbp->s_lock.
|
|
|
|
*/
|
|
|
|
static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
|
|
|
|
{
|
|
|
|
struct vxfs_sb_info *infp;
|
|
|
|
struct vxfs_sb *rsbp;
|
|
|
|
struct buffer_head *bp = NULL;
|
|
|
|
u_long bsize;
|
|
|
|
struct inode *root;
|
|
|
|
|
|
|
|
sbp->s_flags |= MS_RDONLY;
|
|
|
|
|
2005-09-06 18:18:35 -04:00
|
|
|
infp = kzalloc(sizeof(*infp), GFP_KERNEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!infp) {
|
|
|
|
printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
bsize = sb_min_blocksize(sbp, BLOCK_SIZE);
|
|
|
|
if (!bsize) {
|
|
|
|
printk(KERN_WARNING "vxfs: unable to set blocksize\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = sb_bread(sbp, 1);
|
|
|
|
if (!bp || !buffer_mapped(bp)) {
|
|
|
|
if (!silent) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"vxfs: unable to read disk superblock\n");
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
rsbp = (struct vxfs_sb *)bp->b_data;
|
|
|
|
if (rsbp->vs_magic != VXFS_SUPER_MAGIC) {
|
|
|
|
if (!silent)
|
|
|
|
printk(KERN_NOTICE "vxfs: WRONG superblock magic\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rsbp->vs_version < 2 || rsbp->vs_version > 4) && !silent) {
|
|
|
|
printk(KERN_NOTICE "vxfs: unsupported VxFS version (%d)\n",
|
|
|
|
rsbp->vs_version);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
printk(KERN_DEBUG "vxfs: supported VxFS version (%d)\n", rsbp->vs_version);
|
|
|
|
printk(KERN_DEBUG "vxfs: blocksize: %d\n", rsbp->vs_bsize);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sbp->s_magic = rsbp->vs_magic;
|
2005-06-30 05:59:05 -04:00
|
|
|
sbp->s_fs_info = infp;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
infp->vsi_raw = rsbp;
|
|
|
|
infp->vsi_bp = bp;
|
|
|
|
infp->vsi_oltext = rsbp->vs_oltext[0];
|
|
|
|
infp->vsi_oltsize = rsbp->vs_oltsize;
|
|
|
|
|
|
|
|
if (!sb_set_blocksize(sbp, rsbp->vs_bsize)) {
|
|
|
|
printk(KERN_WARNING "vxfs: unable to set final block size\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vxfs_read_olt(sbp, bsize)) {
|
|
|
|
printk(KERN_WARNING "vxfs: unable to read olt\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vxfs_read_fshead(sbp)) {
|
|
|
|
printk(KERN_WARNING "vxfs: unable to read fshead\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbp->s_op = &vxfs_super_ops;
|
|
|
|
root = iget(sbp, VXFS_ROOT_INO);
|
|
|
|
sbp->s_root = d_alloc_root(root);
|
|
|
|
if (!sbp->s_root) {
|
|
|
|
iput(root);
|
|
|
|
printk(KERN_WARNING "vxfs: unable to get root dentry.\n");
|
|
|
|
goto out_free_ilist;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_ilist:
|
|
|
|
vxfs_put_fake_inode(infp->vsi_fship);
|
|
|
|
vxfs_put_fake_inode(infp->vsi_ilist);
|
|
|
|
vxfs_put_fake_inode(infp->vsi_stilist);
|
|
|
|
out:
|
|
|
|
brelse(bp);
|
|
|
|
kfree(infp);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The usual module blurb.
|
|
|
|
*/
|
[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 05:02:57 -04:00
|
|
|
static int vxfs_get_sb(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
|
2005-04-16 18:20:36 -04: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 05:02:57 -04:00
|
|
|
return get_sb_bdev(fs_type, flags, dev_name, data, vxfs_fill_super,
|
|
|
|
mnt);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_system_type vxfs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "vxfs",
|
|
|
|
.get_sb = vxfs_get_sb,
|
|
|
|
.kill_sb = kill_block_super,
|
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
vxfs_init(void)
|
|
|
|
{
|
2006-09-29 05:01:04 -04:00
|
|
|
int rv;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
vxfs_inode_cachep = kmem_cache_create("vxfs_inode",
|
|
|
|
sizeof(struct vxfs_inode_info), 0,
|
[PATCH] cpuset memory spread: slab cache filesystems
Mark file system inode and similar slab caches subject to SLAB_MEM_SPREAD
memory spreading.
If a slab cache is marked SLAB_MEM_SPREAD, then anytime that a task that's
in a cpuset with the 'memory_spread_slab' option enabled goes to allocate
from such a slab cache, the allocations are spread evenly over all the
memory nodes (task->mems_allowed) allowed to that task, instead of favoring
allocation on the node local to the current cpu.
The following inode and similar caches are marked SLAB_MEM_SPREAD:
file cache
==== =====
fs/adfs/super.c adfs_inode_cache
fs/affs/super.c affs_inode_cache
fs/befs/linuxvfs.c befs_inode_cache
fs/bfs/inode.c bfs_inode_cache
fs/block_dev.c bdev_cache
fs/cifs/cifsfs.c cifs_inode_cache
fs/coda/inode.c coda_inode_cache
fs/dquot.c dquot
fs/efs/super.c efs_inode_cache
fs/ext2/super.c ext2_inode_cache
fs/ext2/xattr.c (fs/mbcache.c) ext2_xattr
fs/ext3/super.c ext3_inode_cache
fs/ext3/xattr.c (fs/mbcache.c) ext3_xattr
fs/fat/cache.c fat_cache
fs/fat/inode.c fat_inode_cache
fs/freevxfs/vxfs_super.c vxfs_inode
fs/hpfs/super.c hpfs_inode_cache
fs/isofs/inode.c isofs_inode_cache
fs/jffs/inode-v23.c jffs_fm
fs/jffs2/super.c jffs2_i
fs/jfs/super.c jfs_ip
fs/minix/inode.c minix_inode_cache
fs/ncpfs/inode.c ncp_inode_cache
fs/nfs/direct.c nfs_direct_cache
fs/nfs/inode.c nfs_inode_cache
fs/ntfs/super.c ntfs_big_inode_cache_name
fs/ntfs/super.c ntfs_inode_cache
fs/ocfs2/dlm/dlmfs.c dlmfs_inode_cache
fs/ocfs2/super.c ocfs2_inode_cache
fs/proc/inode.c proc_inode_cache
fs/qnx4/inode.c qnx4_inode_cache
fs/reiserfs/super.c reiser_inode_cache
fs/romfs/inode.c romfs_inode_cache
fs/smbfs/inode.c smb_inode_cache
fs/sysv/inode.c sysv_inode_cache
fs/udf/super.c udf_inode_cache
fs/ufs/super.c ufs_inode_cache
net/socket.c sock_inode_cache
net/sunrpc/rpc_pipe.c rpc_inode_cache
The choice of which slab caches to so mark was quite simple. I marked
those already marked SLAB_RECLAIM_ACCOUNT, except for fs/xfs, dentry_cache,
inode_cache, and buffer_head, which were marked in a previous patch. Even
though SLAB_RECLAIM_ACCOUNT is for a different purpose, it marks the same
potentially large file system i/o related slab caches as we need for memory
spreading.
Given that the rule now becomes "wherever you would have used a
SLAB_RECLAIM_ACCOUNT slab cache flag before (usually the inode cache), use
the SLAB_MEM_SPREAD flag too", this should be easy enough to maintain.
Future file system writers will just copy one of the existing file system
slab cache setups and tend to get it right without thinking.
Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-24 06:16:05 -05:00
|
|
|
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
|
2006-09-29 05:01:04 -04:00
|
|
|
if (!vxfs_inode_cachep)
|
|
|
|
return -ENOMEM;
|
|
|
|
rv = register_filesystem(&vxfs_fs_type);
|
|
|
|
if (rv < 0)
|
|
|
|
kmem_cache_destroy(vxfs_inode_cachep);
|
|
|
|
return rv;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit
|
|
|
|
vxfs_cleanup(void)
|
|
|
|
{
|
|
|
|
unregister_filesystem(&vxfs_fs_type);
|
|
|
|
kmem_cache_destroy(vxfs_inode_cachep);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(vxfs_init);
|
|
|
|
module_exit(vxfs_cleanup);
|