aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/aops.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2009-08-24 20:02:48 -0400
committerJoel Becker <joel.becker@oracle.com>2009-09-22 23:09:37 -0400
commit293b2f70b4a16a1ca91efd28ef3d6634262c6887 (patch)
tree4a85078faae7c529fa313d4964e0d6ad0905a612 /fs/ocfs2/aops.c
parent6ae23c5555176c5b23480c9c578ff27437085ba5 (diff)
ocfs2: Integrate CoW in file write.
When we use mmap, we CoW the refcountd clusters in ocfs2_write_begin_nolock. While for normal file io(including directio), we do CoW in ocfs2_prepare_inode_for_write. Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r--fs/ocfs2/aops.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index fdad075fed61..9db9d64ca475 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -44,6 +44,7 @@
44#include "suballoc.h" 44#include "suballoc.h"
45#include "super.h" 45#include "super.h"
46#include "symlink.h" 46#include "symlink.h"
47#include "refcounttree.h"
47 48
48#include "buffer_head_io.h" 49#include "buffer_head_io.h"
49 50
@@ -590,6 +591,8 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
590 goto bail; 591 goto bail;
591 } 592 }
592 593
594 /* We should already CoW the refcounted extent. */
595 BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED);
593 /* 596 /*
594 * get_more_blocks() expects us to describe a hole by clearing 597 * get_more_blocks() expects us to describe a hole by clearing
595 * the mapped bit on bh_result(). 598 * the mapped bit on bh_result().
@@ -1449,6 +1452,9 @@ static int ocfs2_populate_write_desc(struct inode *inode,
1449 goto out; 1452 goto out;
1450 } 1453 }
1451 1454
1455 /* We should already CoW the refcountd extent. */
1456 BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED);
1457
1452 /* 1458 /*
1453 * Assume worst case - that we're writing in 1459 * Assume worst case - that we're writing in
1454 * the middle of the extent. 1460 * the middle of the extent.
@@ -1700,6 +1706,19 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1700 goto out; 1706 goto out;
1701 } 1707 }
1702 1708
1709 ret = ocfs2_check_range_for_refcount(inode, pos, len);
1710 if (ret < 0) {
1711 mlog_errno(ret);
1712 goto out;
1713 } else if (ret == 1) {
1714 ret = ocfs2_refcount_cow(inode, di_bh,
1715 wc->w_cpos, wc->w_clen);
1716 if (ret) {
1717 mlog_errno(ret);
1718 goto out;
1719 }
1720 }
1721
1703 ret = ocfs2_populate_write_desc(inode, wc, &clusters_to_alloc, 1722 ret = ocfs2_populate_write_desc(inode, wc, &clusters_to_alloc,
1704 &extents_to_split); 1723 &extents_to_split);
1705 if (ret) { 1724 if (ret) {