summaryrefslogtreecommitdiff
path: root/fs/ocfs2/resize.c
diff options
context:
space:
mode:
authorJoseph Qi <joseph.qi@huawei.com>2014-06-04 16:06:17 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 16:53:54 -0700
commit17bf1418b78d9c51370f29c2b840f7d0a1bf311a (patch)
tree3be1bc2fe567f37c322bd1f4c1b5593e1b959bcc /fs/ocfs2/resize.c
parentb7ac233515c6263d6cb471d9e0f57bdd7ea36894 (diff)
ocfs2: fix incorrect i_size of global bitmap inode after resize
Ocfs2 cluster size may be 1MB, which has 20 bits. When resize, the input new clusters is mostly the number of clusters in a group descriptor(32256). Since the input clusters is defined as type int, so it will overflow when shift left 20 bits and then lead to incorrect global bitmap i_size. Signed-off-by: Joseph Qi <joseph.qi@huawei.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/resize.c')
-rw-r--r--fs/ocfs2/resize.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index 168739c2ad2b..d5da6f624142 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -153,7 +153,7 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle,
spin_lock(&OCFS2_I(bm_inode)->ip_lock);
OCFS2_I(bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
- le64_add_cpu(&fe->i_size, new_clusters << osb->s_clustersize_bits);
+ le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits);
spin_unlock(&OCFS2_I(bm_inode)->ip_lock);
i_size_write(bm_inode, le64_to_cpu(fe->i_size));
@@ -563,7 +563,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
spin_lock(&OCFS2_I(main_bm_inode)->ip_lock);
OCFS2_I(main_bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
- le64_add_cpu(&fe->i_size, input->clusters << osb->s_clustersize_bits);
+ le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits);
spin_unlock(&OCFS2_I(main_bm_inode)->ip_lock);
i_size_write(main_bm_inode, le64_to_cpu(fe->i_size));