diff options
Diffstat (limited to 'fs/gfs2/ops_address.c')
-rw-r--r-- | fs/gfs2/ops_address.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 27563816e1c5..4ddab67867eb 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -210,25 +210,23 @@ static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc | |||
210 | { | 210 | { |
211 | struct inode *inode = page->mapping->host; | 211 | struct inode *inode = page->mapping->host; |
212 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 212 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
213 | int error; | 213 | int ret; |
214 | int done_trans = 0; | 214 | int done_trans = 0; |
215 | 215 | ||
216 | error = gfs2_writepage_common(page, wbc); | ||
217 | if (error <= 0) | ||
218 | return error; | ||
219 | |||
220 | if (PageChecked(page)) { | 216 | if (PageChecked(page)) { |
221 | if (wbc->sync_mode != WB_SYNC_ALL) | 217 | if (wbc->sync_mode != WB_SYNC_ALL) |
222 | goto out_ignore; | 218 | goto out_ignore; |
223 | error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); | 219 | ret = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); |
224 | if (error) | 220 | if (ret) |
225 | goto out_ignore; | 221 | goto out_ignore; |
226 | done_trans = 1; | 222 | done_trans = 1; |
227 | } | 223 | } |
228 | error = __gfs2_jdata_writepage(page, wbc); | 224 | ret = gfs2_writepage_common(page, wbc); |
225 | if (ret > 0) | ||
226 | ret = __gfs2_jdata_writepage(page, wbc); | ||
229 | if (done_trans) | 227 | if (done_trans) |
230 | gfs2_trans_end(sdp); | 228 | gfs2_trans_end(sdp); |
231 | return error; | 229 | return ret; |
232 | 230 | ||
233 | out_ignore: | 231 | out_ignore: |
234 | redirty_page_for_writepage(wbc, page); | 232 | redirty_page_for_writepage(wbc, page); |
@@ -453,8 +451,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) | |||
453 | 451 | ||
454 | kaddr = kmap_atomic(page, KM_USER0); | 452 | kaddr = kmap_atomic(page, KM_USER0); |
455 | memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), | 453 | memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), |
456 | ip->i_di.di_size); | 454 | ip->i_disksize); |
457 | memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); | 455 | memset(kaddr + ip->i_disksize, 0, PAGE_CACHE_SIZE - ip->i_disksize); |
458 | kunmap_atomic(kaddr, KM_USER0); | 456 | kunmap_atomic(kaddr, KM_USER0); |
459 | flush_dcache_page(page); | 457 | flush_dcache_page(page); |
460 | brelse(dibh); | 458 | brelse(dibh); |
@@ -627,7 +625,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
627 | { | 625 | { |
628 | struct gfs2_inode *ip = GFS2_I(mapping->host); | 626 | struct gfs2_inode *ip = GFS2_I(mapping->host); |
629 | struct gfs2_sbd *sdp = GFS2_SB(mapping->host); | 627 | struct gfs2_sbd *sdp = GFS2_SB(mapping->host); |
630 | unsigned int data_blocks, ind_blocks, rblocks; | 628 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; |
631 | int alloc_required; | 629 | int alloc_required; |
632 | int error = 0; | 630 | int error = 0; |
633 | struct gfs2_alloc *al; | 631 | struct gfs2_alloc *al; |
@@ -641,11 +639,13 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
641 | if (unlikely(error)) | 639 | if (unlikely(error)) |
642 | goto out_uninit; | 640 | goto out_uninit; |
643 | 641 | ||
644 | gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); | ||
645 | error = gfs2_write_alloc_required(ip, pos, len, &alloc_required); | 642 | error = gfs2_write_alloc_required(ip, pos, len, &alloc_required); |
646 | if (error) | 643 | if (error) |
647 | goto out_unlock; | 644 | goto out_unlock; |
648 | 645 | ||
646 | if (alloc_required || gfs2_is_jdata(ip)) | ||
647 | gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); | ||
648 | |||
649 | if (alloc_required) { | 649 | if (alloc_required) { |
650 | al = gfs2_alloc_get(ip); | 650 | al = gfs2_alloc_get(ip); |
651 | if (!al) { | 651 | if (!al) { |
@@ -675,7 +675,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
675 | goto out_trans_fail; | 675 | goto out_trans_fail; |
676 | 676 | ||
677 | error = -ENOMEM; | 677 | error = -ENOMEM; |
678 | page = __grab_cache_page(mapping, index); | 678 | flags |= AOP_FLAG_NOFS; |
679 | page = grab_cache_page_write_begin(mapping, index, flags); | ||
679 | *pagep = page; | 680 | *pagep = page; |
680 | if (unlikely(!page)) | 681 | if (unlikely(!page)) |
681 | goto out_endtrans; | 682 | goto out_endtrans; |
@@ -782,7 +783,7 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh, | |||
782 | 783 | ||
783 | if (inode->i_size < to) { | 784 | if (inode->i_size < to) { |
784 | i_size_write(inode, to); | 785 | i_size_write(inode, to); |
785 | ip->i_di.di_size = inode->i_size; | 786 | ip->i_disksize = inode->i_size; |
786 | di->di_size = cpu_to_be64(inode->i_size); | 787 | di->di_size = cpu_to_be64(inode->i_size); |
787 | mark_inode_dirty(inode); | 788 | mark_inode_dirty(inode); |
788 | } | 789 | } |
@@ -847,9 +848,9 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, | |||
847 | 848 | ||
848 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); | 849 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); |
849 | 850 | ||
850 | if (likely(ret >= 0) && (inode->i_size > ip->i_di.di_size)) { | 851 | if (likely(ret >= 0) && (inode->i_size > ip->i_disksize)) { |
851 | di = (struct gfs2_dinode *)dibh->b_data; | 852 | di = (struct gfs2_dinode *)dibh->b_data; |
852 | ip->i_di.di_size = inode->i_size; | 853 | ip->i_disksize = inode->i_size; |
853 | di->di_size = cpu_to_be64(inode->i_size); | 854 | di->di_size = cpu_to_be64(inode->i_size); |
854 | mark_inode_dirty(inode); | 855 | mark_inode_dirty(inode); |
855 | } | 856 | } |