xref: /OK3568_Linux_fs/kernel/fs/xfs/xfs_inode_item.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4*4882a593Smuzhiyun  * All Rights Reserved.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef	__XFS_INODE_ITEM_H__
7*4882a593Smuzhiyun #define	__XFS_INODE_ITEM_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /* kernel only definitions */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct xfs_buf;
12*4882a593Smuzhiyun struct xfs_bmbt_rec;
13*4882a593Smuzhiyun struct xfs_inode;
14*4882a593Smuzhiyun struct xfs_mount;
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun struct xfs_inode_log_item {
17*4882a593Smuzhiyun 	struct xfs_log_item	ili_item;	   /* common portion */
18*4882a593Smuzhiyun 	struct xfs_inode	*ili_inode;	   /* inode ptr */
19*4882a593Smuzhiyun 	unsigned short		ili_lock_flags;	   /* inode lock flags */
20*4882a593Smuzhiyun 	/*
21*4882a593Smuzhiyun 	 * The ili_lock protects the interactions between the dirty state and
22*4882a593Smuzhiyun 	 * the flush state of the inode log item. This allows us to do atomic
23*4882a593Smuzhiyun 	 * modifications of multiple state fields without having to hold a
24*4882a593Smuzhiyun 	 * specific inode lock to serialise them.
25*4882a593Smuzhiyun 	 *
26*4882a593Smuzhiyun 	 * We need atomic changes between inode dirtying, inode flushing and
27*4882a593Smuzhiyun 	 * inode completion, but these all hold different combinations of
28*4882a593Smuzhiyun 	 * ILOCK and IFLUSHING and hence we need some other method of
29*4882a593Smuzhiyun 	 * serialising updates to the flush state.
30*4882a593Smuzhiyun 	 */
31*4882a593Smuzhiyun 	spinlock_t		ili_lock;	   /* flush state lock */
32*4882a593Smuzhiyun 	unsigned int		ili_last_fields;   /* fields when flushed */
33*4882a593Smuzhiyun 	unsigned int		ili_fields;	   /* fields to be logged */
34*4882a593Smuzhiyun 	unsigned int		ili_fsync_fields;  /* logged since last fsync */
35*4882a593Smuzhiyun 	xfs_lsn_t		ili_flush_lsn;	   /* lsn at last flush */
36*4882a593Smuzhiyun 	xfs_csn_t		ili_commit_seq;	   /* last transaction commit */
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
xfs_inode_clean(struct xfs_inode * ip)39*4882a593Smuzhiyun static inline int xfs_inode_clean(struct xfs_inode *ip)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun 	return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL);
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
45*4882a593Smuzhiyun extern void xfs_inode_item_destroy(struct xfs_inode *);
46*4882a593Smuzhiyun extern void xfs_iflush_abort(struct xfs_inode *);
47*4882a593Smuzhiyun extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
48*4882a593Smuzhiyun 					 struct xfs_inode_log_format *);
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun extern struct kmem_zone	*xfs_ili_zone;
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun #endif	/* __XFS_INODE_ITEM_H__ */
53