blob: 30114b5103325bd091682d3de7daaa24bf52758e [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 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053void xfs_buf_item_relse(struct xfs_buf *);
Brian Foster95808452018-09-29 13:45:26 +100054bool xfs_buf_item_put(struct xfs_buf_log_item *);
Carlos Maiolino70a20652018-01-24 13:38:48 -080055void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
Brian Foster6453c652017-08-29 10:08:37 -070056bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057void xfs_buf_attach_iodone(struct xfs_buf *,
Christoph Hellwigefe23302019-06-28 19:27:33 -070058 void(*)(struct xfs_buf *, struct xfs_log_item *),
59 struct xfs_log_item *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060void xfs_buf_iodone_callbacks(struct xfs_buf *);
Christoph Hellwigca30b2a2010-06-23 18:11:15 +100061void xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
Carlos Maiolinod3a304b2017-08-08 18:21:50 -070062bool xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
Carlos Maiolinod3a304b2017-08-08 18:21:50 -070063 struct list_head *);
Darrick J. Wong8a6453a2020-01-13 16:33:46 -080064bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Dave Chinnera8da0da2013-08-12 20:49:24 +100066extern kmem_zone_t *xfs_buf_item_zone;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#endif /* __XFS_BUF_ITEM_H__ */