blob: 1a302000d604de54c3b37e6de0e479aa1cd7ef08 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef __XFS_INODE_ITEM_H__
7#define __XFS_INODE_ITEM_H__
8
Dave Chinner69432832013-08-12 20:49:23 +10009/* kernel only definitions */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11struct xfs_buf;
Christoph Hellwiga5f9be52009-12-04 10:19:07 +000012struct xfs_bmbt_rec;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013struct xfs_inode;
14struct xfs_mount;
15
Christoph Hellwigfd9cbe52020-04-30 12:52:19 -070016struct xfs_inode_log_item {
Christoph Hellwigefe23302019-06-28 19:27:33 -070017 struct xfs_log_item ili_item; /* common portion */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 struct xfs_inode *ili_inode; /* inode ptr */
Dave Chinner1319ebe2020-06-29 14:48:46 -070019 unsigned short ili_lock_flags; /* inode lock flags */
20 /*
21 * The ili_lock protects the interactions between the dirty state and
22 * the flush state of the inode log item. This allows us to do atomic
23 * modifications of multiple state fields without having to hold a
24 * specific inode lock to serialise them.
25 *
26 * We need atomic changes between inode dirtying, inode flushing and
27 * inode completion, but these all hold different combinations of
Dave Chinner718ecc52020-08-17 16:41:01 -070028 * ILOCK and IFLUSHING and hence we need some other method of
29 * serialising updates to the flush state.
Dave Chinner1319ebe2020-06-29 14:48:46 -070030 */
31 spinlock_t ili_lock; /* flush state lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 unsigned int ili_last_fields; /* fields when flushed */
Christoph Hellwigf5d8d5c2012-02-29 09:53:54 +000033 unsigned int ili_fields; /* fields to be logged */
Dave Chinnerfc0561c2015-11-03 13:14:59 +110034 unsigned int ili_fsync_fields; /* logged since last fsync */
Dave Chinner1319ebe2020-06-29 14:48:46 -070035 xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
Dave Chinner5f9b4b02021-06-18 08:21:52 -070036 xfs_csn_t ili_commit_seq; /* last transaction commit */
Christoph Hellwigfd9cbe52020-04-30 12:52:19 -070037};
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Dave Chinneraac855a2020-06-29 14:48:48 -070039static inline int xfs_inode_clean(struct xfs_inode *ip)
David Chinner33540402008-03-06 13:43:59 +110040{
Christoph Hellwigf5d8d5c2012-02-29 09:53:54 +000041 return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL);
David Chinner33540402008-03-06 13:43:59 +110042}
43
Nathan Scotta844f452005-11-02 14:38:42 +110044extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
45extern void xfs_inode_item_destroy(struct xfs_inode *);
Brian Foster88fc1872020-05-06 13:27:40 -070046extern void xfs_iflush_abort(struct xfs_inode *);
Tim Shimmin6d192a92006-06-09 14:55:38 +100047extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
Darrick J. Wong06b11322017-10-31 12:04:24 -070048 struct xfs_inode_log_format *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Darrick J. Wong182696f2021-10-12 11:09:23 -070050extern struct kmem_cache *xfs_ili_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#endif /* __XFS_INODE_ITEM_H__ */