Commit 2331fd4
ext4: avoid bb_free and bb_fragments inconsistency in mb_free_blocks()
After updating bb_free in mb_free_blocks, it is possible to return without
updating bb_fragments because the block being freed is found to have
already been freed, which leads to inconsistency between bb_free and
bb_fragments.
Since the group may be unlocked in ext4_grp_locked_error(), this can lead
to problems such as dividing by zero when calculating the average fragment
length. Hence move the update of bb_free to after the block double-free
check guarantees that the corresponding statistics are updated only after
the core block bitmap is modified.
Fixes: eabe044 ("ext4: speed-up releasing blocks on commit")
CC: <stable@vger.kernel.org> # 3.10
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240104142040.2835097-5-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>1 parent c9b528c commit 2331fd4
1 file changed
+21
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1909 | 1909 | | |
1910 | 1910 | | |
1911 | 1911 | | |
1912 | | - | |
1913 | | - | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | 1912 | | |
1918 | 1913 | | |
1919 | 1914 | | |
| |||
1927 | 1922 | | |
1928 | 1923 | | |
1929 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1930 | 1934 | | |
1931 | 1935 | | |
1932 | | - | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
1940 | 1941 | | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
| 1942 | + | |
1945 | 1943 | | |
1946 | 1944 | | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
1947 | 1950 | | |
1948 | 1951 | | |
1949 | 1952 | | |
| |||
1968 | 1971 | | |
1969 | 1972 | | |
1970 | 1973 | | |
1971 | | - | |
1972 | 1974 | | |
1973 | 1975 | | |
| 1976 | + | |
1974 | 1977 | | |
1975 | 1978 | | |
1976 | 1979 | | |
| |||
0 commit comments