xfs: use XFS_IFORK_Q to determine the presence of an xattr fork
authorDarrick J. Wong <djwong@kernel.org>
Sat, 9 Jul 2022 17:56:06 +0000 (10:56 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sat, 9 Jul 2022 22:17:21 +0000 (15:17 -0700)
commite45d7cb2356e6b59fe64da28324025cc6fcd3fbd
tree19d84f0fc674b316e04ed33854262623c42fa4cc
parent2ed5b09b3e8fc274ae8fecd6ab7c5106a364bed1
xfs: use XFS_IFORK_Q to determine the presence of an xattr fork

Modify xfs_ifork_ptr to return a NULL pointer if the caller asks for the
attribute fork but i_forkoff is zero.  This eliminates the ambiguity
between i_forkoff and i_af.if_present, which should make it easier to
understand the lifetime of attr forks.

While we're at it, remove the if_present checks around calls to
xfs_idestroy_fork and xfs_ifork_zap_attr since they can both handle attr
forks that have already been torn down.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr.h
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_inode_fork.c
fs/xfs/libxfs/xfs_inode_fork.h
fs/xfs/xfs_attr_inactive.c
fs/xfs/xfs_attr_list.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h