diff options
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 583e823307ae..0db0cd92a38d 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -72,11 +72,13 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
72 | 72 | ||
73 | if (!PageUptodate(page)) { | 73 | if (!PageUptodate(page)) { |
74 | void *kaddr = kmap(page); | 74 | void *kaddr = kmap(page); |
75 | u64 dsize = i_size_read(inode); | ||
76 | |||
77 | if (dsize > (dibh->b_size - sizeof(struct gfs2_dinode))) | ||
78 | dsize = dibh->b_size - sizeof(struct gfs2_dinode); | ||
75 | 79 | ||
76 | memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), | 80 | memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); |
77 | ip->i_disksize); | 81 | memset(kaddr + dsize, 0, PAGE_CACHE_SIZE - dsize); |
78 | memset(kaddr + ip->i_disksize, 0, | ||
79 | PAGE_CACHE_SIZE - ip->i_disksize); | ||
80 | kunmap(page); | 82 | kunmap(page); |
81 | 83 | ||
82 | SetPageUptodate(page); | 84 | SetPageUptodate(page); |
@@ -1039,13 +1041,14 @@ static int trunc_start(struct gfs2_inode *ip, u64 size) | |||
1039 | goto out; | 1041 | goto out; |
1040 | 1042 | ||
1041 | if (gfs2_is_stuffed(ip)) { | 1043 | if (gfs2_is_stuffed(ip)) { |
1042 | ip->i_disksize = size; | 1044 | u64 dsize = size + sizeof(struct gfs2_inode); |
1043 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; | 1045 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; |
1044 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 1046 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
1045 | gfs2_dinode_out(ip, dibh->b_data); | 1047 | gfs2_dinode_out(ip, dibh->b_data); |
1046 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size); | 1048 | if (dsize > dibh->b_size) |
1049 | dsize = dibh->b_size; | ||
1050 | gfs2_buffer_clear_tail(dibh, dsize); | ||
1047 | error = 1; | 1051 | error = 1; |
1048 | |||
1049 | } else { | 1052 | } else { |
1050 | if (size & (u64)(sdp->sd_sb.sb_bsize - 1)) | 1053 | if (size & (u64)(sdp->sd_sb.sb_bsize - 1)) |
1051 | error = gfs2_block_truncate_page(ip->i_inode.i_mapping); | 1054 | error = gfs2_block_truncate_page(ip->i_inode.i_mapping); |