aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/aops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r--fs/ocfs2/aops.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 9a5c931439bd..742893ea7390 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -196,15 +196,14 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock,
196 dump_stack(); 196 dump_stack();
197 goto bail; 197 goto bail;
198 } 198 }
199
200 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
201 mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino,
202 (unsigned long long)past_eof);
203
204 if (create && (iblock >= past_eof))
205 set_buffer_new(bh_result);
206 } 199 }
207 200
201 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
202 mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino,
203 (unsigned long long)past_eof);
204 if (create && (iblock >= past_eof))
205 set_buffer_new(bh_result);
206
208bail: 207bail:
209 if (err < 0) 208 if (err < 0)
210 err = -EIO; 209 err = -EIO;
@@ -1590,21 +1589,20 @@ out:
1590 * write path can treat it as an non-allocating write, which has no 1589 * write path can treat it as an non-allocating write, which has no
1591 * special case code for sparse/nonsparse files. 1590 * special case code for sparse/nonsparse files.
1592 */ 1591 */
1593static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos, 1592static int ocfs2_expand_nonsparse_inode(struct inode *inode,
1594 unsigned len, 1593 struct buffer_head *di_bh,
1594 loff_t pos, unsigned len,
1595 struct ocfs2_write_ctxt *wc) 1595 struct ocfs2_write_ctxt *wc)
1596{ 1596{
1597 int ret; 1597 int ret;
1598 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1599 loff_t newsize = pos + len; 1598 loff_t newsize = pos + len;
1600 1599
1601 if (ocfs2_sparse_alloc(osb)) 1600 BUG_ON(ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)));
1602 return 0;
1603 1601
1604 if (newsize <= i_size_read(inode)) 1602 if (newsize <= i_size_read(inode))
1605 return 0; 1603 return 0;
1606 1604
1607 ret = ocfs2_extend_no_holes(inode, newsize, pos); 1605 ret = ocfs2_extend_no_holes(inode, di_bh, newsize, pos);
1608 if (ret) 1606 if (ret)
1609 mlog_errno(ret); 1607 mlog_errno(ret);
1610 1608
@@ -1614,6 +1612,18 @@ static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos,
1614 return ret; 1612 return ret;
1615} 1613}
1616 1614
1615static int ocfs2_zero_tail(struct inode *inode, struct buffer_head *di_bh,
1616 loff_t pos)
1617{
1618 int ret = 0;
1619
1620 BUG_ON(!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)));
1621 if (pos > i_size_read(inode))
1622 ret = ocfs2_zero_extend(inode, di_bh, pos);
1623
1624 return ret;
1625}
1626
1617int ocfs2_write_begin_nolock(struct address_space *mapping, 1627int ocfs2_write_begin_nolock(struct address_space *mapping,
1618 loff_t pos, unsigned len, unsigned flags, 1628 loff_t pos, unsigned len, unsigned flags,
1619 struct page **pagep, void **fsdata, 1629 struct page **pagep, void **fsdata,
@@ -1649,7 +1659,11 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1649 } 1659 }
1650 } 1660 }
1651 1661
1652 ret = ocfs2_expand_nonsparse_inode(inode, pos, len, wc); 1662 if (ocfs2_sparse_alloc(osb))
1663 ret = ocfs2_zero_tail(inode, di_bh, pos);
1664 else
1665 ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, len,
1666 wc);
1653 if (ret) { 1667 if (ret) {
1654 mlog_errno(ret); 1668 mlog_errno(ret);
1655 goto out; 1669 goto out;