diff options
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index deb2b132ae5e..21441ddb5506 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -547,6 +547,9 @@ bail: | |||
547 | * | 547 | * |
548 | * called like this: dio->get_blocks(dio->inode, fs_startblk, | 548 | * called like this: dio->get_blocks(dio->inode, fs_startblk, |
549 | * fs_count, map_bh, dio->rw == WRITE); | 549 | * fs_count, map_bh, dio->rw == WRITE); |
550 | * | ||
551 | * Note that we never bother to allocate blocks here, and thus ignore the | ||
552 | * create argument. | ||
550 | */ | 553 | */ |
551 | static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | 554 | static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, |
552 | struct buffer_head *bh_result, int create) | 555 | struct buffer_head *bh_result, int create) |
@@ -563,14 +566,6 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
563 | 566 | ||
564 | inode_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); | 567 | inode_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); |
565 | 568 | ||
566 | /* | ||
567 | * Any write past EOF is not allowed because we'd be extending. | ||
568 | */ | ||
569 | if (create && (iblock + max_blocks) > inode_blocks) { | ||
570 | ret = -EIO; | ||
571 | goto bail; | ||
572 | } | ||
573 | |||
574 | /* This figures out the size of the next contiguous block, and | 569 | /* This figures out the size of the next contiguous block, and |
575 | * our logical offset */ | 570 | * our logical offset */ |
576 | ret = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno, | 571 | ret = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno, |
@@ -582,17 +577,9 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
582 | goto bail; | 577 | goto bail; |
583 | } | 578 | } |
584 | 579 | ||
585 | if (!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)) && !p_blkno && create) { | 580 | /* We should already CoW the refcounted extent in case of create. */ |
586 | ocfs2_error(inode->i_sb, | 581 | BUG_ON(create && (ext_flags & OCFS2_EXT_REFCOUNTED)); |
587 | "Inode %llu has a hole at block %llu\n", | ||
588 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
589 | (unsigned long long)iblock); | ||
590 | ret = -EROFS; | ||
591 | goto bail; | ||
592 | } | ||
593 | 582 | ||
594 | /* We should already CoW the refcounted extent. */ | ||
595 | BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED); | ||
596 | /* | 583 | /* |
597 | * get_more_blocks() expects us to describe a hole by clearing | 584 | * get_more_blocks() expects us to describe a hole by clearing |
598 | * the mapped bit on bh_result(). | 585 | * the mapped bit on bh_result(). |
@@ -601,20 +588,8 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
601 | */ | 588 | */ |
602 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) | 589 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) |
603 | map_bh(bh_result, inode->i_sb, p_blkno); | 590 | map_bh(bh_result, inode->i_sb, p_blkno); |
604 | else { | 591 | else |
605 | /* | ||
606 | * ocfs2_prepare_inode_for_write() should have caught | ||
607 | * the case where we'd be filling a hole and triggered | ||
608 | * a buffered write instead. | ||
609 | */ | ||
610 | if (create) { | ||
611 | ret = -EIO; | ||
612 | mlog_errno(ret); | ||
613 | goto bail; | ||
614 | } | ||
615 | |||
616 | clear_buffer_mapped(bh_result); | 592 | clear_buffer_mapped(bh_result); |
617 | } | ||
618 | 593 | ||
619 | /* make sure we don't map more than max_blocks blocks here as | 594 | /* make sure we don't map more than max_blocks blocks here as |
620 | that's all the kernel will handle at this point. */ | 595 | that's all the kernel will handle at this point. */ |
@@ -625,7 +600,7 @@ bail: | |||
625 | return ret; | 600 | return ret; |
626 | } | 601 | } |
627 | 602 | ||
628 | /* | 603 | /* |
629 | * ocfs2_dio_end_io is called by the dio core when a dio is finished. We're | 604 | * ocfs2_dio_end_io is called by the dio core when a dio is finished. We're |
630 | * particularly interested in the aio/dio case. Like the core uses | 605 | * particularly interested in the aio/dio case. Like the core uses |
631 | * i_alloc_sem, we use the rw_lock DLM lock to protect io on one node from | 606 | * i_alloc_sem, we use the rw_lock DLM lock to protect io on one node from |
@@ -696,7 +671,7 @@ static ssize_t ocfs2_direct_IO(int rw, | |||
696 | 671 | ||
697 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, | 672 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, |
698 | inode->i_sb->s_bdev, iov, offset, | 673 | inode->i_sb->s_bdev, iov, offset, |
699 | nr_segs, | 674 | nr_segs, |
700 | ocfs2_direct_IO_get_blocks, | 675 | ocfs2_direct_IO_get_blocks, |
701 | ocfs2_dio_end_io); | 676 | ocfs2_dio_end_io); |
702 | 677 | ||
@@ -1789,10 +1764,11 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, | |||
1789 | 1764 | ||
1790 | wc->w_handle = handle; | 1765 | wc->w_handle = handle; |
1791 | 1766 | ||
1792 | if (clusters_to_alloc && vfs_dq_alloc_space_nodirty(inode, | 1767 | if (clusters_to_alloc) { |
1793 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc))) { | 1768 | ret = dquot_alloc_space_nodirty(inode, |
1794 | ret = -EDQUOT; | 1769 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); |
1795 | goto out_commit; | 1770 | if (ret) |
1771 | goto out_commit; | ||
1796 | } | 1772 | } |
1797 | /* | 1773 | /* |
1798 | * We don't want this to fail in ocfs2_write_end(), so do it | 1774 | * We don't want this to fail in ocfs2_write_end(), so do it |
@@ -1835,7 +1811,7 @@ success: | |||
1835 | return 0; | 1811 | return 0; |
1836 | out_quota: | 1812 | out_quota: |
1837 | if (clusters_to_alloc) | 1813 | if (clusters_to_alloc) |
1838 | vfs_dq_free_space(inode, | 1814 | dquot_free_space(inode, |
1839 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); | 1815 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); |
1840 | out_commit: | 1816 | out_commit: |
1841 | ocfs2_commit_trans(osb, handle); | 1817 | ocfs2_commit_trans(osb, handle); |