Skip to contentSkip to conversation

small fixes for the always_cow mode

PATCH In review Christoph Hellwig 2 participants 7 messages Oct 11, 2019 – Oct 14, 2019 XFS filesystem

lore
Share & tools
lore
#0 lore raw

Hi all,

two little fixes for the always_cow debug mode, found while doing early feature development based on it.

#1 lore raw

PATCH 1/2 xfs: disable xfs_ioc_space for always COW inodes

If we always have to write out of place preallocating blocks is pointless. We already check for this in the normal falloc path, but the check was missig in the legacy ALLOCSP path.

---
 fs/xfs/xfs_ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/xfs/xfs_ioctl.c +4 -0
index d58f0d6a699e..abf7a102376f 100644
@@ -33,6 +33,7 @@
 #include "xfs_sb.h"
 #include "xfs_ag.h"
 #include "xfs_health.h"
+#include "xfs_reflink.h"
 
 #include <linux/mount.h>
 #include <linux/namei.h>
@@ -607,6 +608,9 @@ xfs_ioc_space(
 	if (!S_ISREG(inode->i_mode))
 		return -EINVAL;
 
+	if (xfs_is_always_cow_inode(ip))
+		return -EOPNOTSUPP;
+
 	if (filp->f_flags & O_DSYNC)
 		flags |= XFS_PREALLOC_SYNC;
 	if (filp->f_mode & FMODE_NOCMTIME)
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/2] xfs: disable xfs_ioc_space for always COW inodes

Quoted 3 lines · Christoph Hellwig

If we always have to write out of place preallocating blocks is pointless. We already check for this in the normal falloc path, but the check was missig in the legacy ALLOCSP path.

This function handles other things than preallocation, such as XFS_IOC_ZERO_RANGE and XFS_IOC_UNRESVSP, which call xfs_zero_file_space and xfs_free_file_space, respectively. We don't prohibit fallocate from calling those two functions on an always_cow inode, so why do that here?

--D

Quoted 31 lines
---
 fs/xfs/xfs_ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/xfs/xfs_ioctl.c +4 -0
index d58f0d6a699e..abf7a102376f 100644
@@ -33,6 +33,7 @@
 #include "xfs_sb.h"
 #include "xfs_ag.h"
 #include "xfs_health.h"
+#include "xfs_reflink.h"
 
 #include <linux/mount.h>
 #include <linux/namei.h>
@@ -607,6 +608,9 @@ xfs_ioc_space(
 	if (!S_ISREG(inode->i_mode))
 		return -EINVAL;
 
+	if (xfs_is_always_cow_inode(ip))
+		return -EOPNOTSUPP;
+
 	if (filp->f_flags & O_DSYNC)
 		flags |= XFS_PREALLOC_SYNC;
 	if (filp->f_mode & FMODE_NOCMTIME)
Signature · 1 line
2.20.1
#3 lore raw

Re: [PATCH 1/2] xfs: disable xfs_ioc_space for always COW inodes

Quoted 10 lines · Darrick J. Wong
Quoted 3 lines · Christoph Hellwig

If we always have to write out of place preallocating blocks is pointless. We already check for this in the normal falloc path, but the check was missig in the legacy ALLOCSP path.

This function handles other things than preallocation, such as XFS_IOC_ZERO_RANGE and XFS_IOC_UNRESVSP, which call xfs_zero_file_space and xfs_free_file_space, respectively. We don't prohibit fallocate from calling those two functions on an always_cow inode, so why do that here?

True. I actually have a patch in my tree that switches those to be handled in the core so that they enter XFS through ->fallocate. It didn't make any sense to send this patch before that other change, sorry.

#4 lore raw

PATCH 2/2 xfs: ignore extent size hints for always COW inodes

In reply to Christoph Hellwig

There is no point in applying extent size hints for always COW inodes, as we would just have to COW any extra allocation beyond the data actually written.

---
 fs/xfs/xfs_inode.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/xfs/xfs_inode.c +6 -0
index 18f4b262e61c..2e94deb4610a 100644
@@ -55,6 +55,12 @@ xfs_extlen_t
 xfs_get_extsz_hint(
 	struct xfs_inode	*ip)
 {
+	/*
+	 * No point in aligning allocations if we need to COW to actually
+	 * write to them.
+	 */
+	if (xfs_is_always_cow_inode(ip))
+		return 0;
 	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
 		return ip->i_d.di_extsize;
 	if (XFS_IS_REALTIME_INODE(ip))
Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] xfs: ignore extent size hints for always COW inodes

Quoted 5 lines · Christoph Hellwig

There is no point in applying extent size hints for always COW inodes, as we would just have to COW any extra allocation beyond the data actually written.

Looks ok, I guess?

By the way, what's the plan for always_cow inodes, seeing as it's still only a debugging feature?

--D

Quoted 24 lines
---
 fs/xfs/xfs_inode.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/xfs/xfs_inode.c +6 -0
index 18f4b262e61c..2e94deb4610a 100644
@@ -55,6 +55,12 @@ xfs_extlen_t
 xfs_get_extsz_hint(
 	struct xfs_inode	*ip)
 {
+	/*
+	 * No point in aligning allocations if we need to COW to actually
+	 * write to them.
+	 */
+	if (xfs_is_always_cow_inode(ip))
+		return 0;
 	if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize)
 		return ip->i_d.di_extsize;
 	if (XFS_IS_REALTIME_INODE(ip))
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH 2/2] xfs: ignore extent size hints for always COW inodes

Quoted 11 lines · Darrick J. Wong
Quoted 5 lines · Christoph Hellwig

There is no point in applying extent size hints for always COW inodes, as we would just have to COW any extra allocation beyond the data actually written.

Looks ok, I guess?

By the way, what's the plan for always_cow inodes, seeing as it's still only a debugging feature?

Support for zoned devices and an O_ATOMIC-like mode that supports data integrity safe overwrites. I've found some time to spend on both lately, but the former might land on the list first.