blob: e11e9ef2338f7e300a30e9e40da7d1dbde14bc39 [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-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef __XFS_BUF_ITEM_H__
7#define __XFS_BUF_ITEM_H__
8
Dave Chinnera8da0da2013-08-12 20:49:24 +10009/* kernel only definitions */
David Chinnera8272ce2007-11-23 16:28:09 +110010
Dave Chinnera8da0da2013-08-12 20:49:24 +100011/* buf log item flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#define XFS_BLI_HOLD 0x01
13#define XFS_BLI_DIRTY 0x02
14#define XFS_BLI_STALE 0x04
15#define XFS_BLI_LOGGED 0x08
16#define XFS_BLI_INODE_ALLOC_BUF 0x10
17#define XFS_BLI_STALE_INODE 0x20
Dave Chinnerccf7c232010-05-20 23:19:42 +100018#define XFS_BLI_INODE_BUF 0x40
Dave Chinner5f6bed72013-06-27 16:04:52 +100019#define XFS_BLI_ORDERED 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Christoph Hellwig0b1b2132009-12-14 23:14:59 +000021#define XFS_BLI_FLAGS \
22 { XFS_BLI_HOLD, "HOLD" }, \
23 { XFS_BLI_DIRTY, "DIRTY" }, \
24 { XFS_BLI_STALE, "STALE" }, \
25 { XFS_BLI_LOGGED, "LOGGED" }, \
26 { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
Dave Chinnerccf7c232010-05-20 23:19:42 +100027 { XFS_BLI_STALE_INODE, "STALE_INODE" }, \
Dave Chinner5f6bed72013-06-27 16:04:52 +100028 { XFS_BLI_INODE_BUF, "INODE_BUF" }, \
29 { XFS_BLI_ORDERED, "ORDERED" }
Christoph Hellwig0b1b2132009-12-14 23:14:59 +000030
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Linus Torvalds1da177e2005-04-16 15:20:36 -070032struct xfs_buf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033struct xfs_mount;
34struct xfs_buf_log_item;
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/*
37 * This is the in core log item structure used to track information
38 * needed to log buffers. It tracks how many times the lock has been
39 * locked, and which 128 byte chunks of the buffer are dirty.
40 */
Carlos Maiolino70a20652018-01-24 13:38:48 -080041struct xfs_buf_log_item {
Christoph Hellwigefe23302019-06-28 19:27:33 -070042 struct xfs_log_item bli_item; /* common item structure */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 struct xfs_buf *bli_buf; /* real buffer pointer */
44 unsigned int bli_flags; /* misc flags */
45 unsigned int bli_recur; /* lock recursion count */
46 atomic_t bli_refcount; /* cnt of tp refs */
Dave Chinner372cc85e2012-06-22 18:50:12 +100047 int bli_format_count; /* count of headers */
48 struct xfs_buf_log_format *bli_formats; /* array of in-log header ptrs */
Mark Tinguelyb9438172012-12-04 17:18:03 -060049 struct xfs_buf_log_format __bli_format; /* embedded in-log header */
Carlos Maiolino70a20652018-01-24 13:38:48 -080050};
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Dave Chinnerf79af0b2015-08-25 10:05:13 +100052int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
Christoph Hellwig664ffb82020-09-01 10:55:29 -070053void xfs_buf_item_done(struct xfs_buf *bp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054void xfs_buf_item_relse(struct xfs_buf *);
Brian Foster95808452018-09-29 13:45:26 +100055bool xfs_buf_item_put(struct xfs_buf_log_item *);
Carlos Maiolino70a20652018-01-24 13:38:48 -080056void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
Brian Foster6453c652017-08-29 10:08:37 -070057bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
Dave Chinnerf593bf12020-06-29 14:48:46 -070058void xfs_buf_inode_iodone(struct xfs_buf *);
Christoph Hellwig664ffb82020-09-01 10:55:29 -070059void xfs_buf_inode_io_fail(struct xfs_buf *bp);
60#ifdef CONFIG_XFS_QUOTA
Dave Chinner0c7e5af2020-06-29 14:48:46 -070061void xfs_buf_dquot_iodone(struct xfs_buf *);
Christoph Hellwig664ffb82020-09-01 10:55:29 -070062void xfs_buf_dquot_io_fail(struct xfs_buf *bp);
63#else
64static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
65{
66}
67static inline void xfs_buf_dquot_io_fail(struct xfs_buf *bp)
68{
69}
70#endif /* CONFIG_XFS_QUOTA */
Dave Chinnerb01d1462020-06-29 14:48:47 -070071void xfs_buf_iodone(struct xfs_buf *);
Darrick J. Wong8a6453a2020-01-13 16:33:46 -080072bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Darrick J. Wong182696f2021-10-12 11:09:23 -070074extern struct kmem_cache *xfs_buf_item_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76#endif /* __XFS_BUF_ITEM_H__ */