]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ext2/super.c
Slab API: remove useless ctor parameter and reorder parameters
[linux-2.6-omap-h63xx.git] / fs / ext2 / super.c
index 16337bff0272e1ca9dad792eba727f4e11778cb9..04bc96caa7b2e6dfe797018032a8ffcbdbaee0f0 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/parser.h>
 #include <linux/random.h>
 #include <linux/buffer_head.h>
+#include <linux/exportfs.h>
 #include <linux/smp_lock.h>
 #include <linux/vfs.h>
 #include <linux/seq_file.h>
@@ -156,7 +157,7 @@ static void ext2_destroy_inode(struct inode *inode)
        kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
 }
 
-static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
+static void init_once(struct kmem_cache * cachep, void *foo)
 {
        struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
 
@@ -166,14 +167,14 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
 #endif
        inode_init_once(&ei->vfs_inode);
 }
+
 static int init_inodecache(void)
 {
        ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
                                             sizeof(struct ext2_inode_info),
                                             0, (SLAB_RECLAIM_ACCOUNT|
                                                SLAB_MEM_SPREAD),
-                                            init_once, NULL);
+                                            init_once);
        if (ext2_inode_cachep == NULL)
                return -ENOMEM;
        return 0;
@@ -579,7 +580,7 @@ static int ext2_check_descriptors (struct super_block * sb)
                        return 0;
                }
                if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
-                   le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
+                   le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
                    last_block)
                {
                        ext2_error (sb, "ext2_check_descriptors",
@@ -652,6 +653,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
        int db_count;
        int i, j;
        __le32 features;
+       int err;
 
        sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
        if (!sbi)
@@ -882,13 +884,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
                goto failed_mount;
        }
        bgl_lock_init(&sbi->s_blockgroup_lock);
-       sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
-                              GFP_KERNEL);
+       sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
        if (!sbi->s_debts) {
                printk ("EXT2-fs: not enough memory\n");
                goto failed_mount_group_desc;
        }
-       memset(sbi->s_debts, 0, sbi->s_groups_count * sizeof(*sbi->s_debts));
        for (i = 0; i < db_count; i++) {
                block = descriptor_loc(sb, logic_sb_block, i);
                sbi->s_group_desc[i] = sb_bread(sb, block);
@@ -907,12 +907,20 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
        get_random_bytes(&sbi->s_next_generation, sizeof(u32));
        spin_lock_init(&sbi->s_next_gen_lock);
 
-       percpu_counter_init(&sbi->s_freeblocks_counter,
+       err = percpu_counter_init(&sbi->s_freeblocks_counter,
                                ext2_count_free_blocks(sb));
-       percpu_counter_init(&sbi->s_freeinodes_counter,
+       if (!err) {
+               err = percpu_counter_init(&sbi->s_freeinodes_counter,
                                ext2_count_free_inodes(sb));
-       percpu_counter_init(&sbi->s_dirs_counter,
+       }
+       if (!err) {
+               err = percpu_counter_init(&sbi->s_dirs_counter,
                                ext2_count_dirs(sb));
+       }
+       if (err) {
+               printk(KERN_ERR "EXT2-fs: insufficient memory\n");
+               goto failed_mount3;
+       }
        /*
         * set up enough so that it can read an inode
         */
@@ -1038,6 +1046,15 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
 
+       ext2_xip_verify_sb(sb); /* see if bdev supports xip, unset
+                                   EXT2_MOUNT_XIP if not */
+
+       if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
+               printk("XIP: Unsupported blocksize\n");
+               err = -EINVAL;
+               goto restore_opts;
+       }
+
        es = sbi->s_es;
        if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
            (old_mount_opt & EXT2_MOUNT_XIP)) &&
@@ -1090,15 +1107,18 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
        struct super_block *sb = dentry->d_sb;
        struct ext2_sb_info *sbi = EXT2_SB(sb);
        struct ext2_super_block *es = sbi->s_es;
-       unsigned long overhead;
-       int i;
        u64 fsid;
 
        if (test_opt (sb, MINIX_DF))
-               overhead = 0;
-       else {
+               sbi->s_overhead_last = 0;
+       else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
+               unsigned long i, overhead = 0;
+               smp_rmb();
+
                /*
-                * Compute the overhead (FS structures)
+                * Compute the overhead (FS structures). This is constant
+                * for a given filesystem unless the number of block groups
+                * changes so we cache the previous value until it does.
                 */
 
                /*
@@ -1122,17 +1142,22 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
                 */
                overhead += (sbi->s_groups_count *
                             (2 + sbi->s_itb_per_group));
+               sbi->s_overhead_last = overhead;
+               smp_wmb();
+               sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
        }
 
        buf->f_type = EXT2_SUPER_MAGIC;
        buf->f_bsize = sb->s_blocksize;
-       buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
+       buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
        buf->f_bfree = ext2_count_free_blocks(sb);
+       es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
        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 = 0;
        buf->f_files = le32_to_cpu(es->s_inodes_count);
        buf->f_ffree = ext2_count_free_inodes(sb);
+       es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
        buf->f_namelen = EXT2_NAME_LEN;
        fsid = le64_to_cpup((void *)es->s_uuid) ^
               le64_to_cpup((void *)es->s_uuid + sizeof(u64));