small fixes for the always_cow mode
Hi all,
two little fixes for the always_cow debug mode, found while doing early feature development based on it.
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
@@ -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
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
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_ioctl.c +4
-0@@ -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
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_RANGEandXFS_IOC_UNRESVSP, which callxfs_zero_file_spaceandxfs_free_file_space, respectively. We don't prohibit fallocate from calling those two functions on analways_cowinode, 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.
PATCH 2/2 xfs: ignore extent size hints for always COW inodes
In reply to Christoph HellwigThere 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
@@ -55,6 +55,12 @@ xfs_extlen_txfs_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
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.
Signed-off-by Christoph Hellwig <[email protected]>
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@@ -55,6 +55,12 @@ xfs_extlen_txfs_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
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.
Signed-off-by Christoph Hellwig <[email protected]>Looks ok, I guess?
By the way, what's the plan for
always_cowinodes, 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.