Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[powerpc.git] / fs / ext4 / super.c
index 9e32a2a..486a641 100644 (file)
@@ -20,9 +20,9 @@
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/time.h>
-#include <linux/jbd.h>
+#include <linux/jbd2.h>
 #include <linux/ext4_fs.h>
-#include <linux/ext4_jbd.h>
+#include <linux/ext4_jbd2.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
@@ -62,8 +62,57 @@ 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);
 
+
+ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
+                              struct ext4_group_desc *bg)
+{
+       return le32_to_cpu(bg->bg_block_bitmap) |
+               (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
+                (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0);
+}
+
+ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
+                              struct ext4_group_desc *bg)
+{
+       return le32_to_cpu(bg->bg_inode_bitmap) |
+               (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
+                (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
+}
+
+ext4_fsblk_t ext4_inode_table(struct super_block *sb,
+                             struct ext4_group_desc *bg)
+{
+       return le32_to_cpu(bg->bg_inode_table) |
+               (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
+                (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0);
+}
+
+void ext4_block_bitmap_set(struct super_block *sb,
+                          struct ext4_group_desc *bg, ext4_fsblk_t blk)
+{
+       bg->bg_block_bitmap = cpu_to_le32((u32)blk);
+       if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
+               bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
+}
+
+void ext4_inode_bitmap_set(struct super_block *sb,
+                          struct ext4_group_desc *bg, ext4_fsblk_t blk)
+{
+       bg->bg_inode_bitmap  = cpu_to_le32((u32)blk);
+       if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
+               bg->bg_inode_bitmap_hi = cpu_to_le32(blk >> 32);
+}
+
+void ext4_inode_table_set(struct super_block *sb,
+                         struct ext4_group_desc *bg, ext4_fsblk_t blk)
+{
+       bg->bg_inode_table = cpu_to_le32((u32)blk);
+       if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
+               bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
+}
+
 /*
- * Wrappers for journal_start/end.
+ * Wrappers for jbd2_journal_start/end.
  *
  * The only special thing we need to do here is to make sure that all
  * journal_end calls result in the superblock being marked dirty, so
@@ -87,12 +136,12 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
                return ERR_PTR(-EROFS);
        }
 
-       return journal_start(journal, nblocks);
+       return jbd2_journal_start(journal, nblocks);
 }
 
 /*
  * The only special thing we need to do here is to make sure that all
- * journal_stop calls result in the superblock being marked dirty, so
+ * jbd2_journal_stop calls result in the superblock being marked dirty, so
  * that sync() will call the filesystem's write_super callback if
  * appropriate.
  */
@@ -104,7 +153,7 @@ int __ext4_journal_stop(const char *where, handle_t *handle)
 
        sb = handle->h_transaction->t_journal->j_private;
        err = handle->h_err;
-       rc = journal_stop(handle);
+       rc = jbd2_journal_stop(handle);
 
        if (!err)
                err = rc;
@@ -131,7 +180,7 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn,
        printk(KERN_ERR "%s: aborting transaction: %s in %s\n",
               caller, errstr, err_fn);
 
-       journal_abort_handle(handle);
+       jbd2_journal_abort_handle(handle);
 }
 
 /* Deal with the reporting of failure conditions on a filesystem such as
@@ -144,7 +193,7 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn,
  * be aborted, we can't rely on the current, or future, transactions to
  * write out the superblock safely.
  *
- * We'll just use the journal_abort() error code to record an error in
+ * We'll just use the jbd2_journal_abort() error code to record an error in
  * the journal instead.  On recovery, the journal will compain about
  * that error until we've noted it down and cleared it.
  */
@@ -164,7 +213,7 @@ static void ext4_handle_error(struct super_block *sb)
 
                EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
                if (journal)
-                       journal_abort(journal, -EIO);
+                       jbd2_journal_abort(journal, -EIO);
        }
        if (test_opt (sb, ERRORS_RO)) {
                printk (KERN_CRIT "Remounting filesystem read-only\n");
@@ -203,7 +252,7 @@ static const char *ext4_decode_error(struct super_block * sb, int errno,
                errstr = "Out of memory";
                break;
        case -EROFS:
-               if (!sb || EXT4_SB(sb)->s_journal->j_flags & JFS_ABORT)
+               if (!sb || EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT)
                        errstr = "Journal has aborted";
                else
                        errstr = "Readonly filesystem";
@@ -279,7 +328,7 @@ void ext4_abort (struct super_block * sb, const char * function,
        EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
        sb->s_flags |= MS_RDONLY;
        EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
-       journal_abort(EXT4_SB(sb)->s_journal, -EIO);
+       jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
 }
 
 void ext4_warning (struct super_block * sb, const char * function,
@@ -390,8 +439,9 @@ static void ext4_put_super (struct super_block * sb)
        struct ext4_super_block *es = sbi->s_es;
        int i;
 
+       ext4_ext_release(sb);
        ext4_xattr_put_super(sb);
-       journal_destroy(sbi->s_journal);
+       jbd2_journal_destroy(sbi->s_journal);
        if (!(sb->s_flags & MS_RDONLY)) {
                EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
                es->s_state = cpu_to_le16(sbi->s_mount_state);
@@ -436,7 +486,7 @@ static void ext4_put_super (struct super_block * sb)
        return;
 }
 
-static kmem_cache_t *ext4_inode_cachep;
+static struct kmem_cache *ext4_inode_cachep;
 
 /*
  * Called inside transaction, so use GFP_NOFS
@@ -445,7 +495,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
 {
        struct ext4_inode_info *ei;
 
-       ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS);
+       ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
@@ -454,6 +504,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
 #endif
        ei->i_block_alloc_info = NULL;
        ei->vfs_inode.i_version = 1;
+       memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
        return &ei->vfs_inode;
 }
 
@@ -462,7 +513,7 @@ static void ext4_destroy_inode(struct inode *inode)
        kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
 
@@ -677,7 +728,7 @@ enum {
        Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
        Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
        Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
-       Opt_grpquota
+       Opt_grpquota, Opt_extents,
 };
 
 static match_table_t tokens = {
@@ -727,6 +778,7 @@ static match_table_t tokens = {
        {Opt_quota, "quota"},
        {Opt_usrquota, "usrquota"},
        {Opt_barrier, "barrier=%u"},
+       {Opt_extents, "extents"},
        {Opt_err, NULL},
        {Opt_resize, "resize"},
 };
@@ -1059,6 +1111,9 @@ clear_qf_name:
                case Opt_bh:
                        clear_opt(sbi->s_mount_opt, NOBH);
                        break;
+               case Opt_extents:
+                       set_opt (sbi->s_mount_opt, EXTENTS);
+                       break;
                default:
                        printk (KERN_ERR
                                "EXT4-fs: Unrecognized mount option \"%s\" "
@@ -1136,9 +1191,10 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
                        "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! :) */
+                * 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) & ~EXT4_VALID_FS);
 #endif
        if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
@@ -1176,6 +1232,9 @@ static int ext4_check_descriptors (struct super_block * sb)
        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;
+       ext4_fsblk_t block_bitmap;
+       ext4_fsblk_t inode_bitmap;
+       ext4_fsblk_t inode_table;
        struct ext4_group_desc * gdp = NULL;
        int desc_block = 0;
        int i;
@@ -1185,7 +1244,7 @@ static int ext4_check_descriptors (struct super_block * sb)
        for (i = 0; i < sbi->s_groups_count; i++)
        {
                if (i == sbi->s_groups_count - 1)
-                       last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
+                       last_block = ext4_blocks_count(sbi->s_es) - 1;
                else
                        last_block = first_block +
                                (EXT4_BLOCKS_PER_GROUP(sb) - 1);
@@ -1193,42 +1252,40 @@ static int ext4_check_descriptors (struct super_block * sb)
                if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
                        gdp = (struct ext4_group_desc *)
                                        sbi->s_group_desc[desc_block++]->b_data;
-               if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
-                   le32_to_cpu(gdp->bg_block_bitmap) > last_block)
+               block_bitmap = ext4_block_bitmap(sb, gdp);
+               if (block_bitmap < first_block || block_bitmap > last_block)
                {
                        ext4_error (sb, "ext4_check_descriptors",
                                    "Block bitmap for group %d"
-                                   " not in group (block %lu)!",
-                                   i, (unsigned long)
-                                       le32_to_cpu(gdp->bg_block_bitmap));
+                                   " not in group (block %llu)!",
+                                   i, block_bitmap);
                        return 0;
                }
-               if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
-                   le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
+               inode_bitmap = ext4_inode_bitmap(sb, gdp);
+               if (inode_bitmap < first_block || inode_bitmap > last_block)
                {
                        ext4_error (sb, "ext4_check_descriptors",
                                    "Inode bitmap for group %d"
-                                   " not in group (block %lu)!",
-                                   i, (unsigned long)
-                                       le32_to_cpu(gdp->bg_inode_bitmap));
+                                   " not in group (block %llu)!",
+                                   i, inode_bitmap);
                        return 0;
                }
-               if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
-                   le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
-                   last_block)
+               inode_table = ext4_inode_table(sb, gdp);
+               if (inode_table < first_block ||
+                   inode_table + sbi->s_itb_per_group > last_block)
                {
                        ext4_error (sb, "ext4_check_descriptors",
                                    "Inode table for group %d"
-                                   " not in group (block %lu)!",
-                                   i, (unsigned long)
-                                       le32_to_cpu(gdp->bg_inode_table));
+                                   " not in group (block %llu)!",
+                                   i, inode_table);
                        return 0;
                }
                first_block += EXT4_BLOCKS_PER_GROUP(sb);
-               gdp++;
+               gdp = (struct ext4_group_desc *)
+                       ((__u8 *)gdp + EXT4_DESC_SIZE(sb));
        }
 
-       sbi->s_es->s_free_blocks_count=cpu_to_le32(ext4_count_free_blocks(sb));
+       ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
        sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb));
        return 1;
 }
@@ -1264,6 +1321,12 @@ static void ext4_orphan_cleanup (struct super_block * sb,
                return;
        }
 
+       if (bdev_read_only(sb->s_bdev)) {
+               printk(KERN_ERR "EXT4-fs: write access "
+                       "unavailable, skipping orphan cleanup.\n");
+               return;
+       }
+
        if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
                if (es->s_last_orphan)
                        jbd_debug(1, "Errors on filesystem, "
@@ -1367,8 +1430,7 @@ static loff_t ext4_max_size(int bits)
 }
 
 static ext4_fsblk_t descriptor_loc(struct super_block *sb,
-                                   ext4_fsblk_t logic_sb_block,
-                                   int nr)
+                               ext4_fsblk_t logical_sb_block, int nr)
 {
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        unsigned long bg, first_meta_bg;
@@ -1378,7 +1440,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
 
        if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) ||
            nr < first_meta_bg)
-               return (logic_sb_block + nr + 1);
+               return logical_sb_block + nr + 1;
        bg = sbi->s_desc_per_block * nr;
        if (ext4_bg_has_super(sb, bg))
                has_super = 1;
@@ -1393,7 +1455,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
        struct ext4_sb_info *sbi;
        ext4_fsblk_t block;
        ext4_fsblk_t sb_block = get_sb_block(&data);
-       ext4_fsblk_t logic_sb_block;
+       ext4_fsblk_t logical_sb_block;
        unsigned long offset = 0;
        unsigned int journal_inum = 0;
        unsigned long journal_devnum = 0;
@@ -1405,6 +1467,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
        int i;
        int needs_recovery;
        __le32 features;
+       __u64 blocks_count;
 
        sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
        if (!sbi)
@@ -1427,13 +1490,13 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
         * block sizes.  We need to calculate the offset from buffer start.
         */
        if (blocksize != EXT4_MIN_BLOCK_SIZE) {
-               logic_sb_block = (sb_block * EXT4_MIN_BLOCK_SIZE) / blocksize;
-               offset = (sb_block * EXT4_MIN_BLOCK_SIZE) % blocksize;
+               logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
+               offset = do_div(logical_sb_block, blocksize);
        } else {
-               logic_sb_block = sb_block;
+               logical_sb_block = sb_block;
        }
 
-       if (!(bh = sb_bread(sb, logic_sb_block))) {
+       if (!(bh = sb_bread(sb, logical_sb_block))) {
                printk (KERN_ERR "EXT4-fs: unable to read superblock\n");
                goto out_fail;
        }
@@ -1470,6 +1533,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, ERRORS_PANIC);
        else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_RO)
                set_opt(sbi->s_mount_opt, ERRORS_RO);
+       else
+               set_opt(sbi->s_mount_opt, ERRORS_CONT);
 
        sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
        sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
@@ -1533,9 +1598,9 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
 
                brelse (bh);
                sb_set_blocksize(sb, blocksize);
-               logic_sb_block = (sb_block * EXT4_MIN_BLOCK_SIZE) / blocksize;
-               offset = (sb_block * EXT4_MIN_BLOCK_SIZE) % blocksize;
-               bh = sb_bread(sb, logic_sb_block);
+               logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
+               offset = do_div(logical_sb_block, blocksize);
+               bh = sb_bread(sb, logical_sb_block);
                if (!bh) {
                        printk(KERN_ERR
                               "EXT4-fs: Can't read superblock on 2nd try.\n");
@@ -1575,7 +1640,18 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                       sbi->s_frag_size, blocksize);
                goto failed_mount;
        }
-       sbi->s_frags_per_block = 1;
+       sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
+       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
+               if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
+                   sbi->s_desc_size > EXT4_MAX_DESC_SIZE ||
+                   sbi->s_desc_size & (sbi->s_desc_size - 1)) {
+                       printk(KERN_ERR
+                              "EXT4-fs: unsupported descriptor size %lu\n",
+                              sbi->s_desc_size);
+                       goto failed_mount;
+               }
+       } else
+               sbi->s_desc_size = EXT4_MIN_DESC_SIZE;
        sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
        sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
        sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
@@ -1586,7 +1662,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                goto cantfind_ext4;
        sbi->s_itb_per_group = sbi->s_inodes_per_group /
                                        sbi->s_inodes_per_block;
-       sbi->s_desc_per_block = blocksize / sizeof(struct ext4_group_desc);
+       sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
        sbi->s_sbh = bh;
        sbi->s_mount_state = le16_to_cpu(es->s_state);
        sbi->s_addr_per_block_bits = log2(EXT4_ADDR_PER_BLOCK(sb));
@@ -1614,7 +1690,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                goto failed_mount;
        }
 
-       if (le32_to_cpu(es->s_blocks_count) >
+       if (ext4_blocks_count(es) >
                    (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
                printk(KERN_ERR "EXT4-fs: filesystem on %s:"
                        " too large to mount safely\n", sb->s_id);
@@ -1626,9 +1702,11 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
 
        if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
                goto cantfind_ext4;
-       sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
-                              le32_to_cpu(es->s_first_data_block) - 1)
-                                      / EXT4_BLOCKS_PER_GROUP(sb)) + 1;
+       blocks_count = (ext4_blocks_count(es) -
+                       le32_to_cpu(es->s_first_data_block) +
+                       EXT4_BLOCKS_PER_GROUP(sb) - 1);
+       do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb));
+       sbi->s_groups_count = blocks_count;
        db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
                   EXT4_DESC_PER_BLOCK(sb);
        sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
@@ -1641,7 +1719,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
        bgl_lock_init(&sbi->s_blockgroup_lock);
 
        for (i = 0; i < db_count; i++) {
-               block = descriptor_loc(sb, logic_sb_block, i);
+               block = descriptor_loc(sb, logical_sb_block, i);
                sbi->s_group_desc[i] = sb_bread(sb, block);
                if (!sbi->s_group_desc[i]) {
                        printk (KERN_ERR "EXT4-fs: "
@@ -1720,10 +1798,11 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
        switch (test_opt(sb, DATA_FLAGS)) {
        case 0:
                /* No mode set, assume a default based on the journal
-                   capabilities: ORDERED_DATA if the journal can
-                   cope, else JOURNAL_DATA */
-               if (journal_check_available_features
-                   (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE))
+                * capabilities: ORDERED_DATA if the journal can
+                * cope, else JOURNAL_DATA
+                */
+               if (jbd2_journal_check_available_features
+                   (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE))
                        set_opt(sbi->s_mount_opt, ORDERED_DATA);
                else
                        set_opt(sbi->s_mount_opt, JOURNAL_DATA);
@@ -1731,8 +1810,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
 
        case EXT4_MOUNT_ORDERED_DATA:
        case EXT4_MOUNT_WRITEBACK_DATA:
-               if (!journal_check_available_features
-                   (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) {
+               if (!jbd2_journal_check_available_features
+                   (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
                        printk(KERN_ERR "EXT4-fs: Journal does not support "
                               "requested data journaling mode\n");
                        goto failed_mount4;
@@ -1749,7 +1828,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                }
        }
        /*
-        * The journal_load will have done any necessary log recovery,
+        * The jbd2_journal_load will have done any necessary log recovery,
         * so we can safely mount the rest of the filesystem now.
         */
 
@@ -1787,6 +1866,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
                test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
                "writeback");
 
+       ext4_ext_init(sb);
+
        lock_kernel();
        return 0;
 
@@ -1797,7 +1878,7 @@ cantfind_ext4:
        goto failed_mount;
 
 failed_mount4:
-       journal_destroy(sbi->s_journal);
+       jbd2_journal_destroy(sbi->s_journal);
 failed_mount3:
        percpu_counter_destroy(&sbi->s_freeblocks_counter);
        percpu_counter_destroy(&sbi->s_freeinodes_counter);
@@ -1837,9 +1918,9 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
 
        spin_lock(&journal->j_state_lock);
        if (test_opt(sb, BARRIER))
-               journal->j_flags |= JFS_BARRIER;
+               journal->j_flags |= JBD2_BARRIER;
        else
-               journal->j_flags &= ~JFS_BARRIER;
+               journal->j_flags &= ~JBD2_BARRIER;
        spin_unlock(&journal->j_state_lock);
 }
 
@@ -1873,7 +1954,7 @@ static journal_t *ext4_get_journal(struct super_block *sb,
                return NULL;
        }
 
-       journal = journal_init_inode(journal_inode);
+       journal = jbd2_journal_init_inode(journal_inode);
        if (!journal) {
                printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");
                iput(journal_inode);
@@ -1941,11 +2022,11 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
                goto out_bdev;
        }
 
-       len = le32_to_cpu(es->s_blocks_count);
+       len = ext4_blocks_count(es);
        start = sb_block + 1;
        brelse(bh);     /* we're done with the superblock */
 
-       journal = journal_init_dev(bdev, sb->s_bdev,
+       journal = jbd2_journal_init_dev(bdev, sb->s_bdev,
                                        start, len, blocksize);
        if (!journal) {
                printk(KERN_ERR "EXT4-fs: failed to create device journal\n");
@@ -1968,7 +2049,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
        ext4_init_journal_params(sb, journal);
        return journal;
 out_journal:
-       journal_destroy(journal);
+       jbd2_journal_destroy(journal);
 out_bdev:
        ext4_blkdev_put(bdev);
        return NULL;
@@ -2029,22 +2110,22 @@ static int ext4_load_journal(struct super_block *sb,
        }
 
        if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
-               err = journal_update_format(journal);
+               err = jbd2_journal_update_format(journal);
                if (err)  {
                        printk(KERN_ERR "EXT4-fs: error updating journal.\n");
-                       journal_destroy(journal);
+                       jbd2_journal_destroy(journal);
                        return err;
                }
        }
 
        if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER))
-               err = journal_wipe(journal, !really_read_only);
+               err = jbd2_journal_wipe(journal, !really_read_only);
        if (!err)
-               err = journal_load(journal);
+               err = jbd2_journal_load(journal);
 
        if (err) {
                printk(KERN_ERR "EXT4-fs: error loading journal.\n");
-               journal_destroy(journal);
+               jbd2_journal_destroy(journal);
                return err;
        }
 
@@ -2081,9 +2162,9 @@ static int ext4_create_journal(struct super_block * sb,
        printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n",
               journal_inum);
 
-       if (journal_create(journal)) {
+       if (jbd2_journal_create(journal)) {
                printk(KERN_ERR "EXT4-fs: error creating journal.\n");
-               journal_destroy(journal);
+               jbd2_journal_destroy(journal);
                return -EIO;
        }
 
@@ -2111,7 +2192,7 @@ static void ext4_commit_super (struct super_block * sb,
        if (!sbh)
                return;
        es->s_wtime = cpu_to_le32(get_seconds());
-       es->s_free_blocks_count = cpu_to_le32(ext4_count_free_blocks(sb));
+       ext4_free_blocks_count_set(es, ext4_count_free_blocks(sb));
        es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
        BUFFER_TRACE(sbh, "marking dirty");
        mark_buffer_dirty(sbh);
@@ -2130,15 +2211,15 @@ static void ext4_mark_recovery_complete(struct super_block * sb,
 {
        journal_t *journal = EXT4_SB(sb)->s_journal;
 
-       journal_lock_updates(journal);
-       journal_flush(journal);
+       jbd2_journal_lock_updates(journal);
+       jbd2_journal_flush(journal);
        if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) &&
            sb->s_flags & MS_RDONLY) {
                EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
                sb->s_dirt = 0;
                ext4_commit_super(sb, es, 1);
        }
-       journal_unlock_updates(journal);
+       jbd2_journal_unlock_updates(journal);
 }
 
 /*
@@ -2160,7 +2241,7 @@ static void ext4_clear_journal_err(struct super_block * sb,
         * journal by a prior ext4_error() or ext4_abort()
         */
 
-       j_errno = journal_errno(journal);
+       j_errno = jbd2_journal_errno(journal);
        if (j_errno) {
                char nbuf[16];
 
@@ -2174,7 +2255,7 @@ static void ext4_clear_journal_err(struct super_block * sb,
                es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
                ext4_commit_super (sb, es, 1);
 
-               journal_clear_err(journal);
+               jbd2_journal_clear_err(journal);
        }
 }
 
@@ -2217,9 +2298,9 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
        tid_t target;
 
        sb->s_dirt = 0;
-       if (journal_start_commit(EXT4_SB(sb)->s_journal, &target)) {
+       if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) {
                if (wait)
-                       log_wait_commit(EXT4_SB(sb)->s_journal, target);
+                       jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target);
        }
        return 0;
 }
@@ -2236,8 +2317,8 @@ static void ext4_write_super_lockfs(struct super_block *sb)
                journal_t *journal = EXT4_SB(sb)->s_journal;
 
                /* Now we set up the journal barrier. */
-               journal_lock_updates(journal);
-               journal_flush(journal);
+               jbd2_journal_lock_updates(journal);
+               jbd2_journal_flush(journal);
 
                /* Journal blocked and flushed, clear needs_recovery flag. */
                EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
@@ -2257,7 +2338,7 @@ static void ext4_unlockfs(struct super_block *sb)
                EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
                ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
                unlock_super(sb);
-               journal_unlock_updates(EXT4_SB(sb)->s_journal);
+               jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
        }
 }
 
@@ -2304,7 +2385,7 @@ static int ext4_remount (struct super_block * sb, int * flags, char * data)
        ext4_init_journal_params(sb, sbi->s_journal);
 
        if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
-               n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
+               n_blocks_count > ext4_blocks_count(es)) {
                if (sbi->s_mount_opt & EXT4_MOUNT_ABORT) {
                        err = -EROFS;
                        goto restore_opts;
@@ -2385,6 +2466,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
        struct ext4_super_block *es = sbi->s_es;
        ext4_fsblk_t overhead;
        int i;
+       u64 fsid;
 
        if (test_opt (sb, MINIX_DF))
                overhead = 0;
@@ -2423,14 +2505,18 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
 
        buf->f_type = EXT4_SUPER_MAGIC;
        buf->f_bsize = sb->s_blocksize;
-       buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
+       buf->f_blocks = ext4_blocks_count(es) - overhead;
        buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
-       buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
-       if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
+       buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es);
+       if (buf->f_bfree < ext4_r_blocks_count(es))
                buf->f_bavail = 0;
        buf->f_files = le32_to_cpu(es->s_inodes_count);
        buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
        buf->f_namelen = EXT4_NAME_LEN;
+       fsid = le64_to_cpup((void *)es->s_uuid) ^
+              le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+       buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
+       buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
        return 0;
 }
 
@@ -2438,9 +2524,9 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
  * is locked for write. Otherwise the are possible deadlocks:
  * Process 1                         Process 2
  * ext4_create()                     quota_sync()
- *   journal_start()                   write_dquot()
+ *   jbd2_journal_start()                   write_dquot()
  *   DQUOT_INIT()                        down(dqio_mutex)
- *     down(dqio_mutex)                    journal_start()
+ *     down(dqio_mutex)                    jbd2_journal_start()
  *
  */
 
@@ -2729,7 +2815,7 @@ static int __init init_ext4_fs(void)
        err = init_inodecache();
        if (err)
                goto out1;
-        err = register_filesystem(&ext4dev_fs_type);
+       err = register_filesystem(&ext4dev_fs_type);
        if (err)
                goto out;
        return 0;