vserver 1.9.3
[linux-2.6.git] / fs / ext3 / ialloc.c
index ac238b2..591eed0 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
 #include <linux/random.h>
+#include <linux/vs_dlimit.h>
 
 #include <asm/bitops.h>
 #include <asm/byteorder.h>
@@ -64,8 +65,8 @@ read_inode_bitmap(struct super_block * sb, unsigned long block_group)
        if (!bh)
                ext3_error(sb, "read_inode_bitmap",
                            "Cannot read inode bitmap - "
-                           "block_group = %lu, inode_bitmap = %lu",
-                           block_group, (unsigned long) desc->bg_inode_bitmap);
+                           "block_group = %lu, inode_bitmap = %u",
+                           block_group, le32_to_cpu(desc->bg_inode_bitmap));
 error_out:
        return bh;
 }
@@ -97,7 +98,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
        unsigned long bit;
        struct ext3_group_desc * gdp;
        struct ext3_super_block * es;
-       struct ext3_sb_info *sbi = EXT3_SB(sb);
+       struct ext3_sb_info *sbi;
        int fatal = 0, err;
 
        if (atomic_read(&inode->i_count) > 1) {
@@ -114,6 +115,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
                printk("ext3_free_inode: inode on nonexistent device\n");
                return;
        }
+       sbi = EXT3_SB(sb);
 
        ino = inode->i_ino;
        ext3_debug ("freeing inode %lu\n", ino);
@@ -124,6 +126,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
         */
        DQUOT_INIT(inode);
        ext3_xattr_delete_inode(handle, inode);
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        DQUOT_FREE_INODE(inode);
        DQUOT_DROP(inode);
 
@@ -444,6 +447,16 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
        inode = new_inode(sb);
        if (!inode)
                return ERR_PTR(-ENOMEM);
+
+       if (sb->s_flags & MS_TAGXID)
+               inode->i_xid = current->xid;
+       else
+               inode->i_xid = 0;
+
+       if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
+               err = -ENOSPC;
+               goto out;
+       }
        ei = EXT3_I(inode);
 
        sbi = EXT3_SB(sb);
@@ -567,7 +580,8 @@ got:
        ei->i_dir_start_lookup = 0;
        ei->i_disksize = 0;
 
-       ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
+       ei->i_flags = EXT3_I(dir)->i_flags &
+               ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
        if (S_ISLNK(mode))
                ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
        /* dirsync only applies to directories */
@@ -618,6 +632,7 @@ got:
        ext3_debug("allocating inode %lu\n", inode->i_ino);
        goto really_out;
 fail:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        ext3_std_error(sb, err);
 out:
        iput(inode);
@@ -627,6 +642,7 @@ really_out:
        return ret;
 
 fail2:
+       DLIMIT_FREE_INODE(sb, inode->i_xid);
        inode->i_flags |= S_NOQUOTA;
        inode->i_nlink = 0;
        iput(inode);