2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Copyright (C) International Business Machines Corp., 2000-2004
|
|
|
|
* Portions Copyright (C) Christoph Hellwig, 2001-2002
|
|
|
|
*
|
|
|
|
* 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
|
2006-10-02 08:55:27 -06:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2005-04-16 16:20:36 -06:00
|
|
|
* (at your option) any later version.
|
2006-10-02 08:55:27 -06:00
|
|
|
*
|
2005-04-16 16:20:36 -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
|
2006-10-02 08:55:27 -06:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-04-16 16:20:36 -06:00
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/parser.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/vfs.h>
|
2008-07-25 02:46:51 -06:00
|
|
|
#include <linux/quotaops.h>
|
2005-09-06 16:16:54 -06:00
|
|
|
#include <linux/mount.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/moduleparam.h>
|
2006-02-15 11:49:04 -07:00
|
|
|
#include <linux/kthread.h>
|
2005-06-23 01:10:19 -06:00
|
|
|
#include <linux/posix_acl.h>
|
2006-07-26 13:52:13 -06:00
|
|
|
#include <linux/buffer_head.h>
|
2007-07-17 05:04:28 -06:00
|
|
|
#include <linux/exportfs.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/uaccess.h>
|
2005-09-06 16:16:54 -06:00
|
|
|
#include <linux/seq_file.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#include "jfs_incore.h"
|
|
|
|
#include "jfs_filsys.h"
|
2005-05-04 14:29:35 -06:00
|
|
|
#include "jfs_inode.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
#include "jfs_metapage.h"
|
|
|
|
#include "jfs_superblock.h"
|
|
|
|
#include "jfs_dmap.h"
|
|
|
|
#include "jfs_imap.h"
|
|
|
|
#include "jfs_acl.h"
|
|
|
|
#include "jfs_debug.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
|
|
|
|
MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2006-12-06 21:33:20 -07:00
|
|
|
static struct kmem_cache * jfs_inode_cachep;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-02-12 01:55:41 -07:00
|
|
|
static const struct super_operations jfs_super_operations;
|
2007-10-21 17:42:17 -06:00
|
|
|
static const struct export_operations jfs_export_operations;
|
2005-04-16 16:20:36 -06:00
|
|
|
static struct file_system_type jfs_fs_type;
|
|
|
|
|
|
|
|
#define MAX_COMMIT_THREADS 64
|
|
|
|
static int commit_threads = 0;
|
|
|
|
module_param(commit_threads, int, 0);
|
|
|
|
MODULE_PARM_DESC(commit_threads, "Number of commit threads");
|
|
|
|
|
2006-02-15 11:49:04 -07:00
|
|
|
static struct task_struct *jfsCommitThread[MAX_COMMIT_THREADS];
|
|
|
|
struct task_struct *jfsIOthread;
|
|
|
|
struct task_struct *jfsSyncThread;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#ifdef CONFIG_JFS_DEBUG
|
|
|
|
int jfsloglevel = JFS_LOGLEVEL_WARN;
|
|
|
|
module_param(jfsloglevel, int, 0644);
|
|
|
|
MODULE_PARM_DESC(jfsloglevel, "Specify JFS loglevel (0, 1 or 2)");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void jfs_handle_error(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
|
|
|
|
if (sb->s_flags & MS_RDONLY)
|
|
|
|
return;
|
|
|
|
|
|
|
|
updateSuper(sb, FM_DIRTY);
|
|
|
|
|
|
|
|
if (sbi->flag & JFS_ERR_PANIC)
|
|
|
|
panic("JFS (device %s): panic forced after error\n",
|
|
|
|
sb->s_id);
|
|
|
|
else if (sbi->flag & JFS_ERR_REMOUNT_RO) {
|
|
|
|
jfs_err("ERROR: (device %s): remounting filesystem "
|
|
|
|
"as read-only\n",
|
|
|
|
sb->s_id);
|
|
|
|
sb->s_flags |= MS_RDONLY;
|
2006-10-02 08:55:27 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* nothing is done for continue beyond marking the superblock dirty */
|
|
|
|
}
|
|
|
|
|
|
|
|
void jfs_error(struct super_block *sb, const char * function, ...)
|
|
|
|
{
|
|
|
|
static char error_buf[256];
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, function);
|
2006-12-06 21:37:04 -07:00
|
|
|
vsnprintf(error_buf, sizeof(error_buf), function, args);
|
2005-04-16 16:20:36 -06:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf);
|
|
|
|
|
|
|
|
jfs_handle_error(sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct inode *jfs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct jfs_inode_info *jfs_inode;
|
|
|
|
|
|
|
|
jfs_inode = kmem_cache_alloc(jfs_inode_cachep, GFP_NOFS);
|
|
|
|
if (!jfs_inode)
|
|
|
|
return NULL;
|
|
|
|
return &jfs_inode->vfs_inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void jfs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
struct jfs_inode_info *ji = JFS_IP(inode);
|
|
|
|
|
2005-08-10 10:14:39 -06:00
|
|
|
BUG_ON(!list_empty(&ji->anon_inode_list));
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_lock_irq(&ji->ag_lock);
|
|
|
|
if (ji->active_ag != -1) {
|
|
|
|
struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
|
|
|
|
atomic_dec(&bmap->db_active[ji->active_ag]);
|
|
|
|
ji->active_ag = -1;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ji->ag_lock);
|
|
|
|
|
|
|
|
#ifdef CONFIG_JFS_POSIX_ACL
|
|
|
|
if (ji->i_acl != JFS_ACL_NOT_CACHED) {
|
|
|
|
posix_acl_release(ji->i_acl);
|
|
|
|
ji->i_acl = JFS_ACL_NOT_CACHED;
|
|
|
|
}
|
|
|
|
if (ji->i_default_acl != JFS_ACL_NOT_CACHED) {
|
|
|
|
posix_acl_release(ji->i_default_acl);
|
|
|
|
ji->i_default_acl = JFS_ACL_NOT_CACHED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
kmem_cache_free(jfs_inode_cachep, ji);
|
|
|
|
}
|
|
|
|
|
2006-06-23 03:02:58 -06:00
|
|
|
static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-06-23 03:02:58 -06:00
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(dentry->d_sb);
|
2005-04-16 16:20:36 -06:00
|
|
|
s64 maxinodes;
|
|
|
|
struct inomap *imap = JFS_IP(sbi->ipimap)->i_imap;
|
|
|
|
|
|
|
|
jfs_info("In jfs_statfs");
|
|
|
|
buf->f_type = JFS_SUPER_MAGIC;
|
|
|
|
buf->f_bsize = sbi->bsize;
|
|
|
|
buf->f_blocks = sbi->bmap->db_mapsize;
|
|
|
|
buf->f_bfree = sbi->bmap->db_nfree;
|
|
|
|
buf->f_bavail = sbi->bmap->db_nfree;
|
|
|
|
/*
|
|
|
|
* If we really return the number of allocated & free inodes, some
|
|
|
|
* applications will fail because they won't see enough free inodes.
|
|
|
|
* We'll try to calculate some guess as to how may inodes we can
|
|
|
|
* really allocate
|
|
|
|
*
|
|
|
|
* buf->f_files = atomic_read(&imap->im_numinos);
|
|
|
|
* buf->f_ffree = atomic_read(&imap->im_numfree);
|
|
|
|
*/
|
|
|
|
maxinodes = min((s64) atomic_read(&imap->im_numinos) +
|
|
|
|
((sbi->bmap->db_nfree >> imap->im_l2nbperiext)
|
|
|
|
<< L2INOSPEREXT), (s64) 0xffffffffLL);
|
|
|
|
buf->f_files = maxinodes;
|
|
|
|
buf->f_ffree = maxinodes - (atomic_read(&imap->im_numinos) -
|
|
|
|
atomic_read(&imap->im_numfree));
|
|
|
|
|
|
|
|
buf->f_namelen = JFS_NAME_MAX;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void jfs_put_super(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
jfs_info("In jfs_put_super");
|
|
|
|
rc = jfs_umount(sb);
|
|
|
|
if (rc)
|
|
|
|
jfs_err("jfs_umount failed with return code %d", rc);
|
|
|
|
if (sbi->nls_tab)
|
|
|
|
unload_nls(sbi->nls_tab);
|
|
|
|
sbi->nls_tab = NULL;
|
|
|
|
|
2005-05-02 12:25:02 -06:00
|
|
|
truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
|
|
|
|
iput(sbi->direct_inode);
|
|
|
|
sbi->direct_inode = NULL;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
kfree(sbi);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
|
2005-09-06 16:16:54 -06:00
|
|
|
Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
|
2006-03-09 12:59:30 -07:00
|
|
|
Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2008-10-13 03:46:57 -06:00
|
|
|
static const match_table_t tokens = {
|
2005-04-16 16:20:36 -06:00
|
|
|
{Opt_integrity, "integrity"},
|
|
|
|
{Opt_nointegrity, "nointegrity"},
|
|
|
|
{Opt_iocharset, "iocharset=%s"},
|
|
|
|
{Opt_resize, "resize=%u"},
|
|
|
|
{Opt_resize_nosize, "resize"},
|
|
|
|
{Opt_errors, "errors=%s"},
|
|
|
|
{Opt_ignore, "noquota"},
|
|
|
|
{Opt_ignore, "quota"},
|
2005-09-06 16:16:54 -06:00
|
|
|
{Opt_usrquota, "usrquota"},
|
|
|
|
{Opt_grpquota, "grpquota"},
|
2006-03-09 12:59:30 -07:00
|
|
|
{Opt_uid, "uid=%u"},
|
|
|
|
{Opt_gid, "gid=%u"},
|
|
|
|
{Opt_umask, "umask=%u"},
|
2005-04-16 16:20:36 -06:00
|
|
|
{Opt_err, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
|
|
|
|
int *flag)
|
|
|
|
{
|
|
|
|
void *nls_map = (void *)-1; /* -1: no change; NULL: none */
|
|
|
|
char *p;
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
|
|
|
|
*newLVSize = 0;
|
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
while ((p = strsep(&options, ",")) != NULL) {
|
|
|
|
substring_t args[MAX_OPT_ARGS];
|
|
|
|
int token;
|
|
|
|
if (!*p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = match_token(p, tokens, args);
|
|
|
|
switch (token) {
|
|
|
|
case Opt_integrity:
|
|
|
|
*flag &= ~JFS_NOINTEGRITY;
|
|
|
|
break;
|
|
|
|
case Opt_nointegrity:
|
|
|
|
*flag |= JFS_NOINTEGRITY;
|
|
|
|
break;
|
|
|
|
case Opt_ignore:
|
|
|
|
/* Silently ignore the quota options */
|
|
|
|
/* Don't do anything ;-) */
|
|
|
|
break;
|
|
|
|
case Opt_iocharset:
|
|
|
|
if (nls_map && nls_map != (void *) -1)
|
|
|
|
unload_nls(nls_map);
|
|
|
|
if (!strcmp(args[0].from, "none"))
|
|
|
|
nls_map = NULL;
|
|
|
|
else {
|
|
|
|
nls_map = load_nls(args[0].from);
|
|
|
|
if (!nls_map) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: charset not found\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Opt_resize:
|
|
|
|
{
|
|
|
|
char *resize = args[0].from;
|
|
|
|
*newLVSize = simple_strtoull(resize, &resize, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Opt_resize_nosize:
|
|
|
|
{
|
|
|
|
*newLVSize = sb->s_bdev->bd_inode->i_size >>
|
|
|
|
sb->s_blocksize_bits;
|
|
|
|
if (*newLVSize == 0)
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: Cannot determine volume size\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Opt_errors:
|
|
|
|
{
|
|
|
|
char *errors = args[0].from;
|
|
|
|
if (!errors || !*errors)
|
|
|
|
goto cleanup;
|
|
|
|
if (!strcmp(errors, "continue")) {
|
|
|
|
*flag &= ~JFS_ERR_REMOUNT_RO;
|
|
|
|
*flag &= ~JFS_ERR_PANIC;
|
|
|
|
*flag |= JFS_ERR_CONTINUE;
|
|
|
|
} else if (!strcmp(errors, "remount-ro")) {
|
|
|
|
*flag &= ~JFS_ERR_CONTINUE;
|
|
|
|
*flag &= ~JFS_ERR_PANIC;
|
|
|
|
*flag |= JFS_ERR_REMOUNT_RO;
|
|
|
|
} else if (!strcmp(errors, "panic")) {
|
|
|
|
*flag &= ~JFS_ERR_CONTINUE;
|
|
|
|
*flag &= ~JFS_ERR_REMOUNT_RO;
|
|
|
|
*flag |= JFS_ERR_PANIC;
|
|
|
|
} else {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: %s is an invalid error handler\n",
|
|
|
|
errors);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-09-06 16:16:54 -06:00
|
|
|
|
2006-07-26 13:52:13 -06:00
|
|
|
#ifdef CONFIG_QUOTA
|
2005-09-06 16:16:54 -06:00
|
|
|
case Opt_quota:
|
|
|
|
case Opt_usrquota:
|
|
|
|
*flag |= JFS_USRQUOTA;
|
|
|
|
break;
|
|
|
|
case Opt_grpquota:
|
|
|
|
*flag |= JFS_GRPQUOTA;
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case Opt_usrquota:
|
|
|
|
case Opt_grpquota:
|
|
|
|
case Opt_quota:
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: quota operations not supported\n");
|
|
|
|
break;
|
|
|
|
#endif
|
2006-03-09 12:59:30 -07:00
|
|
|
case Opt_uid:
|
|
|
|
{
|
|
|
|
char *uid = args[0].from;
|
|
|
|
sbi->uid = simple_strtoul(uid, &uid, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Opt_gid:
|
|
|
|
{
|
|
|
|
char *gid = args[0].from;
|
|
|
|
sbi->gid = simple_strtoul(gid, &gid, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Opt_umask:
|
|
|
|
{
|
|
|
|
char *umask = args[0].from;
|
|
|
|
sbi->umask = simple_strtoul(umask, &umask, 8);
|
|
|
|
if (sbi->umask & ~0777) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: Invalid value of umask\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
default:
|
|
|
|
printk("jfs: Unrecognized mount option \"%s\" "
|
|
|
|
" or missing value\n", p);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nls_map != (void *) -1) {
|
|
|
|
/* Discard old (if remount) */
|
|
|
|
if (sbi->nls_tab)
|
|
|
|
unload_nls(sbi->nls_tab);
|
|
|
|
sbi->nls_tab = nls_map;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (nls_map && nls_map != (void *) -1)
|
|
|
|
unload_nls(nls_map);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int jfs_remount(struct super_block *sb, int *flags, char *data)
|
|
|
|
{
|
|
|
|
s64 newLVSize = 0;
|
|
|
|
int rc = 0;
|
|
|
|
int flag = JFS_SBI(sb)->flag;
|
|
|
|
|
|
|
|
if (!parse_options(data, sb, &newLVSize, &flag)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
if (newLVSize) {
|
|
|
|
if (sb->s_flags & MS_RDONLY) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"JFS: resize requires volume to be mounted read-write\n");
|
|
|
|
return -EROFS;
|
|
|
|
}
|
|
|
|
rc = jfs_extendfs(sb, newLVSize, 0);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
|
2005-05-02 12:25:02 -06:00
|
|
|
/*
|
|
|
|
* Invalidate any previously read metadata. fsck may have
|
|
|
|
* changed the on-disk data since we mounted r/o
|
|
|
|
*/
|
|
|
|
truncate_inode_pages(JFS_SBI(sb)->direct_inode->i_mapping, 0);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
JFS_SBI(sb)->flag = flag;
|
|
|
|
return jfs_mount_rw(sb, 1);
|
|
|
|
}
|
|
|
|
if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
|
|
|
|
rc = jfs_umount_rw(sb);
|
|
|
|
JFS_SBI(sb)->flag = flag;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY))
|
|
|
|
if (!(sb->s_flags & MS_RDONLY)) {
|
|
|
|
rc = jfs_umount_rw(sb);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
JFS_SBI(sb)->flag = flag;
|
|
|
|
return jfs_mount_rw(sb, 1);
|
|
|
|
}
|
|
|
|
JFS_SBI(sb)->flag = flag;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int jfs_fill_super(struct super_block *sb, void *data, int silent)
|
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi;
|
|
|
|
struct inode *inode;
|
|
|
|
int rc;
|
|
|
|
s64 newLVSize = 0;
|
2008-02-07 01:15:43 -07:00
|
|
|
int flag, ret = -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags);
|
|
|
|
|
|
|
|
if (!new_valid_dev(sb->s_bdev->bd_dev))
|
|
|
|
return -EOVERFLOW;
|
|
|
|
|
2006-02-23 08:47:13 -07:00
|
|
|
sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!sbi)
|
2006-09-14 08:22:38 -06:00
|
|
|
return -ENOMEM;
|
2005-04-16 16:20:36 -06:00
|
|
|
sb->s_fs_info = sbi;
|
|
|
|
sbi->sb = sb;
|
2006-03-09 12:59:30 -07:00
|
|
|
sbi->uid = sbi->gid = sbi->umask = -1;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* initialize the mount flag and determine the default error handler */
|
|
|
|
flag = JFS_ERR_REMOUNT_RO;
|
|
|
|
|
|
|
|
if (!parse_options((char *) data, sb, &newLVSize, &flag)) {
|
|
|
|
kfree(sbi);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
sbi->flag = flag;
|
|
|
|
|
|
|
|
#ifdef CONFIG_JFS_POSIX_ACL
|
|
|
|
sb->s_flags |= MS_POSIXACL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (newLVSize) {
|
|
|
|
printk(KERN_ERR "resize option for remount only\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize blocksize to 4K.
|
|
|
|
*/
|
|
|
|
sb_set_blocksize(sb, PSIZE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set method vectors.
|
|
|
|
*/
|
|
|
|
sb->s_op = &jfs_super_operations;
|
|
|
|
sb->s_export_op = &jfs_export_operations;
|
|
|
|
|
2005-05-02 12:25:02 -06:00
|
|
|
/*
|
|
|
|
* Initialize direct-mapping inode/address-space
|
|
|
|
*/
|
|
|
|
inode = new_inode(sb);
|
2008-02-07 01:15:43 -07:00
|
|
|
if (inode == NULL) {
|
|
|
|
ret = -ENOMEM;
|
2005-05-02 12:25:02 -06:00
|
|
|
goto out_kfree;
|
2008-02-07 01:15:43 -07:00
|
|
|
}
|
2005-05-02 12:25:02 -06:00
|
|
|
inode->i_ino = 0;
|
|
|
|
inode->i_nlink = 1;
|
|
|
|
inode->i_size = sb->s_bdev->bd_inode->i_size;
|
|
|
|
inode->i_mapping->a_ops = &jfs_metapage_aops;
|
2005-10-03 14:32:11 -06:00
|
|
|
insert_inode_hash(inode);
|
2005-05-02 12:25:02 -06:00
|
|
|
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
|
|
|
|
|
|
|
|
sbi->direct_inode = inode;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
rc = jfs_mount(sb);
|
|
|
|
if (rc) {
|
|
|
|
if (!silent) {
|
|
|
|
jfs_err("jfs_mount failed w/return code = %d", rc);
|
|
|
|
}
|
2005-05-02 12:25:02 -06:00
|
|
|
goto out_mount_failed;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
if (sb->s_flags & MS_RDONLY)
|
|
|
|
sbi->log = NULL;
|
|
|
|
else {
|
|
|
|
rc = jfs_mount_rw(sb, 0);
|
|
|
|
if (rc) {
|
|
|
|
if (!silent) {
|
|
|
|
jfs_err("jfs_mount_rw failed, return code = %d",
|
|
|
|
rc);
|
|
|
|
}
|
|
|
|
goto out_no_rw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sb->s_magic = JFS_SUPER_MAGIC;
|
|
|
|
|
2008-02-07 01:15:43 -07:00
|
|
|
inode = jfs_iget(sb, ROOT_I);
|
|
|
|
if (IS_ERR(inode)) {
|
|
|
|
ret = PTR_ERR(inode);
|
2008-05-21 09:45:16 -06:00
|
|
|
goto out_no_rw;
|
2008-02-07 01:15:43 -07:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
sb->s_root = d_alloc_root(inode);
|
|
|
|
if (!sb->s_root)
|
|
|
|
goto out_no_root;
|
|
|
|
|
|
|
|
if (sbi->mntflag & JFS_OS2)
|
|
|
|
sb->s_root->d_op = &jfs_ci_dentry_operations;
|
|
|
|
|
|
|
|
/* logical blocks are represented by 40 bits in pxd_t, etc. */
|
|
|
|
sb->s_maxbytes = ((u64) sb->s_blocksize) << 40;
|
|
|
|
#if BITS_PER_LONG == 32
|
|
|
|
/*
|
|
|
|
* Page cache is indexed by long.
|
|
|
|
* I would use MAX_LFS_FILESIZE, but it's only half as big
|
|
|
|
*/
|
|
|
|
sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, sb->s_maxbytes);
|
|
|
|
#endif
|
|
|
|
sb->s_time_gran = 1;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_no_root:
|
2008-05-21 09:45:16 -06:00
|
|
|
jfs_err("jfs_read_super: get root dentry failed");
|
|
|
|
iput(inode);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
out_no_rw:
|
|
|
|
rc = jfs_umount(sb);
|
|
|
|
if (rc) {
|
|
|
|
jfs_err("jfs_umount failed with return code %d", rc);
|
|
|
|
}
|
2005-05-02 12:25:02 -06:00
|
|
|
out_mount_failed:
|
[PATCH] Fix and add EXPORT_SYMBOL(filemap_write_and_wait)
This patch add EXPORT_SYMBOL(filemap_write_and_wait) and use it.
See mm/filemap.c:
And changes the filemap_write_and_wait() and filemap_write_and_wait_range().
Current filemap_write_and_wait() doesn't wait if filemap_fdatawrite()
returns error. However, even if filemap_fdatawrite() returned an
error, it may have submitted the partially data pages to the device.
(e.g. in the case of -ENOSPC)
<quotation>
Andrew Morton writes,
If filemap_fdatawrite() returns an error, this might be due to some
I/O problem: dead disk, unplugged cable, etc. Given the generally
crappy quality of the kernel's handling of such exceptions, there's a
good chance that the filemap_fdatawait() will get stuck in D state
forever.
</quotation>
So, this patch doesn't wait if filemap_fdatawrite() returns the -EIO.
Trond, could you please review the nfs part? Especially I'm not sure,
nfs must use the "filemap_fdatawrite(inode->i_mapping) == 0", or not.
Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 02:02:14 -07:00
|
|
|
filemap_write_and_wait(sbi->direct_inode->i_mapping);
|
2005-05-02 12:25:02 -06:00
|
|
|
truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
|
|
|
|
make_bad_inode(sbi->direct_inode);
|
|
|
|
iput(sbi->direct_inode);
|
|
|
|
sbi->direct_inode = NULL;
|
2005-04-16 16:20:36 -06:00
|
|
|
out_kfree:
|
|
|
|
if (sbi->nls_tab)
|
|
|
|
unload_nls(sbi->nls_tab);
|
|
|
|
kfree(sbi);
|
2008-02-07 01:15:43 -07:00
|
|
|
return ret;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2009-01-09 17:40:58 -07:00
|
|
|
static int jfs_freeze(struct super_block *sb)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
struct jfs_log *log = sbi->log;
|
|
|
|
|
|
|
|
if (!(sb->s_flags & MS_RDONLY)) {
|
|
|
|
txQuiesce(sb);
|
|
|
|
lmLogShutdown(log);
|
|
|
|
updateSuper(sb, FM_CLEAN);
|
|
|
|
}
|
2009-01-09 17:40:58 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2009-01-09 17:40:58 -07:00
|
|
|
static int jfs_unfreeze(struct super_block *sb)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
struct jfs_log *log = sbi->log;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (!(sb->s_flags & MS_RDONLY)) {
|
|
|
|
updateSuper(sb, FM_MOUNT);
|
|
|
|
if ((rc = lmLogInit(log)))
|
|
|
|
jfs_err("jfs_unlock failed with return code %d", rc);
|
|
|
|
else
|
|
|
|
txResume(sb);
|
|
|
|
}
|
2009-01-09 17:40:58 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -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 jfs_get_sb(struct file_system_type *fs_type,
|
|
|
|
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
|
2005-04-16 16:20:36 -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
|
|
|
return get_sb_bdev(fs_type, flags, dev_name, data, jfs_fill_super,
|
|
|
|
mnt);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int jfs_sync_fs(struct super_block *sb, int wait)
|
|
|
|
{
|
|
|
|
struct jfs_log *log = JFS_SBI(sb)->log;
|
|
|
|
|
|
|
|
/* log == NULL indicates read-only mount */
|
2005-05-02 12:25:08 -06:00
|
|
|
if (log) {
|
2005-04-16 16:20:36 -06:00
|
|
|
jfs_flush_journal(log, wait);
|
2005-07-27 08:17:57 -06:00
|
|
|
jfs_syncpt(log, 0);
|
2005-05-02 12:25:08 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-06 16:16:54 -06:00
|
|
|
static int jfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
|
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(vfs->mnt_sb);
|
|
|
|
|
2006-03-09 12:59:30 -07:00
|
|
|
if (sbi->uid != -1)
|
|
|
|
seq_printf(seq, ",uid=%d", sbi->uid);
|
|
|
|
if (sbi->gid != -1)
|
|
|
|
seq_printf(seq, ",gid=%d", sbi->gid);
|
|
|
|
if (sbi->umask != -1)
|
|
|
|
seq_printf(seq, ",umask=%03o", sbi->umask);
|
2005-09-06 16:16:54 -06:00
|
|
|
if (sbi->flag & JFS_NOINTEGRITY)
|
|
|
|
seq_puts(seq, ",nointegrity");
|
2008-01-24 15:13:21 -07:00
|
|
|
if (sbi->nls_tab)
|
|
|
|
seq_printf(seq, ",iocharset=%s", sbi->nls_tab->charset);
|
|
|
|
if (sbi->flag & JFS_ERR_CONTINUE)
|
|
|
|
seq_printf(seq, ",errors=continue");
|
|
|
|
if (sbi->flag & JFS_ERR_PANIC)
|
|
|
|
seq_printf(seq, ",errors=panic");
|
2005-09-06 16:16:54 -06:00
|
|
|
|
2006-07-26 13:52:13 -06:00
|
|
|
#ifdef CONFIG_QUOTA
|
2005-09-06 16:16:54 -06:00
|
|
|
if (sbi->flag & JFS_USRQUOTA)
|
|
|
|
seq_puts(seq, ",usrquota");
|
|
|
|
|
|
|
|
if (sbi->flag & JFS_GRPQUOTA)
|
|
|
|
seq_puts(seq, ",grpquota");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-26 13:52:13 -06:00
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
|
|
|
|
/* Read data from quotafile - avoid pagecache and such because we cannot afford
|
|
|
|
* acquiring the locks... As quota files are never truncated and quota code
|
|
|
|
* itself serializes the operations (and noone else should touch the files)
|
|
|
|
* we don't have to be afraid of races */
|
|
|
|
static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
|
|
|
|
size_t len, loff_t off)
|
|
|
|
{
|
|
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
|
|
sector_t blk = off >> sb->s_blocksize_bits;
|
|
|
|
int err = 0;
|
|
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
|
|
int tocopy;
|
|
|
|
size_t toread;
|
|
|
|
struct buffer_head tmp_bh;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
loff_t i_size = i_size_read(inode);
|
|
|
|
|
|
|
|
if (off > i_size)
|
|
|
|
return 0;
|
|
|
|
if (off+len > i_size)
|
|
|
|
len = i_size-off;
|
|
|
|
toread = len;
|
|
|
|
while (toread > 0) {
|
|
|
|
tocopy = sb->s_blocksize - offset < toread ?
|
|
|
|
sb->s_blocksize - offset : toread;
|
|
|
|
|
|
|
|
tmp_bh.b_state = 0;
|
|
|
|
tmp_bh.b_size = 1 << inode->i_blkbits;
|
|
|
|
err = jfs_get_block(inode, blk, &tmp_bh, 0);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
if (!buffer_mapped(&tmp_bh)) /* A hole? */
|
|
|
|
memset(data, 0, tocopy);
|
|
|
|
else {
|
|
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
|
|
if (!bh)
|
|
|
|
return -EIO;
|
|
|
|
memcpy(data, bh->b_data+offset, tocopy);
|
|
|
|
brelse(bh);
|
|
|
|
}
|
|
|
|
offset = 0;
|
|
|
|
toread -= tocopy;
|
|
|
|
data += tocopy;
|
|
|
|
blk++;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write to quotafile */
|
|
|
|
static ssize_t jfs_quota_write(struct super_block *sb, int type,
|
|
|
|
const char *data, size_t len, loff_t off)
|
|
|
|
{
|
|
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
|
|
sector_t blk = off >> sb->s_blocksize_bits;
|
|
|
|
int err = 0;
|
|
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
|
|
int tocopy;
|
|
|
|
size_t towrite = len;
|
|
|
|
struct buffer_head tmp_bh;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
|
|
|
|
mutex_lock(&inode->i_mutex);
|
|
|
|
while (towrite > 0) {
|
|
|
|
tocopy = sb->s_blocksize - offset < towrite ?
|
|
|
|
sb->s_blocksize - offset : towrite;
|
|
|
|
|
|
|
|
tmp_bh.b_state = 0;
|
2006-07-28 07:46:05 -06:00
|
|
|
tmp_bh.b_size = 1 << inode->i_blkbits;
|
2006-07-26 13:52:13 -06:00
|
|
|
err = jfs_get_block(inode, blk, &tmp_bh, 1);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
if (offset || tocopy != sb->s_blocksize)
|
|
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
|
|
else
|
|
|
|
bh = sb_getblk(sb, tmp_bh.b_blocknr);
|
|
|
|
if (!bh) {
|
|
|
|
err = -EIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
lock_buffer(bh);
|
|
|
|
memcpy(bh->b_data+offset, data, tocopy);
|
|
|
|
flush_dcache_page(bh->b_page);
|
|
|
|
set_buffer_uptodate(bh);
|
|
|
|
mark_buffer_dirty(bh);
|
|
|
|
unlock_buffer(bh);
|
|
|
|
brelse(bh);
|
|
|
|
offset = 0;
|
|
|
|
towrite -= tocopy;
|
|
|
|
data += tocopy;
|
|
|
|
blk++;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
if (len == towrite)
|
|
|
|
return err;
|
|
|
|
if (inode->i_size < off+len-towrite)
|
|
|
|
i_size_write(inode, off+len-towrite);
|
|
|
|
inode->i_version++;
|
|
|
|
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
mutex_unlock(&inode->i_mutex);
|
|
|
|
return len - towrite;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-02-12 01:55:41 -07:00
|
|
|
static const struct super_operations jfs_super_operations = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.alloc_inode = jfs_alloc_inode,
|
|
|
|
.destroy_inode = jfs_destroy_inode,
|
|
|
|
.dirty_inode = jfs_dirty_inode,
|
|
|
|
.write_inode = jfs_write_inode,
|
|
|
|
.delete_inode = jfs_delete_inode,
|
|
|
|
.put_super = jfs_put_super,
|
|
|
|
.sync_fs = jfs_sync_fs,
|
2009-01-09 17:40:58 -07:00
|
|
|
.freeze_fs = jfs_freeze,
|
|
|
|
.unfreeze_fs = jfs_unfreeze,
|
2005-04-16 16:20:36 -06:00
|
|
|
.statfs = jfs_statfs,
|
|
|
|
.remount_fs = jfs_remount,
|
2006-07-26 13:52:13 -06:00
|
|
|
.show_options = jfs_show_options,
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
.quota_read = jfs_quota_read,
|
|
|
|
.quota_write = jfs_quota_write,
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2007-10-21 17:42:17 -06:00
|
|
|
static const struct export_operations jfs_export_operations = {
|
2007-10-21 17:42:09 -06:00
|
|
|
.fh_to_dentry = jfs_fh_to_dentry,
|
|
|
|
.fh_to_parent = jfs_fh_to_parent,
|
2005-04-16 16:20:36 -06:00
|
|
|
.get_parent = jfs_get_parent,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct file_system_type jfs_fs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "jfs",
|
|
|
|
.get_sb = jfs_get_sb,
|
|
|
|
.kill_sb = kill_block_super,
|
|
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
|
|
};
|
|
|
|
|
2008-07-25 20:45:34 -06:00
|
|
|
static void init_once(void *foo)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
|
|
|
|
|
2007-05-16 23:10:57 -06:00
|
|
|
memset(jfs_ip, 0, sizeof(struct jfs_inode_info));
|
|
|
|
INIT_LIST_HEAD(&jfs_ip->anon_inode_list);
|
|
|
|
init_rwsem(&jfs_ip->rdwrlock);
|
|
|
|
mutex_init(&jfs_ip->commit_mutex);
|
|
|
|
init_rwsem(&jfs_ip->xattr_sem);
|
|
|
|
spin_lock_init(&jfs_ip->ag_lock);
|
|
|
|
jfs_ip->active_ag = -1;
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_JFS_POSIX_ACL
|
2007-05-16 23:10:57 -06:00
|
|
|
jfs_ip->i_acl = JFS_ACL_NOT_CACHED;
|
|
|
|
jfs_ip->i_default_acl = JFS_ACL_NOT_CACHED;
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
2007-05-16 23:10:57 -06:00
|
|
|
inode_init_once(&jfs_ip->vfs_inode);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init init_jfs_fs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
jfs_inode_cachep =
|
2006-10-02 08:55:27 -06:00
|
|
|
kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
|
2006-03-24 04:16:06 -07:00
|
|
|
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
|
2007-07-19 19:11:58 -06:00
|
|
|
init_once);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (jfs_inode_cachep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Metapage initialization
|
|
|
|
*/
|
|
|
|
rc = metapage_init();
|
|
|
|
if (rc) {
|
|
|
|
jfs_err("metapage_init failed w/rc = %d", rc);
|
|
|
|
goto free_slab;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Transaction Manager initialization
|
|
|
|
*/
|
|
|
|
rc = txInit();
|
|
|
|
if (rc) {
|
|
|
|
jfs_err("txInit failed w/rc = %d", rc);
|
|
|
|
goto free_metapage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I/O completion thread (endio)
|
|
|
|
*/
|
2006-02-15 11:49:04 -07:00
|
|
|
jfsIOthread = kthread_run(jfsIOWait, NULL, "jfsIO");
|
|
|
|
if (IS_ERR(jfsIOthread)) {
|
|
|
|
rc = PTR_ERR(jfsIOthread);
|
|
|
|
jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
|
2005-04-16 16:20:36 -06:00
|
|
|
goto end_txmngr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (commit_threads < 1)
|
|
|
|
commit_threads = num_online_cpus();
|
|
|
|
if (commit_threads > MAX_COMMIT_THREADS)
|
|
|
|
commit_threads = MAX_COMMIT_THREADS;
|
|
|
|
|
|
|
|
for (i = 0; i < commit_threads; i++) {
|
2006-02-15 11:49:04 -07:00
|
|
|
jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL, "jfsCommit");
|
|
|
|
if (IS_ERR(jfsCommitThread[i])) {
|
|
|
|
rc = PTR_ERR(jfsCommitThread[i]);
|
|
|
|
jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
|
2005-04-16 16:20:36 -06:00
|
|
|
commit_threads = i;
|
|
|
|
goto kill_committask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-15 11:49:04 -07:00
|
|
|
jfsSyncThread = kthread_run(jfs_sync, NULL, "jfsSync");
|
|
|
|
if (IS_ERR(jfsSyncThread)) {
|
|
|
|
rc = PTR_ERR(jfsSyncThread);
|
|
|
|
jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
|
2005-04-16 16:20:36 -06:00
|
|
|
goto kill_committask;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PROC_FS_JFS
|
|
|
|
jfs_proc_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return register_filesystem(&jfs_fs_type);
|
|
|
|
|
|
|
|
kill_committask:
|
|
|
|
for (i = 0; i < commit_threads; i++)
|
2006-02-15 11:49:04 -07:00
|
|
|
kthread_stop(jfsCommitThread[i]);
|
|
|
|
kthread_stop(jfsIOthread);
|
2005-04-16 16:20:36 -06:00
|
|
|
end_txmngr:
|
|
|
|
txExit();
|
|
|
|
free_metapage:
|
|
|
|
metapage_exit();
|
|
|
|
free_slab:
|
|
|
|
kmem_cache_destroy(jfs_inode_cachep);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_jfs_fs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
jfs_info("exit_jfs_fs called");
|
|
|
|
|
|
|
|
txExit();
|
|
|
|
metapage_exit();
|
2006-02-15 11:49:04 -07:00
|
|
|
|
|
|
|
kthread_stop(jfsIOthread);
|
2005-04-16 16:20:36 -06:00
|
|
|
for (i = 0; i < commit_threads; i++)
|
2006-02-15 11:49:04 -07:00
|
|
|
kthread_stop(jfsCommitThread[i]);
|
|
|
|
kthread_stop(jfsSyncThread);
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef PROC_FS_JFS
|
|
|
|
jfs_proc_clean();
|
|
|
|
#endif
|
|
|
|
unregister_filesystem(&jfs_fs_type);
|
|
|
|
kmem_cache_destroy(jfs_inode_cachep);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_jfs_fs)
|
|
|
|
module_exit(exit_jfs_fs)
|