diff options
Diffstat (limited to 'fs/gfs2/aops.c')
| -rw-r--r-- | fs/gfs2/aops.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 194fe16d8418..6b24afb96aae 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c | |||
| @@ -36,8 +36,8 @@ | |||
| 36 | #include "glops.h" | 36 | #include "glops.h" |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, | 39 | void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, |
| 40 | unsigned int from, unsigned int to) | 40 | unsigned int from, unsigned int to) |
| 41 | { | 41 | { |
| 42 | struct buffer_head *head = page_buffers(page); | 42 | struct buffer_head *head = page_buffers(page); |
| 43 | unsigned int bsize = head->b_size; | 43 | unsigned int bsize = head->b_size; |
| @@ -615,7 +615,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
| 615 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; | 615 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; |
| 616 | int alloc_required; | 616 | int alloc_required; |
| 617 | int error = 0; | 617 | int error = 0; |
| 618 | struct gfs2_alloc *al; | 618 | struct gfs2_alloc *al = NULL; |
| 619 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | 619 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
| 620 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); | 620 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); |
| 621 | unsigned to = from + len; | 621 | unsigned to = from + len; |
| @@ -663,6 +663,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
| 663 | rblocks += RES_STATFS + RES_QUOTA; | 663 | rblocks += RES_STATFS + RES_QUOTA; |
| 664 | if (&ip->i_inode == sdp->sd_rindex) | 664 | if (&ip->i_inode == sdp->sd_rindex) |
| 665 | rblocks += 2 * RES_STATFS; | 665 | rblocks += 2 * RES_STATFS; |
| 666 | if (alloc_required) | ||
| 667 | rblocks += gfs2_rg_blocks(al); | ||
| 666 | 668 | ||
| 667 | error = gfs2_trans_begin(sdp, rblocks, | 669 | error = gfs2_trans_begin(sdp, rblocks, |
| 668 | PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize); | 670 | PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize); |
| @@ -696,13 +698,11 @@ out: | |||
| 696 | 698 | ||
| 697 | page_cache_release(page); | 699 | page_cache_release(page); |
| 698 | 700 | ||
| 699 | /* | 701 | gfs2_trans_end(sdp); |
| 700 | * XXX(truncate): the call below should probably be replaced with | ||
| 701 | * a call to the gfs2-specific truncate blocks helper to actually | ||
| 702 | * release disk blocks.. | ||
| 703 | */ | ||
| 704 | if (pos + len > ip->i_inode.i_size) | 702 | if (pos + len > ip->i_inode.i_size) |
| 705 | truncate_setsize(&ip->i_inode, ip->i_inode.i_size); | 703 | gfs2_trim_blocks(&ip->i_inode); |
| 704 | goto out_trans_fail; | ||
| 705 | |||
| 706 | out_endtrans: | 706 | out_endtrans: |
| 707 | gfs2_trans_end(sdp); | 707 | gfs2_trans_end(sdp); |
| 708 | out_trans_fail: | 708 | out_trans_fail: |
| @@ -802,10 +802,8 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh, | |||
| 802 | page_cache_release(page); | 802 | page_cache_release(page); |
| 803 | 803 | ||
| 804 | if (copied) { | 804 | if (copied) { |
| 805 | if (inode->i_size < to) { | 805 | if (inode->i_size < to) |
| 806 | i_size_write(inode, to); | 806 | i_size_write(inode, to); |
| 807 | ip->i_disksize = inode->i_size; | ||
| 808 | } | ||
| 809 | gfs2_dinode_out(ip, di); | 807 | gfs2_dinode_out(ip, di); |
| 810 | mark_inode_dirty(inode); | 808 | mark_inode_dirty(inode); |
| 811 | } | 809 | } |
| @@ -876,8 +874,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, | |||
| 876 | 874 | ||
| 877 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); | 875 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); |
| 878 | if (ret > 0) { | 876 | if (ret > 0) { |
| 879 | if (inode->i_size > ip->i_disksize) | ||
| 880 | ip->i_disksize = inode->i_size; | ||
| 881 | gfs2_dinode_out(ip, dibh->b_data); | 877 | gfs2_dinode_out(ip, dibh->b_data); |
| 882 | mark_inode_dirty(inode); | 878 | mark_inode_dirty(inode); |
| 883 | } | 879 | } |
