aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-06-20 19:55:18 -0400
committerDave Chinner <david@fromorbit.com>2016-06-20 19:55:18 -0400
commit459f0fbc2a827da37bbfaf3cae8da4ad8884da12 (patch)
tree80b44e5d30d805ee99a6bfdcbadbb535c5cae506
parentd2bb140e99e6710c1b46e38a6347ada364aadfc6 (diff)
xfs: use iomap infrastructure for DAX zeroing
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_file.c35
-rw-r--r--fs/xfs/xfs_iops.c9
2 files changed, 3 insertions, 41 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 7316d3841c53..090a90f0d02c 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -80,34 +80,6 @@ xfs_rw_ilock_demote(
80 inode_unlock(VFS_I(ip)); 80 inode_unlock(VFS_I(ip));
81} 81}
82 82
83static int
84xfs_dax_zero_range(
85 struct inode *inode,
86 loff_t pos,
87 size_t count)
88{
89 int status = 0;
90
91 do {
92 unsigned offset, bytes;
93
94 offset = (pos & (PAGE_SIZE -1)); /* Within page */
95 bytes = PAGE_SIZE - offset;
96 if (bytes > count)
97 bytes = count;
98
99 status = dax_zero_page_range(inode, pos, bytes,
100 xfs_get_blocks_direct);
101 if (status)
102 break;
103
104 pos += bytes;
105 count -= bytes;
106 } while (count);
107
108 return status;
109}
110
111/* 83/*
112 * Clear the specified ranges to zero through either the pagecache or DAX. 84 * Clear the specified ranges to zero through either the pagecache or DAX.
113 * Holes and unwritten extents will be left as-is as they already are zeroed. 85 * Holes and unwritten extents will be left as-is as they already are zeroed.
@@ -118,12 +90,7 @@ xfs_iozero(
118 loff_t pos, 90 loff_t pos,
119 size_t count) 91 size_t count)
120{ 92{
121 struct inode *inode = VFS_I(ip); 93 return iomap_zero_range(VFS_I(ip), pos, count, NULL, &xfs_iomap_ops);
122
123 if (IS_DAX(VFS_I(ip)))
124 return xfs_dax_zero_range(inode, pos, count);
125 else
126 return iomap_zero_range(inode, pos, count, NULL, &xfs_iomap_ops);
127} 94}
128 95
129int 96int
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 985a263c6144..ab820f84ed50 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -819,13 +819,8 @@ xfs_setattr_size(
819 if (newsize > oldsize) { 819 if (newsize > oldsize) {
820 error = xfs_zero_eof(ip, newsize, oldsize, &did_zeroing); 820 error = xfs_zero_eof(ip, newsize, oldsize, &did_zeroing);
821 } else { 821 } else {
822 if (IS_DAX(inode)) { 822 error = iomap_truncate_page(inode, newsize, &did_zeroing,
823 error = dax_truncate_page(inode, newsize, 823 &xfs_iomap_ops);
824 xfs_get_blocks_direct);
825 } else {
826 error = iomap_truncate_page(inode, newsize,
827 &did_zeroing, &xfs_iomap_ops);
828 }
829 } 824 }
830 825
831 if (error) 826 if (error)