diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 1114 |
1 files changed, 557 insertions, 557 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8bfd56ef18c..9e32a2a8d28 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1,5 +1,5 @@ /* - * linux/fs/ext3/super.c + * linux/fs/ext4/super.c * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) @@ -21,8 +21,8 @@ #include <linux/fs.h> #include <linux/time.h> #include <linux/jbd.h> -#include <linux/ext3_fs.h> -#include <linux/ext3_jbd.h> +#include <linux/ext4_fs.h> +#include <linux/ext4_jbd.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/blkdev.h> @@ -42,25 +42,25 @@ #include "acl.h" #include "namei.h" -static int ext3_load_journal(struct super_block *, struct ext3_super_block *, +static int ext4_load_journal(struct super_block *, struct ext4_super_block *, unsigned long journal_devnum); -static int ext3_create_journal(struct super_block *, struct ext3_super_block *, +static int ext4_create_journal(struct super_block *, struct ext4_super_block *, unsigned int); -static void ext3_commit_super (struct super_block * sb, - struct ext3_super_block * es, +static void ext4_commit_super (struct super_block * sb, + struct ext4_super_block * es, int sync); -static void ext3_mark_recovery_complete(struct super_block * sb, - struct ext3_super_block * es); -static void ext3_clear_journal_err(struct super_block * sb, - struct ext3_super_block * es); -static int ext3_sync_fs(struct super_block *sb, int wait); -static const char *ext3_decode_error(struct super_block * sb, int errno, +static void ext4_mark_recovery_complete(struct super_block * sb, + struct ext4_super_block * es); +static void ext4_clear_journal_err(struct super_block * sb, + struct ext4_super_block * es); +static int ext4_sync_fs(struct super_block *sb, int wait); +static const char *ext4_decode_error(struct super_block * sb, int errno, char nbuf[16]); -static int ext3_remount (struct super_block * sb, int * flags, char * data); -static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf); -static void ext3_unlockfs(struct super_block *sb); -static void ext3_write_super (struct super_block * sb); -static void ext3_write_super_lockfs(struct super_block *sb); +static int ext4_remount (struct super_block * sb, int * flags, char * data); +static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf); +static void ext4_unlockfs(struct super_block *sb); +static void ext4_write_super (struct super_block * sb); +static void ext4_write_super_lockfs(struct super_block *sb); /* * Wrappers for journal_start/end. @@ -70,7 +70,7 @@ static void ext3_write_super_lockfs(struct super_block *sb); * that sync() will call the filesystem's write_super callback if * appropriate. */ -handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) +handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) { journal_t *journal; @@ -80,9 +80,9 @@ handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) /* Special case here: if the journal has aborted behind our * backs (eg. EIO in the commit thread), then we still need to * take the FS itself readonly cleanly. */ - journal = EXT3_SB(sb)->s_journal; + journal = EXT4_SB(sb)->s_journal; if (is_journal_aborted(journal)) { - ext3_abort(sb, __FUNCTION__, + ext4_abort(sb, __FUNCTION__, "Detected aborted journal"); return ERR_PTR(-EROFS); } @@ -96,7 +96,7 @@ handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) * that sync() will call the filesystem's write_super callback if * appropriate. */ -int __ext3_journal_stop(const char *where, handle_t *handle) +int __ext4_journal_stop(const char *where, handle_t *handle) { struct super_block *sb; int err; @@ -109,15 +109,15 @@ int __ext3_journal_stop(const char *where, handle_t *handle) if (!err) err = rc; if (err) - __ext3_std_error(sb, where, err); + __ext4_std_error(sb, where, err); return err; } -void ext3_journal_abort_handle(const char *caller, const char *err_fn, +void ext4_journal_abort_handle(const char *caller, const char *err_fn, struct buffer_head *bh, handle_t *handle, int err) { char nbuf[16]; - const char *errstr = ext3_decode_error(NULL, err, nbuf); + const char *errstr = ext4_decode_error(NULL, err, nbuf); if (bh) BUFFER_TRACE(bh, "abort"); @@ -138,7 +138,7 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn, * inconsistencies detected or read IO failures. * * On ext2, we can store the error state of the filesystem in the - * superblock. That is not possible on ext3, because we may have other + * superblock. That is not possible on ext4, because we may have other * write ordering constraints on the superblock which prevent us from * writing it out straight away; and given that the journal is about to * be aborted, we can't rely on the current, or future, transactions to @@ -149,20 +149,20 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn, * that error until we've noted it down and cleared it. */ -static void ext3_handle_error(struct super_block *sb) +static void ext4_handle_error(struct super_block *sb) { - struct ext3_super_block *es = EXT3_SB(sb)->s_es; + struct ext4_super_block *es = EXT4_SB(sb)->s_es; - EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; - es->s_state |= cpu_to_le16(EXT3_ERROR_FS); + EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; + es->s_state |= cpu_to_le16(EXT4_ERROR_FS); if (sb->s_flags & MS_RDONLY) return; if (!test_opt (sb, ERRORS_CONT)) { - journal_t *journal = EXT3_SB(sb)->s_journal; + journal_t *journal = EXT4_SB(sb)->s_journal; - EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; + EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; if (journal) journal_abort(journal, -EIO); } @@ -170,27 +170,27 @@ static void ext3_handle_error(struct super_block *sb) printk (KERN_CRIT "Remounting filesystem read-only\n"); sb->s_flags |= MS_RDONLY; } - ext3_commit_super(sb, es, 1); + ext4_commit_super(sb, es, 1); if (test_opt(sb, ERRORS_PANIC)) - panic("EXT3-fs (device %s): panic forced after error\n", + panic("EXT4-fs (device %s): panic forced after error\n", sb->s_id); } -void ext3_error (struct super_block * sb, const char * function, +void ext4_error (struct super_block * sb, const char * function, const char * fmt, ...) { va_list args; va_start(args, fmt); - printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); + printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function); vprintk(fmt, args); printk("\n"); va_end(args); - ext3_handle_error(sb); + ext4_handle_error(sb); } -static const char *ext3_decode_error(struct super_block * sb, int errno, +static const char *ext4_decode_error(struct super_block * sb, int errno, char nbuf[16]) { char *errstr = NULL; @@ -203,7 +203,7 @@ static const char *ext3_decode_error(struct super_block * sb, int errno, errstr = "Out of memory"; break; case -EROFS: - if (!sb || EXT3_SB(sb)->s_journal->j_flags & JFS_ABORT) + if (!sb || EXT4_SB(sb)->s_journal->j_flags & JFS_ABORT) errstr = "Journal has aborted"; else errstr = "Readonly filesystem"; @@ -223,10 +223,10 @@ static const char *ext3_decode_error(struct super_block * sb, int errno, return errstr; } -/* __ext3_std_error decodes expected errors from journaling functions +/* __ext4_std_error decodes expected errors from journaling functions * automatically and invokes the appropriate error response. */ -void __ext3_std_error (struct super_block * sb, const char * function, +void __ext4_std_error (struct super_block * sb, const char * function, int errno) { char nbuf[16]; @@ -239,15 +239,15 @@ void __ext3_std_error (struct super_block * sb, const char * function, (sb->s_flags & MS_RDONLY)) return; - errstr = ext3_decode_error(sb, errno, nbuf); - printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", + errstr = ext4_decode_error(sb, errno, nbuf); + printk (KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n", sb->s_id, function, errstr); - ext3_handle_error(sb); + ext4_handle_error(sb); } /* - * ext3_abort is a much stronger failure handler than ext3_error. The + * ext4_abort is a much stronger failure handler than ext4_error. The * abort function may be used to deal with unrecoverable failures such * as journal IO errors or ENOMEM at a critical moment in log management. * @@ -256,60 +256,60 @@ void __ext3_std_error (struct super_block * sb, const char * function, * case we take the easy way out and panic immediately. */ -void ext3_abort (struct super_block * sb, const char * function, +void ext4_abort (struct super_block * sb, const char * function, const char * fmt, ...) { va_list args; - printk (KERN_CRIT "ext3_abort called.\n"); + printk (KERN_CRIT "ext4_abort called.\n"); va_start(args, fmt); - printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); + printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function); vprintk(fmt, args); printk("\n"); va_end(args); if (test_opt(sb, ERRORS_PANIC)) - panic("EXT3-fs panic from previous error\n"); + panic("EXT4-fs panic from previous error\n"); if (sb->s_flags & MS_RDONLY) return; printk(KERN_CRIT "Remounting filesystem read-only\n"); - EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; + EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; sb->s_flags |= MS_RDONLY; - EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; - journal_abort(EXT3_SB(sb)->s_journal, -EIO); + EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; + journal_abort(EXT4_SB(sb)->s_journal, -EIO); } -void ext3_warning (struct super_block * sb, const char * function, +void ext4_warning (struct super_block * sb, const char * function, const char * fmt, ...) { va_list args; va_start(args, fmt); - printk(KERN_WARNING "EXT3-fs warning (device %s): %s: ", + printk(KERN_WARNING "EXT4-fs warning (device %s): %s: ", sb->s_id, function); vprintk(fmt, args); printk("\n"); va_end(args); } -void ext3_update_dynamic_rev(struct super_block *sb) +void ext4_update_dynamic_rev(struct super_block *sb) { - struct ext3_super_block *es = EXT3_SB(sb)->s_es; + struct ext4_super_block *es = EXT4_SB(sb)->s_es; - if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV) + if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV) return; - ext3_warning(sb, __FUNCTION__, + ext4_warning(sb, __FUNCTION__, "updating to rev %d because of new feature flag, " "running e2fsck is recommended", - EXT3_DYNAMIC_REV); + EXT4_DYNAMIC_REV); - es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO); - es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE); - es->s_rev_level = cpu_to_le32(EXT3_DYNAMIC_REV); + es->s_first_ino = cpu_to_le32(EXT4_GOOD_OLD_FIRST_INO); + es->s_inode_size = cpu_to_le16(EXT4_GOOD_OLD_INODE_SIZE); + es->s_rev_level = cpu_to_le32(EXT4_DYNAMIC_REV); /* leave es->s_feature_*compat flags alone */ /* es->s_uuid will be set by e2fsck if empty */ @@ -323,7 +323,7 @@ void ext3_update_dynamic_rev(struct super_block *sb) /* * Open the external journal device */ -static struct block_device *ext3_blkdev_get(dev_t dev) +static struct block_device *ext4_blkdev_get(dev_t dev) { struct block_device *bdev; char b[BDEVNAME_SIZE]; @@ -334,7 +334,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev) return bdev; fail: - printk(KERN_ERR "EXT3: failed to open journal device %s: %ld\n", + printk(KERN_ERR "EXT4: failed to open journal device %s: %ld\n", __bdevname(dev, b), PTR_ERR(bdev)); return NULL; } @@ -342,20 +342,20 @@ fail: /* * Release the journal device */ -static int ext3_blkdev_put(struct block_device *bdev) +static int ext4_blkdev_put(struct block_device *bdev) { bd_release(bdev); return blkdev_put(bdev); } -static int ext3_blkdev_remove(struct ext3_sb_info *sbi) +static int ext4_blkdev_remove(struct ext4_sb_info *sbi) { struct block_device *bdev; int ret = -ENODEV; bdev = sbi->journal_bdev; if (bdev) { - ret = ext3_blkdev_put(bdev); + ret = ext4_blkdev_put(bdev); sbi->journal_bdev = NULL; } return ret; @@ -363,10 +363,10 @@ static int ext3_blkdev_remove(struct ext3_sb_info *sbi) static inline struct inode *orphan_list_entry(struct list_head *l) { - return &list_entry(l, struct ext3_inode_info, i_orphan)->vfs_inode; + return &list_entry(l, struct ext4_inode_info, i_orphan)->vfs_inode; } -static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) +static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi) { struct list_head *l; @@ -384,20 +384,20 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) } } -static void ext3_put_super (struct super_block * sb) +static void ext4_put_super (struct super_block * sb) { - struct ext3_sb_info *sbi = EXT3_SB(sb); - struct ext3_super_block *es = sbi->s_es; + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_super_block *es = sbi->s_es; int i; - ext3_xattr_put_super(sb); + ext4_xattr_put_super(sb); journal_destroy(sbi->s_journal); if (!(sb->s_flags & MS_RDONLY)) { - EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); + EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); es->s_state = cpu_to_le16(sbi->s_mount_state); BUFFER_TRACE(sbi->s_sbh, "marking dirty"); mark_buffer_dirty(sbi->s_sbh); - ext3_commit_super(sb, es, 1); + ext4_commit_super(sb, es, 1); } for (i = 0; i < sbi->s_gdb_count; i++) @@ -429,47 +429,47 @@ static void ext3_put_super (struct super_block * sb) */ sync_blockdev(sbi->journal_bdev); invalidate_bdev(sbi->journal_bdev, 0); - ext3_blkdev_remove(sbi); + ext4_blkdev_remove(sbi); } sb->s_fs_info = NULL; kfree(sbi); return; } -static kmem_cache_t *ext3_inode_cachep; +static kmem_cache_t *ext4_inode_cachep; /* * Called inside transaction, so use GFP_NOFS */ -static struct inode *ext3_alloc_inode(struct super_block *sb) +static struct inode *ext4_alloc_inode(struct super_block *sb) { - struct ext3_inode_info *ei; + struct ext4_inode_info *ei; - ei = kmem_cache_alloc(ext3_inode_cachep, SLAB_NOFS); + ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS); if (!ei) return NULL; -#ifdef CONFIG_EXT3_FS_POSIX_ACL - ei->i_acl = EXT3_ACL_NOT_CACHED; - ei->i_default_acl = EXT3_ACL_NOT_CACHED; +#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL + ei->i_acl = EXT4_ACL_NOT_CACHED; + ei->i_default_acl = EXT4_ACL_NOT_CACHED; #endif ei->i_block_alloc_info = NULL; ei->vfs_inode.i_version = 1; return &ei->vfs_inode; } -static void ext3_destroy_inode(struct inode *inode) +static void ext4_destroy_inode(struct inode *inode) { - kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); + kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); } static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) { - struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; + struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) { INIT_LIST_HEAD(&ei->i_orphan); -#ifdef CONFIG_EXT3_FS_XATTR +#ifdef CONFIG_EXT4DEV_FS_XATTR init_rwsem(&ei->xattr_sem); #endif mutex_init(&ei->truncate_mutex); @@ -479,46 +479,46 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) static int init_inodecache(void) { - ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", - sizeof(struct ext3_inode_info), + ext4_inode_cachep = kmem_cache_create("ext4_inode_cache", + sizeof(struct ext4_inode_info), 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), init_once, NULL); - if (ext3_inode_cachep == NULL) + if (ext4_inode_cachep == NULL) return -ENOMEM; return 0; } static void destroy_inodecache(void) { - kmem_cache_destroy(ext3_inode_cachep); + kmem_cache_destroy(ext4_inode_cachep); } -static void ext3_clear_inode(struct inode *inode) +static void ext4_clear_inode(struct inode *inode) { - struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; -#ifdef CONFIG_EXT3_FS_POSIX_ACL - if (EXT3_I(inode)->i_acl && - EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) { - posix_acl_release(EXT3_I(inode)->i_acl); - EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED; - } - if (EXT3_I(inode)->i_default_acl && - EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) { - posix_acl_release(EXT3_I(inode)->i_default_acl); - EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED; + struct ext4_block_alloc_info *rsv = EXT4_I(inode)->i_block_alloc_info; +#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL + if (EXT4_I(inode)->i_acl && + EXT4_I(inode)->i_acl != EXT4_ACL_NOT_CACHED) { + posix_acl_release(EXT4_I(inode)->i_acl); + EXT4_I(inode)->i_acl = EXT4_ACL_NOT_CACHED; + } + if (EXT4_I(inode)->i_default_acl && + EXT4_I(inode)->i_default_acl != EXT4_ACL_NOT_CACHED) { + posix_acl_release(EXT4_I(inode)->i_default_acl); + EXT4_I(inode)->i_default_acl = EXT4_ACL_NOT_CACHED; } #endif - ext3_discard_reservation(inode); - EXT3_I(inode)->i_block_alloc_info = NULL; + ext4_discard_reservation(inode); + EXT4_I(inode)->i_block_alloc_info = NULL; if (unlikely(rsv)) kfree(rsv); } -static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb) +static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb) { #if defined(CONFIG_QUOTA) - struct ext3_sb_info *sbi = EXT3_SB(sb); + struct ext4_sb_info *sbi = EXT4_SB(sb); if (sbi->s_jquota_fmt) seq_printf(seq, ",jqfmt=%s", @@ -530,32 +530,32 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl if (sbi->s_qf_names[GRPQUOTA]) seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); - if (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) + if (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) seq_puts(seq, ",usrquota"); - if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) + if (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) seq_puts(seq, ",grpquota"); #endif } -static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) { struct super_block *sb = vfs->mnt_sb; - if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) + if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) seq_puts(seq, ",data=journal"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) + else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) seq_puts(seq, ",data=ordered"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) + else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) seq_puts(seq, ",data=writeback"); - ext3_show_quota_options(seq, sb); + ext4_show_quota_options(seq, sb); return 0; } -static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) +static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp) { __u32 *objp = vobjp; unsigned long ino = objp[0]; @@ -563,14 +563,14 @@ static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) struct inode *inode; struct dentry *result; - if (ino < EXT3_FIRST_INO(sb) && ino != EXT3_ROOT_INO) + if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) return ERR_PTR(-ESTALE); - if (ino > le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count)) + if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)) return ERR_PTR(-ESTALE); /* iget isn't really right if the inode is currently unallocated!! * - * ext3_read_inode will return a bad_inode if the inode had been + * ext4_read_inode will return a bad_inode if the inode had been * deleted, so we should be safe. * * Currently we don't know the generation for parent directory, so @@ -599,37 +599,37 @@ static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") #define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) -static int ext3_dquot_initialize(struct inode *inode, int type); -static int ext3_dquot_drop(struct inode *inode); -static int ext3_write_dquot(struct dquot *dquot); -static int ext3_acquire_dquot(struct dquot *dquot); -static int ext3_release_dquot(struct dquot *dquot); -static int ext3_mark_dquot_dirty(struct dquot *dquot); -static int ext3_write_info(struct super_block *sb, int type); -static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path); -static int ext3_quota_on_mount(struct super_block *sb, int type); -static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, +static int ext4_dquot_initialize(struct inode *inode, int type); +static int ext4_dquot_drop(struct inode *inode); +static int ext4_write_dquot(struct dquot *dquot); +static int ext4_acquire_dquot(struct dquot *dquot); +static int ext4_release_dquot(struct dquot *dquot); +static int ext4_mark_dquot_dirty(struct dquot *dquot); +static int ext4_write_info(struct super_block *sb, int type); +static int ext4_quota_on(struct super_block *sb, int type, int format_id, char *path); +static int ext4_quota_on_mount(struct super_block *sb, int type); +static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off); -static ssize_t ext3_quota_write(struct super_block *sb, int type, +static ssize_t ext4_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off); -static struct dquot_operations ext3_quota_operations = { - .initialize = ext3_dquot_initialize, - .drop = ext3_dquot_drop, +static struct dquot_operations ext4_quota_operations = { + .initialize = ext4_dquot_initialize, + .drop = ext4_dquot_drop, .alloc_space = dquot_alloc_space, .alloc_inode = dquot_alloc_inode, .free_space = dquot_free_space, .free_inode = dquot_free_inode, .transfer = dquot_transfer, - .write_dquot = ext3_write_dquot, - .acquire_dquot = ext3_acquire_dquot, - .release_dquot = ext3_release_dquot, - .mark_dirty = ext3_mark_dquot_dirty, - .write_info = ext3_write_info + .write_dquot = ext4_write_dquot, + .acquire_dquot = ext4_acquire_dquot, + .release_dquot = ext4_release_dquot, + .mark_dirty = ext4_mark_dquot_dirty, + .write_info = ext4_write_info }; -static struct quotactl_ops ext3_qctl_operations = { - .quota_on = ext3_quota_on, +static struct quotactl_ops ext4_qctl_operations = { + .quota_on = ext4_quota_on, .quota_off = vfs_quota_off, .quota_sync = vfs_quota_sync, .get_info = vfs_get_dqinfo, @@ -639,31 +639,31 @@ static struct quotactl_ops ext3_qctl_operations = { }; #endif -static struct super_operations ext3_sops = { - .alloc_inode = ext3_alloc_inode, - .destroy_inode = ext3_destroy_inode, - .read_inode = ext3_read_inode, - .write_inode = ext3_write_inode, - .dirty_inode = ext3_dirty_inode, - .delete_inode = ext3_delete_inode, - .put_super = ext3_put_super, - .write_super = ext3_write_super, - .sync_fs = ext3_sync_fs, - .write_super_lockfs = ext3_write_super_lockfs, - .unlockfs = ext3_unlockfs, - .statfs = ext3_statfs, - .remount_fs = ext3_remount, - .clear_inode = ext3_clear_inode, - .show_options = ext3_show_options, +static struct super_operations ext4_sops = { + .alloc_inode = ext4_alloc_inode, + .destroy_inode = ext4_destroy_inode, + .read_inode = ext4_read_inode, + .write_inode = ext4_write_inode, + .dirty_inode = ext4_dirty_inode, + .delete_inode = ext4_delete_inode, + .put_super = ext4_put_super, + .write_super = ext4_write_super, + .sync_fs = ext4_sync_fs, + .write_super_lockfs = ext4_write_super_lockfs, + .unlockfs = ext4_unlockfs, + .statfs = ext4_statfs, + .remount_fs = ext4_remount, + .clear_inode = ext4_clear_inode, + .show_options = ext4_show_options, #ifdef CONFIG_QUOTA - .quota_read = ext3_quota_read, - .quota_write = ext3_quota_write, + .quota_read = ext4_quota_read, + .quota_write = ext4_quota_write, #endif }; -static struct export_operations ext3_export_ops = { - .get_parent = ext3_get_parent, - .get_dentry = ext3_get_dentry, +static struct export_operations ext4_export_ops = { + .get_parent = ext4_get_parent, + .get_dentry = ext4_get_dentry, }; enum { @@ -731,18 +731,18 @@ static match_table_t tokens = { {Opt_resize, "resize"}, }; -static ext3_fsblk_t get_sb_block(void **data) +static ext4_fsblk_t get_sb_block(void **data) { - ext3_fsblk_t sb_block; + ext4_fsblk_t sb_block; char *options = (char *) *data; if (!options || strncmp(options, "sb=", 3) != 0) return 1; /* Default location */ options += 3; - /*todo: use simple_strtoll with >32bit ext3 */ + /*todo: use simple_strtoll with >32bit ext4 */ sb_block = simple_strtoul(options, &options, 0); if (*options && *options != ',') { - printk("EXT3-fs: Invalid sb specification: %s\n", + printk("EXT4-fs: Invalid sb specification: %s\n", (char *) *data); return 1; } @@ -754,9 +754,9 @@ static ext3_fsblk_t get_sb_block(void **data) static int parse_options (char *options, struct super_block *sb, unsigned int *inum, unsigned long *journal_devnum, - ext3_fsblk_t *n_blocks_count, int is_remount) + ext4_fsblk_t *n_blocks_count, int is_remount) { - struct ext3_sb_info *sbi = EXT3_SB(sb); + struct ext4_sb_info *sbi = EXT4_SB(sb); char * p; substring_t args[MAX_OPT_ARGS]; int data_opt = 0; @@ -832,7 +832,7 @@ static int parse_options (char *options, struct super_block *sb, case Opt_orlov: clear_opt (sbi->s_mount_opt, OLDALLOC); break; -#ifdef CONFIG_EXT3_FS_XATTR +#ifdef CONFIG_EXT4DEV_FS_XATTR case Opt_user_xattr: set_opt (sbi->s_mount_opt, XATTR_USER); break; @@ -842,10 +842,10 @@ static int parse_options (char *options, struct super_block *sb, #else case Opt_user_xattr: case Opt_nouser_xattr: - printk("EXT3 (no)user_xattr options not supported\n"); + printk("EXT4 (no)user_xattr options not supported\n"); break; #endif -#ifdef CONFIG_EXT3_FS_POSIX_ACL +#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL case Opt_acl: set_opt(sbi->s_mount_opt, POSIX_ACL); break; @@ -855,7 +855,7 @@ static int parse_options (char *options, struct super_block *sb, #else case Opt_acl: case Opt_noacl: - printk("EXT3 (no)acl options not supported\n"); + printk("EXT4 (no)acl options not supported\n"); break; #endif case Opt_reservation: @@ -871,7 +871,7 @@ static int parse_options (char *options, struct super_block *sb, user to specify an existing inode to be the journal file. */ if (is_remount) { - printk(KERN_ERR "EXT3-fs: cannot specify " + printk(KERN_ERR "EXT4-fs: cannot specify " "journal on remount\n"); return 0; } @@ -879,7 +879,7 @@ static int parse_options (char *options, struct super_block *sb, break; case Opt_journal_inum: if (is_remount) { - printk(KERN_ERR "EXT3-fs: cannot specify " + printk(KERN_ERR "EXT4-fs: cannot specify " "journal on remount\n"); return 0; } @@ -889,7 +889,7 @@ static int parse_options (char *options, struct super_block *sb, break; case Opt_journal_dev: if (is_remount) { - printk(KERN_ERR "EXT3-fs: cannot specify " + printk(KERN_ERR "EXT4-fs: cannot specify " "journal on remount\n"); return 0; } @@ -910,24 +910,24 @@ static int parse_options (char *options, struct super_block *sb, sbi->s_commit_interval = HZ * option; break; case Opt_data_journal: - data_opt = EXT3_MOUNT_JOURNAL_DATA; + data_opt = EXT4_MOUNT_JOURNAL_DATA; goto datacheck; case Opt_data_ordered: - data_opt = EXT3_MOUNT_ORDERED_DATA; + data_opt = EXT4_MOUNT_ORDERED_DATA; goto datacheck; case Opt_data_writeback: - data_opt = EXT3_MOUNT_WRITEBACK_DATA; + data_opt = EXT4_MOUNT_WRITEBACK_DATA; datacheck: if (is_remount) { - if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) + if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) != data_opt) { printk(KERN_ERR - "EXT3-fs: cannot change data " + "EXT4-fs: cannot change data " "mode on remount\n"); return 0; } } else { - sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; + sbi->s_mount_opt &= ~EXT4_MOUNT_DATA_FLAGS; sbi->s_mount_opt |= data_opt; } break; @@ -940,21 +940,21 @@ static int parse_options (char *options, struct super_block *sb, set_qf_name: if (sb_any_quota_enabled(sb)) { printk(KERN_ERR - "EXT3-fs: Cannot change journalled " + "EXT4-fs: Cannot change journalled " "quota options when quota turned on.\n"); return 0; } qname = match_strdup(&args[0]); if (!qname) { printk(KERN_ERR - "EXT3-fs: not enough memory for " + "EXT4-fs: not enough memory for " "storing quotafile name.\n"); return 0; } if (sbi->s_qf_names[qtype] && strcmp(sbi->s_qf_names[qtype], qname)) { printk(KERN_ERR - "EXT3-fs: %s quota file already " + "EXT4-fs: %s quota file already " "specified.\n", QTYPE2NAME(qtype)); kfree(qname); return 0; @@ -962,7 +962,7 @@ set_qf_name: sbi->s_qf_names[qtype] = qname; if (strchr(sbi->s_qf_names[qtype], '/')) { printk(KERN_ERR - "EXT3-fs: quotafile must be on " + "EXT4-fs: quotafile must be on " "filesystem root.\n"); kfree(sbi->s_qf_names[qtype]); sbi->s_qf_names[qtype] = NULL; @@ -977,7 +977,7 @@ set_qf_name: qtype = GRPQUOTA; clear_qf_name: if (sb_any_quota_enabled(sb)) { - printk(KERN_ERR "EXT3-fs: Cannot change " + printk(KERN_ERR "EXT4-fs: Cannot change " "journalled quota options when " "quota turned on.\n"); return 0; @@ -1005,7 +1005,7 @@ clear_qf_name: break; case Opt_noquota: if (sb_any_quota_enabled(sb)) { - printk(KERN_ERR "EXT3-fs: Cannot change quota " + printk(KERN_ERR "EXT4-fs: Cannot change quota " "options when quota turned on.\n"); return 0; } @@ -1024,7 +1024,7 @@ clear_qf_name: case Opt_jqfmt_vfsold: case Opt_jqfmt_vfsv0: printk(KERN_ERR - "EXT3-fs: journalled quota options not " + "EXT4-fs: journalled quota options not " "supported.\n"); break; case Opt_noquota: @@ -1045,7 +1045,7 @@ clear_qf_name: break; case Opt_resize: if (!is_remount) { - printk("EXT3-fs: resize option only available " + printk("EXT4-fs: resize option only available " "for remount\n"); return 0; } @@ -1061,38 +1061,38 @@ clear_qf_name: break; default: printk (KERN_ERR - "EXT3-fs: Unrecognized mount option \"%s\" " + "EXT4-fs: Unrecognized mount option \"%s\" " "or missing value\n", p); return 0; } } #ifdef CONFIG_QUOTA if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { - if ((sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) && + if ((sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) && sbi->s_qf_names[USRQUOTA]) clear_opt(sbi->s_mount_opt, USRQUOTA); - if ((sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) && + if ((sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) clear_opt(sbi->s_mount_opt, GRPQUOTA); if ((sbi->s_qf_names[USRQUOTA] && - (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || + (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || (sbi->s_qf_names[GRPQUOTA] && - (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) { - printk(KERN_ERR "EXT3-fs: old and new quota " + (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { + printk(KERN_ERR "EXT4-fs: old and new quota " "format mixing.\n"); return 0; } if (!sbi->s_jquota_fmt) { - printk(KERN_ERR "EXT3-fs: journalled quota format " + printk(KERN_ERR "EXT4-fs: journalled quota format " "not specified.\n"); return 0; } } else { if (sbi->s_jquota_fmt) { - printk(KERN_ERR "EXT3-fs: journalled quota format " + printk(KERN_ERR "EXT4-fs: journalled quota format " "specified with no journalling " "enabled.\n"); return 0; @@ -1102,68 +1102,68 @@ clear_qf_name: return 1; } -static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, +static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, int read_only) { - struct ext3_sb_info *sbi = EXT3_SB(sb); + struct ext4_sb_info *sbi = EXT4_SB(sb); int res = 0; - if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { - printk (KERN_ERR "EXT3-fs warning: revision level too high, " + if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { + printk (KERN_ERR "EXT4-fs warning: revision level too high, " "forcing read-only mode\n"); res = MS_RDONLY; } if (read_only) return res; - if (!(sbi->s_mount_state & EXT3_VALID_FS)) - printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, " + if (!(sbi->s_mount_state & EXT4_VALID_FS)) + printk (KERN_WARNING "EXT4-fs warning: mounting unchecked fs, " "running e2fsck is recommended\n"); - else if ((sbi->s_mount_state & EXT3_ERROR_FS)) + else if ((sbi->s_mount_state & EXT4_ERROR_FS)) printk (KERN_WARNING - "EXT3-fs warning: mounting fs with errors, " + "EXT4-fs warning: mounting fs with errors, " "running e2fsck is recommended\n"); else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && le16_to_cpu(es->s_mnt_count) >= (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) printk (KERN_WARNING - "EXT3-fs warning: maximal mount count reached, " + "EXT4-fs warning: maximal mount count reached, " "running e2fsck is recommended\n"); else if (le32_to_cpu(es->s_checkinterval) && (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds())) printk (KERN_WARNING - "EXT3-fs warning: checktime reached, " + "EXT4-fs warning: checktime reached, " "running e2fsck is recommended\n"); #if 0 /* @@@ We _will_ want to clear the valid bit if we find inconsistencies, to force a fsck at reboot. But for a plain journaled filesystem we can keep it set as valid forever! :) */ - es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3_VALID_FS); + es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT4_VALID_FS); #endif if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) - es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); + es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); es->s_mtime = cpu_to_le32(get_seconds()); - ext3_update_dynamic_rev(sb); - EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); + ext4_update_dynamic_rev(sb); + EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); - ext3_commit_super(sb, es, 1); + ext4_commit_super(sb, es, 1); if (test_opt(sb, DEBUG)) - printk(KERN_INFO "[EXT3 FS bs=%lu, gc=%lu, " + printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%lu, " "bpg=%lu, ipg=%lu, mo=%04lx]\n", sb->s_blocksize, sbi->s_groups_count, - EXT3_BLOCKS_PER_GROUP(sb), - EXT3_INODES_PER_GROUP(sb), + EXT4_BLOCKS_PER_GROUP(sb), + EXT4_INODES_PER_GROUP(sb), sbi->s_mount_opt); - printk(KERN_INFO "EXT3 FS on %s, ", sb->s_id); - if (EXT3_SB(sb)->s_journal->j_inode == NULL) { + printk(KERN_INFO "EXT4 FS on %s, ", sb->s_id); + if (EXT4_SB(sb)->s_journal->j_inode == NULL) { char b[BDEVNAME_SIZE]; printk("external journal on %s\n", - bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); + bdevname(EXT4_SB(sb)->s_journal->j_dev, b)); } else { printk("internal journal\n"); } @@ -1171,16 +1171,16 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, } /* Called at mount-time, super-block is locked */ -static int ext3_check_descriptors (struct super_block * sb) +static int ext4_check_descriptors (struct super_block * sb) { - struct ext3_sb_info *sbi = EXT3_SB(sb); - ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); - ext3_fsblk_t last_block; - struct ext3_group_desc * gdp = NULL; + struct ext4_sb_info *sbi = EXT4_SB(sb); + ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); + ext4_fsblk_t last_block; + struct ext4_group_desc * gdp = NULL; int desc_block = 0; int i; - ext3_debug ("Checking group descriptors"); + ext4_debug ("Checking group descriptors"); for (i = 0; i < sbi->s_groups_count; i++) { @@ -1188,15 +1188,15 @@ static int ext3_check_descriptors (struct super_block * sb) last_block = le32_to_cpu(sbi->s_es->s_ |