162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2000,2005 Silicon Graphics, Inc.
462306a36Sopenharmony_ci * All Rights Reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef	__XFS_INODE_ITEM_H__
762306a36Sopenharmony_ci#define	__XFS_INODE_ITEM_H__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* kernel only definitions */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct xfs_buf;
1262306a36Sopenharmony_cistruct xfs_bmbt_rec;
1362306a36Sopenharmony_cistruct xfs_inode;
1462306a36Sopenharmony_cistruct xfs_mount;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistruct xfs_inode_log_item {
1762306a36Sopenharmony_ci	struct xfs_log_item	ili_item;	   /* common portion */
1862306a36Sopenharmony_ci	struct xfs_inode	*ili_inode;	   /* inode ptr */
1962306a36Sopenharmony_ci	unsigned short		ili_lock_flags;	   /* inode lock flags */
2062306a36Sopenharmony_ci	unsigned int		ili_dirty_flags;   /* dirty in current tx */
2162306a36Sopenharmony_ci	/*
2262306a36Sopenharmony_ci	 * The ili_lock protects the interactions between the dirty state and
2362306a36Sopenharmony_ci	 * the flush state of the inode log item. This allows us to do atomic
2462306a36Sopenharmony_ci	 * modifications of multiple state fields without having to hold a
2562306a36Sopenharmony_ci	 * specific inode lock to serialise them.
2662306a36Sopenharmony_ci	 *
2762306a36Sopenharmony_ci	 * We need atomic changes between inode dirtying, inode flushing and
2862306a36Sopenharmony_ci	 * inode completion, but these all hold different combinations of
2962306a36Sopenharmony_ci	 * ILOCK and IFLUSHING and hence we need some other method of
3062306a36Sopenharmony_ci	 * serialising updates to the flush state.
3162306a36Sopenharmony_ci	 */
3262306a36Sopenharmony_ci	spinlock_t		ili_lock;	   /* flush state lock */
3362306a36Sopenharmony_ci	unsigned int		ili_last_fields;   /* fields when flushed */
3462306a36Sopenharmony_ci	unsigned int		ili_fields;	   /* fields to be logged */
3562306a36Sopenharmony_ci	unsigned int		ili_fsync_fields;  /* logged since last fsync */
3662306a36Sopenharmony_ci	xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */
3762306a36Sopenharmony_ci	xfs_csn_t		ili_commit_seq;	   /* last transaction commit */
3862306a36Sopenharmony_ci};
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cistatic inline int xfs_inode_clean(struct xfs_inode *ip)
4162306a36Sopenharmony_ci{
4262306a36Sopenharmony_ci	return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL);
4362306a36Sopenharmony_ci}
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciextern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
4662306a36Sopenharmony_ciextern void xfs_inode_item_destroy(struct xfs_inode *);
4762306a36Sopenharmony_ciextern void xfs_iflush_abort(struct xfs_inode *);
4862306a36Sopenharmony_ciextern void xfs_iflush_shutdown_abort(struct xfs_inode *);
4962306a36Sopenharmony_ciextern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
5062306a36Sopenharmony_ci					 struct xfs_inode_log_format *);
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciextern struct kmem_cache	*xfs_ili_cache;
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#endif	/* __XFS_INODE_ITEM_H__ */
55