1 ext4: fix wrong size computation in ext4_mb_normalize_request()
3 From: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
5 As the member fe_len defined in struct ext4_free_extent is expressed as
6 number of clusters, the variable "size" computation is wrong, we need to
7 first translate fe_len to block number, then to bytes.
9 Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 Reviewed-by: Lukas Czerner <lczerner@redhat.com>
13 fs/ext4/mballoc.c | 5 +++--
14 1 file changed, 3 insertions(+), 2 deletions(-)
16 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
17 index 18a1619..0e9466f 100644
18 --- a/fs/ext4/mballoc.c
19 +++ b/fs/ext4/mballoc.c
20 @@ -3075,8 +3075,9 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
22 size = 8 * 1024 * 1024;
24 - start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits;
25 - size = ac->ac_o_ex.fe_len << bsbits;
26 + start_off = (loff_t) ac->ac_o_ex.fe_logical << bsbits;
27 + size = (loff_t) EXT4_C2B(EXT4_SB(ac->ac_sb),
28 + ac->ac_o_ex.fe_len) << bsbits;
30 size = size >> bsbits;
31 start = start_off >> bsbits;