shithub: lwext4

Download patch

ref: 1cd9e263f29e4f5d596fc17515d014a721ac2f11
parent: f60d62d6cd364c09aef1c0ec94232183cf6f2b91
author: ngkaho1234 <[email protected]>
date: Fri Oct 23 14:04:21 EDT 2015

ext4_ialloc.c and ext4_balloc.c: very minor code optimizations.

--- a/lwext4/ext4_balloc.c
+++ b/lwext4/ext4_balloc.c
@@ -142,9 +142,9 @@
 
 	/* Modify bitmap */
 	ext4_bmap_bit_clr(bitmap_block.data, index_in_group);
-	bitmap_block.dirty = true;
 	ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 				    bitmap_block.data);
+	bitmap_block.dirty = true;
 
 	/* Release block with bitmap */
 	rc = ext4_block_set(fs->bdev, &bitmap_block);
@@ -234,9 +234,9 @@
 		/* Modify bitmap */
 		ext4_bmap_bits_free(bitmap_block.data, index_in_group_first,
 				    free_cnt);
-		bitmap_block.dirty = true;
 		ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 					    bitmap_block.data);
+		bitmap_block.dirty = true;
 
 		count -= free_cnt;
 		first += free_cnt;
@@ -334,9 +334,9 @@
 	/* Check if goal is free */
 	if (ext4_bmap_is_bit_clr(bitmap_block.data, index_in_group)) {
 		ext4_bmap_bit_set(bitmap_block.data, index_in_group);
-		bitmap_block.dirty = true;
 		ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 					    bitmap_block.data);
+		bitmap_block.dirty = true;
 		rc = ext4_block_set(inode_ref->fs->bdev, &bitmap_block);
 		if (rc != EOK) {
 			ext4_fs_put_block_group_ref(&bg_ref);
@@ -361,9 +361,9 @@
 		if (ext4_bmap_is_bit_clr(bitmap_block.data, tmp_idx)) {
 			ext4_bmap_bit_set(bitmap_block.data, tmp_idx);
 
-			bitmap_block.dirty = true;
 			ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 						    bitmap_block.data);
+			bitmap_block.dirty = true;
 			rc = ext4_block_set(inode_ref->fs->bdev, &bitmap_block);
 			if (rc != EOK)
 				return rc;
@@ -380,9 +380,9 @@
 				    blocks_in_group, &rel_block_idx);
 	if (rc == EOK) {
 		ext4_bmap_bit_set(bitmap_block.data, rel_block_idx);
-		bitmap_block.dirty = true;
 		ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 					    bitmap_block.data);
+		bitmap_block.dirty = true;
 		rc = ext4_block_set(inode_ref->fs->bdev, &bitmap_block);
 		if (rc != EOK)
 			return rc;
@@ -455,9 +455,9 @@
 
 			ext4_bmap_bit_set(bitmap_block.data, rel_block_idx);
 
-			bitmap_block.dirty = true;
 			ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 						    bitmap_block.data);
+			bitmap_block.dirty = true;
 			rc = ext4_block_set(inode_ref->fs->bdev, &bitmap_block);
 			if (rc != EOK) {
 				ext4_fs_put_block_group_ref(&bg_ref);
@@ -556,9 +556,9 @@
 	/* Allocate block if possible */
 	if (*free) {
 		ext4_bmap_bit_set(bitmap_block.data, index_in_group);
-		bitmap_block.dirty = true;
 		ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group,
 					    bitmap_block.data);
+		bitmap_block.dirty = true;
 	}
 
 	/* Release block with bitmap */
--- a/lwext4/ext4_ialloc.c
+++ b/lwext4/ext4_ialloc.c
@@ -146,9 +146,9 @@
 	/* Free i-node in the bitmap */
 	uint32_t index_in_group = ext4_ialloc_inode2index_in_group(sb, index);
 	ext4_bmap_bit_clr(bitmap_block.data, index_in_group);
-	bitmap_block.dirty = true;
 	ext4_ialloc_set_bitmap_csum(sb, bg_ref.block_group,
 				    bitmap_block.data);
+	bitmap_block.dirty = true;
 
 	/* Put back the block with bitmap */
 	rc = ext4_block_set(fs->bdev, &bitmap_block);
@@ -261,9 +261,9 @@
 			ext4_bmap_bit_set(bitmap_block.data, index_in_group);
 
 			/* Free i-node found, save the bitmap */
-			bitmap_block.dirty = true;
 			ext4_ialloc_set_bitmap_csum(sb, bg_ref.block_group,
 						    bitmap_block.data);
+			bitmap_block.dirty = true;
 
 			ext4_block_set(fs->bdev, &bitmap_block);
 			if (rc != EOK) {