nilfs2: fix missing zero-fill initialization of btree node cache
[safe/jmp/linux-2.6] / fs / udf / balloc.c
index 58be702..1e06853 100644 (file)
@@ -140,17 +140,17 @@ static inline int load_block_bitmap(struct super_block *sb,
        return slot;
 }
 
-static bool udf_add_free_space(struct udf_sb_info *sbi,
-                               u16 partition, u32 cnt)
+static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        struct logicalVolIntegrityDesc *lvid;
 
-       if (sbi->s_lvid_bh == NULL)
-               return false;
+       if (!sbi->s_lvid_bh)
+               return;
 
        lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
        le32_add_cpu(&lvid->freeSpaceTable[partition], cnt);
-       return true;
+       udf_updated_lvid(sb);
 }
 
 static void udf_bitmap_free_blocks(struct super_block *sb,
@@ -209,7 +209,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
                        } else {
                                if (inode)
                                        vfs_dq_free_block(inode, 1);
-                               udf_add_free_space(sbi, sbi->s_partition, 1);
+                               udf_add_free_space(sb, sbi->s_partition, 1);
                        }
                }
                mark_buffer_dirty(bh);
@@ -220,9 +220,6 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
        } while (overflow);
 
 error_return:
-       sb->s_dirt = 1;
-       if (sbi->s_lvid_bh)
-               mark_buffer_dirty(sbi->s_lvid_bh);
        mutex_unlock(&sbi->s_alloc_mutex);
 }
 
@@ -241,7 +238,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
 
        mutex_lock(&sbi->s_alloc_mutex);
        part_len = sbi->s_partmaps[partition].s_partition_len;
-       if (first_block < 0 || first_block >= part_len)
+       if (first_block >= part_len)
                goto out;
 
        if (first_block + block_count > part_len)
@@ -279,9 +276,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
        } while (block_count > 0);
 
 out:
-       if (udf_add_free_space(sbi, partition, -alloc_count))
-               mark_buffer_dirty(sbi->s_lvid_bh);
-       sb->s_dirt = 1;
+       udf_add_free_space(sb, partition, -alloc_count);
        mutex_unlock(&sbi->s_alloc_mutex);
        return alloc_count;
 }
@@ -302,7 +297,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
        mutex_lock(&sbi->s_alloc_mutex);
 
 repeat:
-       if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
+       if (goal >= sbi->s_partmaps[partition].s_partition_len)
                goal = 0;
 
        nr_groups = bitmap->s_nr_groups;
@@ -411,9 +406,7 @@ got_block:
 
        mark_buffer_dirty(bh);
 
-       if (udf_add_free_space(sbi, partition, -1))
-               mark_buffer_dirty(sbi->s_lvid_bh);
-       sb->s_dirt = 1;
+       udf_add_free_space(sb, partition, -1);
        mutex_unlock(&sbi->s_alloc_mutex);
        *err = 0;
        return newblock;
@@ -457,8 +450,7 @@ static void udf_table_free_blocks(struct super_block *sb,
           could occure, but.. oh well */
        if (inode)
                vfs_dq_free_block(inode, count);
-       if (udf_add_free_space(sbi, sbi->s_partition, count))
-               mark_buffer_dirty(sbi->s_lvid_bh);
+       udf_add_free_space(sb, sbi->s_partition, count);
 
        start = bloc->logicalBlockNum + offset;
        end = bloc->logicalBlockNum + offset + count - 1;
@@ -657,7 +649,6 @@ static void udf_table_free_blocks(struct super_block *sb,
        brelse(oepos.bh);
 
 error_return:
-       sb->s_dirt = 1;
        mutex_unlock(&sbi->s_alloc_mutex);
        return;
 }
@@ -675,8 +666,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
        int8_t etype = -1;
        struct udf_inode_info *iinfo;
 
-       if (first_block < 0 ||
-               first_block >= sbi->s_partmaps[partition].s_partition_len)
+       if (first_block >= sbi->s_partmaps[partition].s_partition_len)
                return 0;
 
        iinfo = UDF_I(table);
@@ -722,10 +712,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 
        brelse(epos.bh);
 
-       if (alloc_count && udf_add_free_space(sbi, partition, -alloc_count)) {
-               mark_buffer_dirty(sbi->s_lvid_bh);
-               sb->s_dirt = 1;
-       }
+       if (alloc_count)
+               udf_add_free_space(sb, partition, -alloc_count);
        mutex_unlock(&sbi->s_alloc_mutex);
        return alloc_count;
 }
@@ -754,7 +742,7 @@ static int udf_table_new_block(struct super_block *sb,
                return newblock;
 
        mutex_lock(&sbi->s_alloc_mutex);
-       if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
+       if (goal >= sbi->s_partmaps[partition].s_partition_len)
                goal = 0;
 
        /* We search for the closest matching block to goal. If we find
@@ -823,10 +811,8 @@ static int udf_table_new_block(struct super_block *sb,
                udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
        brelse(goal_epos.bh);
 
-       if (udf_add_free_space(sbi, partition, -1))
-               mark_buffer_dirty(sbi->s_lvid_bh);
+       udf_add_free_space(sb, partition, -1);
 
-       sb->s_dirt = 1;
        mutex_unlock(&sbi->s_alloc_mutex);
        *err = 0;
        return newblock;