Skip to content

Commit

Permalink
[GFS2] Fix a size calculation error
Browse files Browse the repository at this point in the history
Fix a size calculation error.
The size was incorrect being computed as a
negative length and then being passed to an
unsigned parameter.

This in turn would cause the allocator to
think it needed enough meta data to store
a gigabyte file for every file created.

Signed-off-by: Russell Cattelan <cattelan@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Russell Cattelan authored and swhiteho committed Oct 12, 2006
1 parent c25d518 commit 52ae7b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/gfs2/ops_address.c
Expand Up @@ -370,15 +370,17 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + from;
loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
struct gfs2_alloc *al;
unsigned int write_len = to - from;


gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh);
error = gfs2_glock_nq_m_atime(1, &ip->i_gh);
if (error)
goto out_uninit;

gfs2_write_calc_reserv(ip, to - from, &data_blocks, &ind_blocks);
gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks);

error = gfs2_write_alloc_required(ip, pos, from - to, &alloc_required);
error = gfs2_write_alloc_required(ip, pos, write_len, &alloc_required);
if (error)
goto out_unlock;

Expand Down

0 comments on commit 52ae7b7

Please sign in to comment.