xfs: factor out a new xfs_log_force_inode helper
PATCH 1/2 xfs: factor out a new xfs_log_force_inode helper
Create a new helper to force the log up to the last LSN touching an inode.
--- fs/xfs/xfs_export.c | 14 +------------- fs/xfs/xfs_file.c | 12 +----------- fs/xfs/xfs_inode.c | 19 +++++++++++++++++++ fs/xfs/xfs_inode.h | 1 + 4 files changed, 22 insertions(+), 24 deletions(-)
fs/xfs/xfs_export.c +1 -13
@@ -15,7 +15,6 @@#include "xfs_trans.h" #include "xfs_inode_item.h" #include "xfs_icache.h" -#include "xfs_log.h" #include "xfs_pnfs.h" /*
@@ -221,18 +220,7 @@ STATIC intxfs_fs_nfs_commit_metadata ( struct inode *inode) { -struct xfs_inode *ip =XFS_I (inode); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ; - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (XFS_I (inode)); }const struct export_operations xfs_export_operations = {
fs/xfs/xfs_file.c +1 -11
@@ -80,19 +80,9 @@ xfs_dir_fsync( int datasync) {struct xfs_inode *ip =XFS_I (file->f_mapping->host); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ;trace_xfs_dir_fsync (ip); - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (ip); }STATIC int
fs/xfs/xfs_inode.c +19 -0
@@ -3951,3 +3951,22 @@ xfs_irele(trace_xfs_irele (ip, _RET_IP_);iput (VFS_I (ip)); } + +/* +* Ensure all commited transactions touching the inode are written to the log. +*/ +int +xfs_log_force_inode ( +struct xfs_inode *ip) +{ +xfs_lsn_t lsn =0 ; + +xfs_ilock (ip,XFS_ILOCK_SHARED ); +if (xfs_ipincount (ip)) + lsn = ip->i_itemp->ili_last_lsn; +xfs_iunlock (ip,XFS_ILOCK_SHARED ); + +if (!lsn) +return 0 ; +return xfs_log_force_lsn (ip->i_mount, lsn,XFS_LOG_SYNC ,NULL ); +}
fs/xfs/xfs_inode.h +1 -0
@@ -426,6 +426,7 @@ int xfs_itruncate_extents_flags(struct xfs_trans **, struct xfs_inode *, int, xfs_fsize_t, int);void xfs_iext_realloc (xfs_inode_t *,int ,int ); +int xfs_log_force_inode (struct xfs_inode *ip);void xfs_iunpin_wait (xfs_inode_t *);#define xfs_ipincount (ip) ((unsigned int) atomic_read(&ip->i_pincount))
Signature · 1 line
2.25.1
PATCH 2/2 xfs: reflink should force the log out if mounted with wsync
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/xfs_file.c +4 -0
@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)
Signature · 1 line
2.25.1
Re: [PATCH 2/2] xfs: reflink should force the log out if mounted with wsync
Quoted 5 lines · Christoph Hellwig
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
Fixes 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range")Signed-off-by Christoph Hellwig <[email protected]>
Seems like a cleaner implementation than the one I came up with,
--D
Quoted 23 lines
--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_file.c +4
-0@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)Signature · 1 line
2.25.1
Re: [PATCH 2/2] xfs: reflink should force the log out if mounted with wsync
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
Isn't WSYNC for namespace operations? Why is this needed for reflink?
Quoted 1 line
Fixes 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range")
At a glance this looks like a refactoring patch. What does this fix?
Brian
Quoted 24 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_file.c +4
-0@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)Signature · 1 line
2.25.1
Re: [PATCH 2/2] xfs: reflink should force the log out if mounted with wsync
Quoted 6 lines · Brian Foster
Quoted 3 lines · Christoph Hellwig
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
Isn't WSYNC for namespace operations? Why is this needed for reflink?
The manpage says that 'wsync' (the mount option) is for making namespace operations synchronous.
However, xfs_init_fs_context sets XFS_MOUNT_WSYNC if the admin set the 'sync' mount option, which makes all IO synchronous.
Quoted 3 lines
Quoted 1 line
Fixes 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range")At a glance this looks like a refactoring patch. What does this fix?
It probably ought to be 862bb360ef569f ("xfs: reflink extents from one file to another") but so much of that was refactored for 5.0 that backporting this fix will require changing a totally different function (xfs_reflink_remap_range) in a totally different file (xfs_reflink.c).
--D
Quoted 27 lines
Brian
Quoted 24 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_file.c +4
-0@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)Signature · 1 line
2.25.1
Brian Foster
Reviewed-byRe: [PATCH 2/2] xfs: reflink should force the log out if mounted with wsync
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines · Brian Foster
Quoted 3 lines · Christoph Hellwig
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
Quoted 8 lines
Quoted 1 line
Isn't WSYNC for namespace operations? Why is this needed for reflink?
The manpage says that 'wsync' (the mount option) is for making namespace operations synchronous.
However,
xfs_init_fs_contextsetsXFS_MOUNT_WSYNCif the admin set the 'sync' mount option, which makes all IO synchronous.
Ok.. so we're considering reflink a form of I/O.. I suppose that makes sense, though it would be nice to explain that in the commit log...
Quoted 39 lines
Quoted 3 lines
Quoted 1 line
Fixes 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range")At a glance this looks like a refactoring patch. What does this fix?
It probably ought to be
862bb360ef569f("xfs: reflink extents from one file to another") but so much of that was refactored for 5.0 that backporting this fix will require changing a totally different function (xfs_reflink_remap_range) in a totally different file (xfs_reflink.c).--D
Quoted 27 lines
Brian
Quoted 24 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_file.c +4
-0@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)Signature · 1 line
2.25.1
Re: [PATCH 2/2] xfs: reflink should force the log out if mounted with wsync
Quoted 12 lines · Brian Foster
Quoted 11 lines · Darrick J. Wong
Quoted 6 lines · Brian Foster
Quoted 3 lines · Christoph Hellwig
Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs.
Isn't WSYNC for namespace operations? Why is this needed for reflink?
The manpage says that 'wsync' (the mount option) is for making namespace operations synchronous.
Quoted 6 lines
Quoted 3 lines
However,
xfs_init_fs_contextsetsXFS_MOUNT_WSYNCif the admin set the 'sync' mount option, which makes all IO synchronous.Ok.. so we're considering reflink a form of I/O.. I suppose that makes sense, though it would be nice to explain that in the commit log...
Ok, I'll add the following:
[Note: XFS_MOUNT_WSYNC is set when the admin mounts the filesystem with either the 'wsync' or 'sync' mount options, which effectively means that we're classifying reflink/dedupe as IO operations and making them synchronous when required.]
Thanks for reviewing. :)
--D
Quoted 42 lines
Reviewed-by Brian Foster <[email protected]>Quoted 39 lines
Quoted 3 lines
Quoted 1 line
Fixes 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range")At a glance this looks like a refactoring patch. What does this fix?
It probably ought to be
862bb360ef569f("xfs: reflink extents from one file to another") but so much of that was refactored for 5.0 that backporting this fix will require changing a totally different function (xfs_reflink_remap_range) in a totally different file (xfs_reflink.c).--D
Quoted 27 lines
Brian
Quoted 24 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/xfs_file.c +4
-0@@ -1059,7 +1059,11 @@ xfs_file_remap_range( ret =xfs_reflink_update_dest (dest, pos_out + len, cowextsize, remap_flags); +if (ret) + goto out_unlock; +if (mp->m_flags &XFS_MOUNT_WSYNC ) +xfs_log_force_inode (dest); out_unlock:xfs_reflink_remap_unlock (file_in, file_out);if (ret)Signature · 1 line
2.25.1
Quoted 4 lines · Christoph Hellwig
Create a new helper to force the log up to the last LSN touching an inode.
Signed-off-by Christoph Hellwig <[email protected]>
Looks reasonable,
--D
Quoted 106 lines
--- fs/xfs/xfs_export.c | 14 +------------- fs/xfs/xfs_file.c | 12 +----------- fs/xfs/xfs_inode.c | 19 +++++++++++++++++++ fs/xfs/xfs_inode.h | 1 + 4 files changed, 22 insertions(+), 24 deletions(-)fs/xfs/xfs_export.c +1
-13@@ -15,7 +15,6 @@#include "xfs_trans.h" #include "xfs_inode_item.h" #include "xfs_icache.h" -#include "xfs_log.h" #include "xfs_pnfs.h" /* @@ -221,18 +220,7 @@ STATIC intxfs_fs_nfs_commit_metadata ( struct inode *inode) { -struct xfs_inode *ip =XFS_I (inode); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ; - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (XFS_I (inode)); }const struct export_operations xfs_export_operations = {fs/xfs/xfs_file.c +1
-11@@ -80,19 +80,9 @@ xfs_dir_fsync( int datasync) {struct xfs_inode *ip =XFS_I (file->f_mapping->host); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ;trace_xfs_dir_fsync (ip); - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (ip); }STATIC intfs/xfs/xfs_inode.c +19
-0@@ -3951,3 +3951,22 @@ xfs_irele(trace_xfs_irele (ip, _RET_IP_);iput (VFS_I (ip)); } + +/* +* Ensure all commited transactions touching the inode are written to the log. +*/ +int +xfs_log_force_inode ( +struct xfs_inode *ip) +{ +xfs_lsn_t lsn =0 ; + +xfs_ilock (ip,XFS_ILOCK_SHARED ); +if (xfs_ipincount (ip)) + lsn = ip->i_itemp->ili_last_lsn; +xfs_iunlock (ip,XFS_ILOCK_SHARED ); + +if (!lsn) +return 0 ; +return xfs_log_force_lsn (ip->i_mount, lsn,XFS_LOG_SYNC ,NULL ); +}fs/xfs/xfs_inode.h +1
-0@@ -426,6 +426,7 @@ int xfs_itruncate_extents_flags(struct xfs_trans **, struct xfs_inode *, int, xfs_fsize_t, int);void xfs_iext_realloc (xfs_inode_t *,int ,int ); +int xfs_log_force_inode (struct xfs_inode *ip);void xfs_iunpin_wait (xfs_inode_t *);#define xfs_ipincount (ip) ((unsigned int) atomic_read(&ip->i_pincount))Signature · 1 line
2.25.1
Quoted 5 lines · Christoph Hellwig
Create a new helper to force the log up to the last LSN touching an inode.
Signed-off-by Christoph Hellwig <[email protected]>---
Quoted 105 lines
fs/xfs/xfs_export.c | 14 +------------- fs/xfs/xfs_file.c | 12 +----------- fs/xfs/xfs_inode.c | 19 +++++++++++++++++++ fs/xfs/xfs_inode.h | 1 + 4 files changed, 22 insertions(+), 24 deletions(-)fs/xfs/xfs_export.c +1
-13@@ -15,7 +15,6 @@#include "xfs_trans.h" #include "xfs_inode_item.h" #include "xfs_icache.h" -#include "xfs_log.h" #include "xfs_pnfs.h" /* @@ -221,18 +220,7 @@ STATIC intxfs_fs_nfs_commit_metadata ( struct inode *inode) { -struct xfs_inode *ip =XFS_I (inode); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ; - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (XFS_I (inode)); }const struct export_operations xfs_export_operations = {fs/xfs/xfs_file.c +1
-11@@ -80,19 +80,9 @@ xfs_dir_fsync( int datasync) {struct xfs_inode *ip =XFS_I (file->f_mapping->host); -struct xfs_mount *mp = ip->i_mount; -xfs_lsn_t lsn =0 ;trace_xfs_dir_fsync (ip); - -xfs_ilock (ip,XFS_ILOCK_SHARED ); -if (xfs_ipincount (ip)) - lsn = ip->i_itemp->ili_last_lsn; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -if (!lsn) -return 0 ; -return xfs_log_force_lsn (mp, lsn,XFS_LOG_SYNC ,NULL ); +return xfs_log_force_inode (ip); }STATIC intfs/xfs/xfs_inode.c +19
-0@@ -3951,3 +3951,22 @@ xfs_irele(trace_xfs_irele (ip, _RET_IP_);iput (VFS_I (ip)); } + +/* +* Ensure all commited transactions touching the inode are written to the log. +*/ +int +xfs_log_force_inode ( +struct xfs_inode *ip) +{ +xfs_lsn_t lsn =0 ; + +xfs_ilock (ip,XFS_ILOCK_SHARED ); +if (xfs_ipincount (ip)) + lsn = ip->i_itemp->ili_last_lsn; +xfs_iunlock (ip,XFS_ILOCK_SHARED ); + +if (!lsn) +return 0 ; +return xfs_log_force_lsn (ip->i_mount, lsn,XFS_LOG_SYNC ,NULL ); +}fs/xfs/xfs_inode.h +1
-0@@ -426,6 +426,7 @@ int xfs_itruncate_extents_flags(struct xfs_trans **, struct xfs_inode *, int, xfs_fsize_t, int);void xfs_iext_realloc (xfs_inode_t *,int ,int ); +int xfs_log_force_inode (struct xfs_inode *ip);void xfs_iunpin_wait (xfs_inode_t *);#define xfs_ipincount (ip) ((unsigned int) atomic_read(&ip->i_pincount))Signature · 1 line
2.25.1