Skip to content

Commit

Permalink
GFS2: Get a block reservation before resizing a file
Browse files Browse the repository at this point in the history
This patch allocates a block reservation structure before growing
or shrinking a file. Without this structure, the grow or shink code
can reference the bad pointer.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Bob Peterson authored and Steven Whitehouse committed Feb 1, 2013
1 parent 4506a51 commit d2b47cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,10 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)

inode_dio_wait(inode);

ret = gfs2_rs_alloc(GFS2_I(inode));
if (ret)
return ret;

oldsize = inode->i_size;
if (newsize >= oldsize)
return do_grow(inode, newsize);
Expand Down

0 comments on commit d2b47cf

Please sign in to comment.