aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-03-01 17:10:31 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2018-03-01 17:10:31 -0500
commit172ed391f6e40f799273e005405041b57c343cf7 (patch)
tree787b5bb07ae62d394d988aaa3333a42aa09c04ae
parent5b4c845ea4f4b86c43096eb924354c83a2e26f3c (diff)
xfs: don't allocate COW blocks for zeroing holes or unwritten extents
The iomap zeroing interface is smart enough to skip zeroing holes or unwritten extents. Don't subvert this logic for reflink files. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/xfs_iomap.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 66e1edbfb2b2..4e771e0f1170 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -955,6 +955,13 @@ static inline bool imap_needs_alloc(struct inode *inode,
955 (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); 955 (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN);
956} 956}
957 957
958static inline bool needs_cow_for_zeroing(struct xfs_bmbt_irec *imap, int nimaps)
959{
960 return nimaps &&
961 imap->br_startblock != HOLESTARTBLOCK &&
962 imap->br_state != XFS_EXT_UNWRITTEN;
963}
964
958static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) 965static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags)
959{ 966{
960 /* 967 /*
@@ -1024,7 +1031,9 @@ xfs_file_iomap_begin(
1024 goto out_unlock; 1031 goto out_unlock;
1025 } 1032 }
1026 1033
1027 if ((flags & (IOMAP_WRITE | IOMAP_ZERO)) && xfs_is_reflink_inode(ip)) { 1034 if (xfs_is_reflink_inode(ip) &&
1035 ((flags & IOMAP_WRITE) ||
1036 ((flags & IOMAP_ZERO) && needs_cow_for_zeroing(&imap, nimaps)))) {
1028 if (flags & IOMAP_DIRECT) { 1037 if (flags & IOMAP_DIRECT) {
1029 /* 1038 /*
1030 * A reflinked inode will result in CoW alloc. 1039 * A reflinked inode will result in CoW alloc.