162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
462306a36Sopenharmony_ci * All Rights Reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef	__XFS_BUF_ITEM_H__
762306a36Sopenharmony_ci#define	__XFS_BUF_ITEM_H__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* kernel only definitions */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct xfs_buf;
1262306a36Sopenharmony_cistruct xfs_mount;
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* buf log item flags */
1562306a36Sopenharmony_ci#define	XFS_BLI_HOLD		(1u << 0)
1662306a36Sopenharmony_ci#define	XFS_BLI_DIRTY		(1u << 1)
1762306a36Sopenharmony_ci#define	XFS_BLI_STALE		(1u << 2)
1862306a36Sopenharmony_ci#define	XFS_BLI_LOGGED		(1u << 3)
1962306a36Sopenharmony_ci#define	XFS_BLI_INODE_ALLOC_BUF	(1u << 4)
2062306a36Sopenharmony_ci#define XFS_BLI_STALE_INODE	(1u << 5)
2162306a36Sopenharmony_ci#define	XFS_BLI_INODE_BUF	(1u << 6)
2262306a36Sopenharmony_ci#define	XFS_BLI_ORDERED		(1u << 7)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define XFS_BLI_FLAGS \
2562306a36Sopenharmony_ci	{ XFS_BLI_HOLD,		"HOLD" }, \
2662306a36Sopenharmony_ci	{ XFS_BLI_DIRTY,	"DIRTY" }, \
2762306a36Sopenharmony_ci	{ XFS_BLI_STALE,	"STALE" }, \
2862306a36Sopenharmony_ci	{ XFS_BLI_LOGGED,	"LOGGED" }, \
2962306a36Sopenharmony_ci	{ XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
3062306a36Sopenharmony_ci	{ XFS_BLI_STALE_INODE,	"STALE_INODE" }, \
3162306a36Sopenharmony_ci	{ XFS_BLI_INODE_BUF,	"INODE_BUF" }, \
3262306a36Sopenharmony_ci	{ XFS_BLI_ORDERED,	"ORDERED" }
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/*
3562306a36Sopenharmony_ci * This is the in core log item structure used to track information
3662306a36Sopenharmony_ci * needed to log buffers.  It tracks how many times the lock has been
3762306a36Sopenharmony_ci * locked, and which 128 byte chunks of the buffer are dirty.
3862306a36Sopenharmony_ci */
3962306a36Sopenharmony_cistruct xfs_buf_log_item {
4062306a36Sopenharmony_ci	struct xfs_log_item	bli_item;	/* common item structure */
4162306a36Sopenharmony_ci	struct xfs_buf		*bli_buf;	/* real buffer pointer */
4262306a36Sopenharmony_ci	unsigned int		bli_flags;	/* misc flags */
4362306a36Sopenharmony_ci	unsigned int		bli_recur;	/* lock recursion count */
4462306a36Sopenharmony_ci	atomic_t		bli_refcount;	/* cnt of tp refs */
4562306a36Sopenharmony_ci	int			bli_format_count;	/* count of headers */
4662306a36Sopenharmony_ci	struct xfs_buf_log_format *bli_formats;	/* array of in-log header ptrs */
4762306a36Sopenharmony_ci	struct xfs_buf_log_format __bli_format;	/* embedded in-log header */
4862306a36Sopenharmony_ci};
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciint	xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
5162306a36Sopenharmony_civoid	xfs_buf_item_done(struct xfs_buf *bp);
5262306a36Sopenharmony_civoid	xfs_buf_item_relse(struct xfs_buf *);
5362306a36Sopenharmony_cibool	xfs_buf_item_put(struct xfs_buf_log_item *);
5462306a36Sopenharmony_civoid	xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
5562306a36Sopenharmony_cibool	xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
5662306a36Sopenharmony_civoid	xfs_buf_inode_iodone(struct xfs_buf *);
5762306a36Sopenharmony_civoid	xfs_buf_inode_io_fail(struct xfs_buf *bp);
5862306a36Sopenharmony_ci#ifdef CONFIG_XFS_QUOTA
5962306a36Sopenharmony_civoid	xfs_buf_dquot_iodone(struct xfs_buf *);
6062306a36Sopenharmony_civoid	xfs_buf_dquot_io_fail(struct xfs_buf *bp);
6162306a36Sopenharmony_ci#else
6262306a36Sopenharmony_cistatic inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
6362306a36Sopenharmony_ci{
6462306a36Sopenharmony_ci}
6562306a36Sopenharmony_cistatic inline void xfs_buf_dquot_io_fail(struct xfs_buf *bp)
6662306a36Sopenharmony_ci{
6762306a36Sopenharmony_ci}
6862306a36Sopenharmony_ci#endif /* CONFIG_XFS_QUOTA */
6962306a36Sopenharmony_civoid	xfs_buf_iodone(struct xfs_buf *);
7062306a36Sopenharmony_cibool	xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciextern struct kmem_cache	*xfs_buf_item_cache;
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#endif	/* __XFS_BUF_ITEM_H__ */
75