diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/aops.c | 15 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 47 |
2 files changed, 31 insertions, 31 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 4a231a166cf8..1ef547e49373 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -1481,8 +1481,16 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, | |||
1481 | handle_t *handle; | 1481 | handle_t *handle; |
1482 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; | 1482 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; |
1483 | 1483 | ||
1484 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | ||
1485 | if (IS_ERR(handle)) { | ||
1486 | ret = PTR_ERR(handle); | ||
1487 | mlog_errno(ret); | ||
1488 | goto out; | ||
1489 | } | ||
1490 | |||
1484 | page = find_or_create_page(mapping, 0, GFP_NOFS); | 1491 | page = find_or_create_page(mapping, 0, GFP_NOFS); |
1485 | if (!page) { | 1492 | if (!page) { |
1493 | ocfs2_commit_trans(osb, handle); | ||
1486 | ret = -ENOMEM; | 1494 | ret = -ENOMEM; |
1487 | mlog_errno(ret); | 1495 | mlog_errno(ret); |
1488 | goto out; | 1496 | goto out; |
@@ -1494,13 +1502,6 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, | |||
1494 | wc->w_pages[0] = wc->w_target_page = page; | 1502 | wc->w_pages[0] = wc->w_target_page = page; |
1495 | wc->w_num_pages = 1; | 1503 | wc->w_num_pages = 1; |
1496 | 1504 | ||
1497 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | ||
1498 | if (IS_ERR(handle)) { | ||
1499 | ret = PTR_ERR(handle); | ||
1500 | mlog_errno(ret); | ||
1501 | goto out; | ||
1502 | } | ||
1503 | |||
1504 | ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, | 1505 | ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, |
1505 | OCFS2_JOURNAL_ACCESS_WRITE); | 1506 | OCFS2_JOURNAL_ACCESS_WRITE); |
1506 | if (ret) { | 1507 | if (ret) { |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 2930e231f3f9..682732f3f0d8 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -760,7 +760,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
760 | struct address_space *mapping = inode->i_mapping; | 760 | struct address_space *mapping = inode->i_mapping; |
761 | struct page *page; | 761 | struct page *page; |
762 | unsigned long index = abs_from >> PAGE_CACHE_SHIFT; | 762 | unsigned long index = abs_from >> PAGE_CACHE_SHIFT; |
763 | handle_t *handle = NULL; | 763 | handle_t *handle; |
764 | int ret = 0; | 764 | int ret = 0; |
765 | unsigned zero_from, zero_to, block_start, block_end; | 765 | unsigned zero_from, zero_to, block_start, block_end; |
766 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | 766 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; |
@@ -769,11 +769,17 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
769 | BUG_ON(abs_to > (((u64)index + 1) << PAGE_CACHE_SHIFT)); | 769 | BUG_ON(abs_to > (((u64)index + 1) << PAGE_CACHE_SHIFT)); |
770 | BUG_ON(abs_from & (inode->i_blkbits - 1)); | 770 | BUG_ON(abs_from & (inode->i_blkbits - 1)); |
771 | 771 | ||
772 | handle = ocfs2_zero_start_ordered_transaction(inode, di_bh); | ||
773 | if (IS_ERR(handle)) { | ||
774 | ret = PTR_ERR(handle); | ||
775 | goto out; | ||
776 | } | ||
777 | |||
772 | page = find_or_create_page(mapping, index, GFP_NOFS); | 778 | page = find_or_create_page(mapping, index, GFP_NOFS); |
773 | if (!page) { | 779 | if (!page) { |
774 | ret = -ENOMEM; | 780 | ret = -ENOMEM; |
775 | mlog_errno(ret); | 781 | mlog_errno(ret); |
776 | goto out; | 782 | goto out_commit_trans; |
777 | } | 783 | } |
778 | 784 | ||
779 | /* Get the offsets within the page that we want to zero */ | 785 | /* Get the offsets within the page that we want to zero */ |
@@ -805,15 +811,6 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
805 | goto out_unlock; | 811 | goto out_unlock; |
806 | } | 812 | } |
807 | 813 | ||
808 | if (!handle) { | ||
809 | handle = ocfs2_zero_start_ordered_transaction(inode, | ||
810 | di_bh); | ||
811 | if (IS_ERR(handle)) { | ||
812 | ret = PTR_ERR(handle); | ||
813 | handle = NULL; | ||
814 | break; | ||
815 | } | ||
816 | } | ||
817 | 814 | ||
818 | /* must not update i_size! */ | 815 | /* must not update i_size! */ |
819 | ret = block_commit_write(page, block_start + 1, | 816 | ret = block_commit_write(page, block_start + 1, |
@@ -824,27 +821,29 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
824 | ret = 0; | 821 | ret = 0; |
825 | } | 822 | } |
826 | 823 | ||
824 | /* | ||
825 | * fs-writeback will release the dirty pages without page lock | ||
826 | * whose offset are over inode size, the release happens at | ||
827 | * block_write_full_page(). | ||
828 | */ | ||
829 | i_size_write(inode, abs_to); | ||
830 | inode->i_blocks = ocfs2_inode_sector_count(inode); | ||
831 | di->i_size = cpu_to_le64((u64)i_size_read(inode)); | ||
832 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
833 | di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec); | ||
834 | di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); | ||
835 | di->i_mtime_nsec = di->i_ctime_nsec; | ||
827 | if (handle) { | 836 | if (handle) { |
828 | /* | ||
829 | * fs-writeback will release the dirty pages without page lock | ||
830 | * whose offset are over inode size, the release happens at | ||
831 | * block_write_full_page(). | ||
832 | */ | ||
833 | i_size_write(inode, abs_to); | ||
834 | inode->i_blocks = ocfs2_inode_sector_count(inode); | ||
835 | di->i_size = cpu_to_le64((u64)i_size_read(inode)); | ||
836 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
837 | di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec); | ||
838 | di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); | ||
839 | di->i_mtime_nsec = di->i_ctime_nsec; | ||
840 | ocfs2_journal_dirty(handle, di_bh); | 837 | ocfs2_journal_dirty(handle, di_bh); |
841 | ocfs2_update_inode_fsync_trans(handle, inode, 1); | 838 | ocfs2_update_inode_fsync_trans(handle, inode, 1); |
842 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | ||
843 | } | 839 | } |
844 | 840 | ||
845 | out_unlock: | 841 | out_unlock: |
846 | unlock_page(page); | 842 | unlock_page(page); |
847 | page_cache_release(page); | 843 | page_cache_release(page); |
844 | out_commit_trans: | ||
845 | if (handle) | ||
846 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | ||
848 | out: | 847 | out: |
849 | return ret; | 848 | return ret; |
850 | } | 849 | } |