ext4_trans: flush the buffer in the following case.
[lwext4.git] / lwext4 / ext4_ialloc.c
index 7f7b0d624579fa5dc9d40acba367a39e42e83012..5c3bcc04b554603adf399b821e90bc47d65db140 100644 (file)
@@ -43,7 +43,7 @@
 #include "ext4_types.h"
 #include "ext4_ialloc.h"
 #include "ext4_super.h"
-#include "ext4_crc32c.h"
+#include "ext4_crc32.h"
 #include "ext4_fs.h"
 #include "ext4_blockdev.h"
 #include "ext4_block_group.h"
@@ -112,7 +112,7 @@ void ext4_ialloc_set_bitmap_csum(struct ext4_sblock *sb, struct ext4_bgroup *bg,
        uint32_t csum = ext4_ialloc_bitmap_csum(sb, bitmap);
        uint16_t lo_csum = to_le16(csum & 0xFFFF),
                 hi_csum = to_le16(csum >> 16);
-       
+
        if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
                return;
 
@@ -136,7 +136,7 @@ ext4_ialloc_verify_bitmap_csum(struct ext4_sblock *sb, struct ext4_bgroup *bg,
 
        if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
                return true;
-       
+
        if (bg->inode_bitmap_csum_lo != lo_csum)
                return false;
 
@@ -169,7 +169,7 @@ int ext4_ialloc_free_inode(struct ext4_fs *fs, uint32_t index, bool is_dir)
            ext4_bg_get_inode_bitmap(bg, sb);
 
        struct ext4_block b;
-       rc = ext4_block_get(fs->bdev, &b, bitmap_block_addr);
+       rc = ext4_trans_block_get(fs->bdev, &b, bitmap_block_addr);
        if (rc != EOK)
                return rc;
 
@@ -184,7 +184,7 @@ int ext4_ialloc_free_inode(struct ext4_fs *fs, uint32_t index, bool is_dir)
        uint32_t index_in_group = ext4_ialloc_inode_to_bgidx(sb, index);
        ext4_bmap_bit_clr(b.data, index_in_group);
        ext4_ialloc_set_bitmap_csum(sb, bg, b.data);
-       b.dirty = true;
+       ext4_trans_set_block_dirty(b.buf);
 
        /* Put back the block with bitmap */
        rc = ext4_block_set(fs->bdev, &b);
@@ -260,7 +260,7 @@ int ext4_ialloc_alloc_inode(struct ext4_fs *fs, uint32_t *idx, bool is_dir)
                        uint32_t bmp_blk_add = ext4_bg_get_inode_bitmap(bg, sb);
 
                        struct ext4_block b;
-                       rc = ext4_block_get(fs->bdev, &b, bmp_blk_add);
+                       rc = ext4_trans_block_get(fs->bdev, &b, bmp_blk_add);
                        if (rc != EOK) {
                                ext4_fs_put_block_group_ref(&bg_ref);
                                return rc;
@@ -300,7 +300,7 @@ int ext4_ialloc_alloc_inode(struct ext4_fs *fs, uint32_t *idx, bool is_dir)
                        /* Free i-node found, save the bitmap */
                        ext4_ialloc_set_bitmap_csum(sb,bg,
                                                    b.data);
-                       b.dirty = true;
+                       ext4_trans_set_block_dirty(b.buf);
 
                        ext4_block_set(fs->bdev, &b);
                        if (rc != EOK) {