blob: 4a10a1b92ee99e3412bb5e24565c893a3dfb5141 [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
28 * ILOCK and iflock and hence we need some other method of serialising
29 * updates to the flush state.
30 */
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 */
36 xfs_lsn_t ili_last_lsn; /* lsn at last transaction */
Christoph Hellwigfd9cbe52020-04-30 12:52:19 -070037};
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
David Chinner33540402008-03-06 13:43:59 +110039static inline int xfs_inode_clean(xfs_inode_t *ip)
40{
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 *);
Christoph Hellwigca30b2a2010-06-23 18:11:15 +100046extern void xfs_iflush_done(struct xfs_buf *, struct xfs_log_item *);
47extern void xfs_istale_done(struct xfs_buf *, struct xfs_log_item *);
Brian Foster88fc1872020-05-06 13:27:40 -070048extern void xfs_iflush_abort(struct xfs_inode *);
Tim Shimmin6d192a92006-06-09 14:55:38 +100049extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
Darrick J. Wong06b11322017-10-31 12:04:24 -070050 struct xfs_inode_log_format *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Dave Chinner69432832013-08-12 20:49:23 +100052extern struct kmem_zone *xfs_ili_zone;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54#endif /* __XFS_INODE_ITEM_H__ */