This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / ext2 / balloc.c
index 6591abe..21cee4f 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/quotaops.h>
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
+#include <linux/capability.h>
+#include <linux/vs_dlimit.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
@@ -108,6 +110,8 @@ static int reserve_blocks(struct super_block *sb, int count)
        free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
        root_blocks = le32_to_cpu(es->s_r_blocks_count);
 
+       DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
+
        if (free_blocks < count)
                count = free_blocks;
 
@@ -258,6 +262,7 @@ do_more:
        }
 error_return:
        brelse(bitmap_bh);
+       DLIMIT_FREE_BLOCK(inode, freed);
        release_blocks(sb, freed);
        DQUOT_FREE_BLOCK(inode, freed);
 }
@@ -361,6 +366,10 @@ int ext2_new_block(struct inode *inode, unsigned long goal,
                *err = -ENOSPC;
                goto out_dquot;
        }
+       if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
+               *err = -ENOSPC;
+               goto out_dlimit;
+       }
 
        ext2_debug ("goal=%lu.\n", goal);
 
@@ -508,6 +517,8 @@ got_block:
        *err = 0;
 out_release:
        group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
+       DLIMIT_FREE_BLOCK(inode, es_alloc);
+out_dlimit:
        release_blocks(sb, es_alloc);
 out_dquot:
        DQUOT_FREE_BLOCK(inode, dq_alloc);
@@ -624,76 +635,3 @@ unsigned long ext2_bg_num_gdb(struct super_block *sb, int group)
        return EXT2_SB(sb)->s_gdb_count;
 }
 
-#ifdef CONFIG_EXT2_CHECK
-/* Called at mount-time, super-block is locked */
-void ext2_check_blocks_bitmap (struct super_block * sb)
-{
-       struct buffer_head *bitmap_bh = NULL;
-       struct ext2_super_block * es;
-       unsigned long desc_count, bitmap_count, x, j;
-       unsigned long desc_blocks;
-       struct ext2_group_desc * desc;
-       int i;
-
-       es = EXT2_SB(sb)->s_es;
-       desc_count = 0;
-       bitmap_count = 0;
-       desc = NULL;
-       for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
-               desc = ext2_get_group_desc (sb, i, NULL);
-               if (!desc)
-                       continue;
-               desc_count += le16_to_cpu(desc->bg_free_blocks_count);
-               brelse(bitmap_bh);
-               bitmap_bh = read_block_bitmap(sb, i);
-               if (!bitmap_bh)
-                       continue;
-
-               if (ext2_bg_has_super(sb, i) &&
-                               !ext2_test_bit(0, bitmap_bh->b_data))
-                       ext2_error(sb, __FUNCTION__,
-                                  "Superblock in group %d is marked free", i);
-
-               desc_blocks = ext2_bg_num_gdb(sb, i);
-               for (j = 0; j < desc_blocks; j++)
-                       if (!ext2_test_bit(j + 1, bitmap_bh->b_data))
-                               ext2_error(sb, __FUNCTION__,
-                                          "Descriptor block #%ld in group "
-                                          "%d is marked free", j, i);
-
-               if (!block_in_use(le32_to_cpu(desc->bg_block_bitmap),
-                                       sb, bitmap_bh->b_data))
-                       ext2_error(sb, "ext2_check_blocks_bitmap",
-                                   "Block bitmap for group %d is marked free",
-                                   i);
-
-               if (!block_in_use(le32_to_cpu(desc->bg_inode_bitmap),
-                                       sb, bitmap_bh->b_data))
-                       ext2_error(sb, "ext2_check_blocks_bitmap",
-                                   "Inode bitmap for group %d is marked free",
-                                   i);
-
-               for (j = 0; j < EXT2_SB(sb)->s_itb_per_group; j++)
-                       if (!block_in_use(le32_to_cpu(desc->bg_inode_table) + j,
-                                               sb, bitmap_bh->b_data))
-                               ext2_error (sb, "ext2_check_blocks_bitmap",
-                                           "Block #%ld of the inode table in "
-                                           "group %d is marked free", j, i);
-
-               x = ext2_count_free(bitmap_bh, sb->s_blocksize);
-               if (le16_to_cpu(desc->bg_free_blocks_count) != x)
-                       ext2_error (sb, "ext2_check_blocks_bitmap",
-                                   "Wrong free blocks count for group %d, "
-                                   "stored = %d, counted = %lu", i,
-                                   le16_to_cpu(desc->bg_free_blocks_count), x);
-               bitmap_count += x;
-       }
-       if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count)
-               ext2_error (sb, "ext2_check_blocks_bitmap",
-                       "Wrong free blocks count in super block, "
-                       "stored = %lu, counted = %lu",
-                       (unsigned long)le32_to_cpu(es->s_free_blocks_count),
-                       bitmap_count);
-       brelse(bitmap_bh);
-}
-#endif