Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: update fork seq counter on data fork changes

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>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

authored by

Brian Foster and committed by
Darrick J. Wong
9f9bc034 d519da41

+7 -8
+6 -7
fs/xfs/libxfs/xfs_iext_tree.c
··· 614 614 } 615 615 616 616 /* 617 - * Increment the sequence counter if we are on a COW fork. This allows 618 - * the writeback code to skip looking for a COW extent if the COW fork 619 - * hasn't changed. We use WRITE_ONCE here to ensure the update to the 620 - * sequence counter is seen before the modifications to the extent 621 - * tree itself take effect. 617 + * Increment the sequence counter on extent tree changes. If we are on a COW 618 + * fork, this allows the writeback code to skip looking for a COW extent if the 619 + * COW fork hasn't changed. We use WRITE_ONCE here to ensure the update to the 620 + * sequence counter is seen before the modifications to the extent tree itself 621 + * take effect. 622 622 */ 623 623 static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp, int state) 624 624 { 625 - if (state & BMAP_COWFORK) 626 - WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); 625 + WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); 627 626 } 628 627 629 628 void
+1 -1
fs/xfs/libxfs/xfs_inode_fork.h
··· 14 14 */ 15 15 struct xfs_ifork { 16 16 int if_bytes; /* bytes in if_u1 */ 17 - unsigned int if_seq; /* cow fork mod counter */ 17 + unsigned int if_seq; /* fork mod counter */ 18 18 struct xfs_btree_block *if_broot; /* file's incore btree root */ 19 19 short if_broot_bytes; /* bytes allocated for root */ 20 20 unsigned char if_flags; /* per-fork flags */