Skip to contentSkip to conversation

ext4: release bh in make_indexed_dir

PATCH Applied gmail 2 participants 3 messages Sep 29, 2016 – Sep 30, 2016

Subsystems (2)
lore
Share & tools
lore

gmail

author
#0 lore raw

PATCH 1/1 ext4: release bh in make_indexed_dir

The commit 6050d47adcad
("ext4: bail out from make_indexed_dir() on first error") miss to release bh in make_indexed_dir.

---
 fs/ext4/namei.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ext4/namei.c +3 -4
index 38ca0fe..465f960 100644
@@ -2058,19 +2058,18 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 		retval = PTR_ERR(de);
 		goto out_frames;
 	}
-	dx_release(frames);
 
 	retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh);
-	brelse(bh);
-	return retval;
 out_frames:
 	/*
 	 * Even if the block split failed, we have to properly write
 	 * out all the changes we did so far. Otherwise we can end up
 	 * with corrupted filesystem.
 	 */
-	ext4_mark_inode_dirty(handle, dir);
+	if (retval)
+		ext4_mark_inode_dirty(handle, dir);
 	dx_release(frames);
+	brelse(bh);
 	return retval;
 }
 
maintainer
#1 lore raw
Quoted 5 lines · gmail

The commit 6050d47adcad
("ext4: bail out from make_indexed_dir() on first error") miss to release bh in make_indexed_dir.

There's no missing brelse() as far as I can see. bh is assigned to frame->bh, and the call to dx_release(frames) will release bh.

- Ted

Quoted 33 lines
---
 fs/ext4/namei.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ext4/namei.c +3 -4
index 38ca0fe..465f960 100644
@@ -2058,19 +2058,18 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 		retval = PTR_ERR(de);
 		goto out_frames;
 	}
-	dx_release(frames);
 
 	retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh);
-	brelse(bh);
-	return retval;
 out_frames:
 	/*
 	 * Even if the block split failed, we have to properly write
 	 * out all the changes we did so far. Otherwise we can end up
 	 * with corrupted filesystem.
 	 */
-	ext4_mark_inode_dirty(handle, dir);
+	if (retval)
+		ext4_mark_inode_dirty(handle, dir);
 	dx_release(frames);
+	brelse(bh);
 	return retval;
 }
 
maintainer Applied
#2 lore raw
In reply to gmail
Quoted 5 lines · gmail

The commit 6050d47adcad
("ext4: bail out from make_indexed_dir() on first error") miss to release bh in make_indexed_dir.

Thanks, applied. I rewrote the commit description and also took out the confusing "bh = bh2" and then used bh2 where we were using bh before, which makes the code much easier to understand.

- Ted