Skip to contentSkip to conversation

fs:ext3: remove lock_buffer in bclean() and setup_new_group_blocks

PATCH In review Cong Ding 2 participants 2 messages Dec 2, 2012 – Dec 5, 2012

lore
Share & tools
lore

Cong Ding

author
#0 lore raw

PATCH 1/1 fs:ext3: remove lock_buffer in bclean() and setup_new_group_blocks

it's not necessary to lock the buffers because no one touches them beyond the file system.

---
 fs/ext3/resize.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
fs/ext3/resize.c +0 -4
index 0f814f3..f76fcd6 100644
@@ -122,10 +122,8 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
 		brelse(bh);
 		bh = ERR_PTR(err);
 	} else {
-		lock_buffer(bh);
 		memset(bh->b_data, 0, sb->s_blocksize);
 		set_buffer_uptodate(bh);
-		unlock_buffer(bh);
 	}
 
 	return bh;
@@ -242,10 +240,8 @@ static int setup_new_group_blocks(struct super_block *sb,
 			brelse(gdb);
 			goto exit_bh;
 		}
-		lock_buffer(gdb);
 		memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size);
 		set_buffer_uptodate(gdb);
-		unlock_buffer(gdb);
 		err = ext3_journal_dirty_metadata(handle, gdb);
 		if (err) {
 			brelse(gdb);
Signature · 1 line
1.7.4.5
#1 lore raw
Quoted 2 lines · Cong Ding

it's not necessary to lock the buffers because no one touches them beyond the file system.

Although I agree those locks are not strictly necessary, I prefer to keep
them because the general rula is buffer contents should be changed under buffer lock unless we have a good reason to do otherwise. And here the cost of additional lock is really marginal...

Honza

Quoted 35 lines
---
 fs/ext3/resize.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
fs/ext3/resize.c +0 -4
index 0f814f3..f76fcd6 100644
@@ -122,10 +122,8 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
 		brelse(bh);
 		bh = ERR_PTR(err);
 	} else {
-		lock_buffer(bh);
 		memset(bh->b_data, 0, sb->s_blocksize);
 		set_buffer_uptodate(bh);
-		unlock_buffer(bh);
 	}
 
 	return bh;
@@ -242,10 +240,8 @@ static int setup_new_group_blocks(struct super_block *sb,
 			brelse(gdb);
 			goto exit_bh;
 		}
-		lock_buffer(gdb);
 		memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size);
 		set_buffer_uptodate(gdb);
-		unlock_buffer(gdb);
 		err = ext3_journal_dirty_metadata(handle, gdb);
 		if (err) {
 			brelse(gdb);
Signature · 1 line
1.7.4.5
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR