]> err.no Git - linux-2.6/blobdiff - fs/udf/balloc.c
udf: truncate: create function for updating of Allocation Ext Descriptor
[linux-2.6] / fs / udf / balloc.c
index 989259655b401066f0a1635660de8064523e6a12..f855dcbbdfb854e1704566ae0cebd187c656c45f 100644 (file)
@@ -145,7 +145,7 @@ static bool udf_add_free_space(struct udf_sb_info *sbi,
 {
        struct logicalVolIntegrityDesc *lvid;
 
-       if (sbi->s_lvid_bh)
+       if (sbi->s_lvid_bh == NULL)
                return false;
 
        lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
@@ -436,6 +436,7 @@ static void udf_table_free_blocks(struct super_block *sb,
        struct extent_position oepos, epos;
        int8_t etype;
        int i;
+       struct udf_inode_info *iinfo;
 
        mutex_lock(&sbi->s_alloc_mutex);
        if (bloc.logicalBlockNum < 0 ||
@@ -448,6 +449,7 @@ static void udf_table_free_blocks(struct super_block *sb,
                goto error_return;
        }
 
+       iinfo = UDF_I(table);
        /* We do this up front - There are some error conditions that
           could occure, but.. oh well */
        if (inode)
@@ -460,7 +462,7 @@ static void udf_table_free_blocks(struct super_block *sb,
 
        epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
        elen = 0;
-       epos.block = oepos.block = UDF_I_LOCATION(table);
+       epos.block = oepos.block = iinfo->i_location;
        epos.bh = oepos.bh = NULL;
 
        while (count &&
@@ -539,11 +541,11 @@ static void udf_table_free_blocks(struct super_block *sb,
                elen = EXT_RECORDED_ALLOCATED |
                        (count << sb->s_blocksize_bits);
 
-               if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) {
+               if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
                        adsize = sizeof(short_ad);
-               } else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) {
+               else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
                        adsize = sizeof(long_ad);
-               else {
+               else {
                        brelse(oepos.bh);
                        brelse(epos.bh);
                        goto error_return;
@@ -573,7 +575,8 @@ static void udf_table_free_blocks(struct super_block *sb,
                        if (epos.offset + adsize > sb->s_blocksize) {
                                loffset = epos.offset;
                                aed->lengthAllocDescs = cpu_to_le32(adsize);
-                               sptr = UDF_I_DATA(table) + epos.offset - adsize;
+                               sptr = iinfo->i_ext.i_data + epos.offset
+                                                               - adsize;
                                dptr = epos.bh->b_data +
                                        sizeof(struct allocExtDesc);
                                memcpy(dptr, sptr, adsize);
@@ -591,8 +594,9 @@ static void udf_table_free_blocks(struct super_block *sb,
                                                        aed->lengthAllocDescs) +
                                                                adsize);
                                } else {
-                                       sptr = UDF_I_DATA(table) + epos.offset;
-                                       UDF_I_LENALLOC(table) += adsize;
+                                       sptr = iinfo->i_ext.i_data +
+                                                               epos.offset;
+                                       iinfo->i_lenAlloc += adsize;
                                        mark_inode_dirty(table);
                                }
                                epos.offset = sizeof(struct allocExtDesc);
@@ -606,7 +610,7 @@ static void udf_table_free_blocks(struct super_block *sb,
                                            2, 1, epos.block.logicalBlockNum,
                                            sizeof(tag));
 
-                       switch (UDF_I_ALLOCTYPE(table)) {
+                       switch (iinfo->i_alloc_type) {
                        case ICBTAG_FLAG_AD_SHORT:
                                sad = (short_ad *)sptr;
                                sad->extLength = cpu_to_le32(
@@ -637,7 +641,7 @@ static void udf_table_free_blocks(struct super_block *sb,
                        udf_write_aext(table, &epos, eloc, elen, 1);
 
                        if (!epos.bh) {
-                               UDF_I_LENALLOC(table) += adsize;
+                               iinfo->i_lenAlloc += adsize;
                                mark_inode_dirty(table);
                        } else {
                                aed = (struct allocExtDesc *)epos.bh->b_data;
@@ -670,21 +674,23 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
        kernel_lb_addr eloc;
        struct extent_position epos;
        int8_t etype = -1;
+       struct udf_inode_info *iinfo;
 
        if (first_block < 0 ||
                first_block >= sbi->s_partmaps[partition].s_partition_len)
                return 0;
 
-       if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
+       iinfo = UDF_I(table);
+       if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
                adsize = sizeof(short_ad);
-       else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG)
+       else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
                adsize = sizeof(long_ad);
        else
                return 0;
 
        mutex_lock(&sbi->s_alloc_mutex);
        epos.offset = sizeof(struct unallocSpaceEntry);
-       epos.block = UDF_I_LOCATION(table);
+       epos.block = iinfo->i_location;
        epos.bh = NULL;
        eloc.logicalBlockNum = 0xFFFFFFFF;
 
@@ -737,12 +743,13 @@ static int udf_table_new_block(struct super_block *sb,
        kernel_lb_addr eloc, uninitialized_var(goal_eloc);
        struct extent_position epos, goal_epos;
        int8_t etype;
+       struct udf_inode_info *iinfo = UDF_I(table);
 
        *err = -ENOSPC;
 
-       if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
+       if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
                adsize = sizeof(short_ad);
-       else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG)
+       else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
                adsize = sizeof(long_ad);
        else
                return newblock;
@@ -757,7 +764,7 @@ static int udf_table_new_block(struct super_block *sb,
           of the current closest match and use that when we are done.
         */
        epos.offset = sizeof(struct unallocSpaceEntry);
-       epos.block = UDF_I_LOCATION(table);
+       epos.block = iinfo->i_location;
        epos.bh = goal_epos.bh = NULL;
 
        while (spread &&