diff mbox series

[v2,2/5] xfs: update fork seq counter on data fork changes

Message ID 20190117192004.49346-3-bfoster@redhat.com (mailing list archive)
State Superseded
Headers show
Series xfs: properly invalidate cached writeback mapping | expand

Commit Message

Brian Foster Jan. 17, 2019, 7:20 p.m. UTC
The sequence counter in the xfs_ifork structure is only updated on
COW forks. This is because the counter is currently only used to
optimize out repetitive COW fork checks at writeback time.

Tweak the extent code to update the seq counter regardless of the
fork type in preparation for using this counter on data forks as
well.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_iext_tree.c  | 13 ++++++-------
 fs/xfs/libxfs/xfs_inode_fork.h |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

Allison Henderson Jan. 18, 2019, 5:30 a.m. UTC | #1
On 1/17/19 12:20 PM, Brian Foster wrote:
> The sequence counter in the xfs_ifork structure is only updated on
> COW forks. This is because the counter is currently only used to
> optimize out repetitive COW fork checks at writeback time.
> 
> Tweak the extent code to update the seq counter regardless of the
> fork type in preparation for using this counter on data forks as
> well.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
>   fs/xfs/libxfs/xfs_iext_tree.c  | 13 ++++++-------
>   fs/xfs/libxfs/xfs_inode_fork.h |  2 +-
>   2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
> index 771dd072015d..bc690f2409fa 100644
> --- a/fs/xfs/libxfs/xfs_iext_tree.c
> +++ b/fs/xfs/libxfs/xfs_iext_tree.c
> @@ -614,16 +614,15 @@ xfs_iext_realloc_root(
>   }
>   
>   /*
> - * Increment the sequence counter if we are on a COW fork.  This allows
> - * the writeback code to skip looking for a COW extent if the COW fork
> - * hasn't changed.  We use WRITE_ONCE here to ensure the update to the
> - * sequence counter is seen before the modifications to the extent
> - * tree itself take effect.
> + * Increment the sequence counter on extent tree changes. If we are on a COW
> + * fork, this allows the writeback code to skip looking for a COW extent if the
> + * COW fork hasn't changed. We use WRITE_ONCE here to ensure the update to the
> + * sequence counter is seen before the modifications to the extent tree itself
> + * take effect.
>    */
>   static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp, int state)
>   {
> -	if (state & BMAP_COWFORK)
> -		WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1);
> +	WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1);
>   }
>   
>   void
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index 60361d2d74a1..00c62ce170d0 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -14,7 +14,7 @@ struct xfs_dinode;
>    */
>   struct xfs_ifork {
>   	int			if_bytes;	/* bytes in if_u1 */
> -	unsigned int		if_seq;		/* cow fork mod counter */
> +	unsigned int		if_seq;		/* fork mod counter */
>   	struct xfs_btree_block	*if_broot;	/* file's incore btree root */
>   	short			if_broot_bytes;	/* bytes allocated for root */
>   	unsigned char		if_flags;	/* per-fork flags */
> 

This one looks fine too:

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
index 771dd072015d..bc690f2409fa 100644
--- a/fs/xfs/libxfs/xfs_iext_tree.c
+++ b/fs/xfs/libxfs/xfs_iext_tree.c
@@ -614,16 +614,15 @@  xfs_iext_realloc_root(
 }
 
 /*
- * Increment the sequence counter if we are on a COW fork.  This allows
- * the writeback code to skip looking for a COW extent if the COW fork
- * hasn't changed.  We use WRITE_ONCE here to ensure the update to the
- * sequence counter is seen before the modifications to the extent
- * tree itself take effect.
+ * Increment the sequence counter on extent tree changes. If we are on a COW
+ * fork, this allows the writeback code to skip looking for a COW extent if the
+ * COW fork hasn't changed. We use WRITE_ONCE here to ensure the update to the
+ * sequence counter is seen before the modifications to the extent tree itself
+ * take effect.
  */
 static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp, int state)
 {
-	if (state & BMAP_COWFORK)
-		WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1);
+	WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1);
 }
 
 void
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index 60361d2d74a1..00c62ce170d0 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -14,7 +14,7 @@  struct xfs_dinode;
  */
 struct xfs_ifork {
 	int			if_bytes;	/* bytes in if_u1 */
-	unsigned int		if_seq;		/* cow fork mod counter */
+	unsigned int		if_seq;		/* fork mod counter */
 	struct xfs_btree_block	*if_broot;	/* file's incore btree root */
 	short			if_broot_bytes;	/* bytes allocated for root */
 	unsigned char		if_flags;	/* per-fork flags */