summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:19:51 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-09-17 18:55:27 -0700
commitdf2537664cbc20922c701b5aef068128e37af58d (patch)
tree7af966ef6bde8055b3a9cb55ee700a51b9b123be
parent7457d3a9f6b43c6d75f73ce1cad3cd422d78b54c (diff)
xfs: enable extent size hints for CoW when rtextsize > 1
CoW extent size hints are not allowed on filesystems that have large realtime extents because we only want to perform the minimum required amount of write-around (aka write amplification) for shared extents. On filesystems where rtextsize > 1, allocations can only be done in units of full rt extents, which means that we can only map an entire rt extent's worth of blocks into the data fork. Hole punch requests become conversions to unwritten if the request isn't aligned properly. Because a copy-write fundamentally requires remapping, this means that we also can only do copy-writes of a full rt extent. This is too expensive for large hint sizes, since it's all or nothing. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index aa4bc2b5aab1..f6e44d203786 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -6406,6 +6406,28 @@ xfs_get_cowextsz_hint(
if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
a = ip->i_cowextsize;
if (XFS_IS_REALTIME_INODE(ip)) {
+ /*
+ * For realtime files, the realtime extent is the fundamental
+ * unit of allocation. This means that data sharing and CoW
+ * remapping can only be done in those units. For filesystems
+ * where the extent size is larger than one block, write
+ * requests that are not aligned to an extent boundary employ
+ * an unshare-around strategy to ensure that all pages for a
+ * shared extent are fully dirtied.
+ *
+ * Because the remapping alignment requirement applies equally
+ * to all CoW writes, any regular overwrites that could be
+ * turned (by a speculative CoW preallocation) into a CoW write
+ * must either employ this dirty-around strategy, or be smart
+ * enough to ignore the CoW fork mapping unless the entire
+ * extent is dirty or becomes shared by writeback time. Doing
+ * the first would dramatically increase write amplification,
+ * and the second would require deeper insight into the state
+ * of the page cache during a writeback request. For now, we
+ * ignore the hint.
+ */
+ if (ip->i_mount->m_sb.sb_rextsize > 1)
+ return ip->i_mount->m_sb.sb_rextsize;
b = 0;
if (ip->i_diflags & XFS_DIFLAG_EXTSIZE)
b = ip->i_extsize;