Skip to content

Commit

Permalink
ext4: recheck buffer uptodate bit under buffer lock
Browse files Browse the repository at this point in the history
Commit 8e33fad ("ext4: remove an unnecessary if statement in
__ext4_get_inode_loc()") forget to recheck buffer's uptodate bit again
under buffer lock, which may overwrite the buffer if someone else have
already brought it uptodate and changed it.

Fixes: 8e33fad ("ext4: remove an unnecessary if statement in __ext4_get_inode_loc()")
Cc: [email protected]
Signed-off-by: Zhang Yi <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
zhangyi089 authored and tytso committed Oct 1, 2021
1 parent 42cb447 commit f2c7797
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4277,6 +4277,12 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
goto has_buffer;

lock_buffer(bh);
if (ext4_buffer_uptodate(bh)) {
/* Someone brought it uptodate while we waited */
unlock_buffer(bh);
goto has_buffer;
}

/*
* If we have all information of the inode in memory and this
* is the only valid inode in the block, we need not read the
Expand Down

0 comments on commit f2c7797

Please sign in to comment.