Commit 18aba2a
jbd2: fix off-by-one while erasing journal
In __jbd2_journal_erase(), the block_stop parameter includes the last
block of a contiguous region; however, the calculation of byte_stop is
incorrect, as it does not account for the bytes in that last block.
Consequently, the page cache is not cleared properly, which occasionally
causes the ext4/050 test to fail.
Since block_stop operates on inclusion semantics, it involves repeated
increments and decrements by 1, significantly increasing the complexity
of the calculations. Optimize the calculation and fix the incorrect
byte_stop by make both block_stop and byte_stop to use exclusion
semantics.
This fixes a failure in fstests ext4/050.
Fixes: 01d5d96 ("ext4: add discard/zeroout flags to journal flush")
Signed-off-by: Zhang Yi <[email protected]>
Reviewed-by: Baokun Li <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>1 parent 08be56f commit 18aba2a
1 file changed
+6
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1964 | 1964 | | |
1965 | 1965 | | |
1966 | 1966 | | |
1967 | | - | |
1968 | | - | |
1969 | | - | |
1970 | | - | |
| 1967 | + | |
| 1968 | + | |
1971 | 1969 | | |
1972 | 1970 | | |
1973 | 1971 | | |
1974 | 1972 | | |
1975 | 1973 | | |
1976 | 1974 | | |
1977 | | - | |
| 1975 | + | |
1978 | 1976 | | |
1979 | 1977 | | |
1980 | 1978 | | |
| |||
1993 | 1991 | | |
1994 | 1992 | | |
1995 | 1993 | | |
1996 | | - | |
1997 | | - | |
| 1994 | + | |
1998 | 1995 | | |
1999 | 1996 | | |
2000 | | - | |
| 1997 | + | |
2001 | 1998 | | |
2002 | 1999 | | |
2003 | 2000 | | |
| |||
2012 | 2009 | | |
2013 | 2010 | | |
2014 | 2011 | | |
2015 | | - | |
| 2012 | + | |
2016 | 2013 | | |
2017 | 2014 | | |
2018 | 2015 | | |
| |||
0 commit comments