]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ext2/super.c
Pull sbs into release branch
[linux-2.6-omap-h63xx.git] / fs / ext2 / super.c
index a046a419d8afd65a87671a7963da8b2cf3a0b887..68579a0ed3f0a6617b8ecbe59e9ce826f5be2f2d 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>
@@ -160,23 +161,20 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
 {
        struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
 
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR) {
-               rwlock_init(&ei->i_meta_lock);
+       rwlock_init(&ei->i_meta_lock);
 #ifdef CONFIG_EXT2_FS_XATTR
-               init_rwsem(&ei->xattr_sem);
+       init_rwsem(&ei->xattr_sem);
 #endif
-               inode_init_once(&ei->vfs_inode);
-       }
+       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;
@@ -885,13 +883,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);
@@ -1041,6 +1037,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)) &&
@@ -1093,15 +1098,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.
                 */
 
                /*
@@ -1125,17 +1133,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));