Skip to contentSkip to conversation

__set_bit for BH flags in ext4_ext_get_blocks?

PATCH New Eric Sandeen 1 participant 2 messages Jun 9, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

I was wondering why ext4_ext_get_blocks calls things like:

__set_bit(BH_Unwritten, &bh_result->b_state);
__set_bit(BH_New, &bh_result->b_state);
__set_bit(BH_Mapped, &bh_result->b_state);

instead of set_buffer_unwritten, etc.

Is there any reason it's calling __set_bit instead of set_bit (via the BUFFER_FNS macros)?

Thanks,
-Eric

#1 lore raw

PATCH 1/1 use atomic functions to set bh_state

use the BUFFER_FNS functions (set_buffer_foo) to set buffer head state atomically, not the nonatomic __set_bit.

Alex, please speak up if you had a good reason for __set_bit() :)

---

fs/ext4/extents.c +3 -4
Index: linux-2.6/fs/ext4/extents.c
===================================================================
@@ -2616,8 +2616,7 @@ int ext4_ext_get_blocks(handle_t *handle
 				 */
 				if (allocated > max_blocks)
 					allocated = max_blocks;
-				/* mark the buffer unwritten */
-				__set_bit(BH_Unwritten, &bh_result->b_state);
+				set_buffer_unwritten(bh);
 				goto out2;
 			}
 
@@ -2723,7 +2722,7 @@ int ext4_ext_get_blocks(handle_t *handle
 	newblock = ext_pblock(&newex);
 	allocated = ext4_ext_get_actual_len(&newex);
 outnew:
-	__set_bit(BH_New, &bh_result->b_state);
+	set_buffer_new(bh_result);
 
 	/* Cache only when it is _not_ an uninitialized extent */
 	if (create != EXT4_CREATE_UNINITIALIZED_EXT)
@@ -2733,7 +2732,7 @@ out:
 	if (allocated > max_blocks)
 		allocated = max_blocks;
 	ext4_ext_show_leaf(inode, path);
-	__set_bit(BH_Mapped, &bh_result->b_state);
+	set_buffer_mapped(bh_result);
 	bh_result->b_bdev = inode->i_sb->s_bdev;
 	bh_result->b_blocknr = newblock;
 out2: