diff options
Diffstat (limited to 'fs/xfs/xfs_iops.c')
-rw-r--r-- | fs/xfs/xfs_iops.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 1f7c275ec894..e4ccef86fe28 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -24,6 +24,7 @@ #include "xfs_ioctl.h" #include "xfs_health.h" #include "xfs_bmap.h" +#include "xfs_reflink.h" #include <linux/posix_acl.h> #include <linux/security.h> @@ -935,10 +936,24 @@ xfs_setattr_size( * truncate. */ if (newsize > oldsize) { + if (xfs_inode_needs_cow_around(ip)) { + error = xfs_file_cow_around(ip, oldsize, + newsize - oldsize); + if (error) + return error; + } + trace_xfs_zero_eof(ip, oldsize, newsize - oldsize); error = iomap_zero_range(inode, oldsize, newsize - oldsize, &did_zeroing, &xfs_buffered_write_iomap_ops); } else { + if (xfs_inode_needs_cow_around(ip)) { + error = xfs_file_cow_around(ip, newsize, + oldsize - newsize); + if (error) + return error; + } + /* * iomap won't detect a dirty page over an unwritten block (or a * cow block over a hole) and subsequently skips zeroing the |