]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_trans.h
xfs: make xfs_buf_read return an error code
[thirdparty/xfsprogs-dev.git] / include / xfs_trans.h
CommitLineData
959ef981 1// SPDX-License-Identifier: GPL-2.0
b626fb59
DC
2/*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
b626fb59
DC
5 */
6
7#ifndef __XFS_TRANS_H__
8#define __XFS_TRANS_H__
9
10struct xfs_mount;
11struct xfs_buftarg;
12struct xfs_buf;
13struct xfs_buf_map;
14
15/*
16 * Userspace Transaction interface
17 */
18
19typedef struct xfs_log_item {
2fdd378a
DC
20 struct list_head li_trans; /* transaction list */
21 xfs_lsn_t li_lsn; /* last on-disk lsn */
b626fb59
DC
22 struct xfs_mount *li_mountp; /* ptr to fs mount */
23 uint li_type; /* item type */
2fdd378a 24 unsigned long li_flags; /* misc flags */
b626fb59
DC
25} xfs_log_item_t;
26
2fdd378a
DC
27#define XFS_LI_DIRTY 3 /* log item dirty in transaction */
28
b626fb59
DC
29typedef struct xfs_inode_log_item {
30 xfs_log_item_t ili_item; /* common portion */
31 struct xfs_inode *ili_inode; /* inode pointer */
c0860494 32 unsigned short ili_lock_flags; /* lock flags */
b626fb59 33 unsigned int ili_last_fields; /* fields when flushed*/
5539639c
ES
34 unsigned int ili_fields; /* fields to be logged */
35 unsigned int ili_fsync_fields; /* ignored by userspace */
b626fb59
DC
36} xfs_inode_log_item_t;
37
38typedef struct xfs_buf_log_item {
39 xfs_log_item_t bli_item; /* common item structure */
40 struct xfs_buf *bli_buf; /* real buffer pointer */
41 unsigned int bli_flags; /* misc flags */
42 unsigned int bli_recur; /* recursion count */
cebe02e2 43 xfs_buf_log_format_t __bli_format; /* in-log header */
b626fb59
DC
44} xfs_buf_log_item_t;
45
46#define XFS_BLI_DIRTY (1<<0)
47#define XFS_BLI_HOLD (1<<1)
48#define XFS_BLI_STALE (1<<2)
49#define XFS_BLI_INODE_ALLOC_BUF (1<<3)
50
b626fb59
DC
51typedef struct xfs_qoff_logitem {
52 xfs_log_item_t qql_item; /* common portion */
53 struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
54 xfs_qoff_logformat_t qql_format; /* logged structure */
55} xfs_qoff_logitem_t;
56
f5f4497f
BF
57#define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */
58#define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */
59
b626fb59 60typedef struct xfs_trans {
b626fb59
DC
61 unsigned int t_log_res; /* amt of log space resvd */
62 unsigned int t_log_count; /* count for perm log res */
0268fdc3 63 unsigned int t_blk_res; /* # of blocks resvd */
255682d9 64 xfs_fsblock_t t_firstblock; /* first block allocated */
b626fb59 65 struct xfs_mount *t_mountp; /* ptr to fs mount struct */
41ab9202 66 unsigned int t_blk_res_used; /* # of resvd blocks used */
b626fb59
DC
67 unsigned int t_flags; /* misc flags */
68 long t_icount_delta; /* superblock icount change */
69 long t_ifree_delta; /* superblock ifree change */
70 long t_fdblocks_delta; /* superblock fdblocks chg */
71 long t_frextents_delta; /* superblock freextents chg */
72 struct list_head t_items; /* first log item desc chunk */
92a8736e 73 struct list_head t_dfops; /* deferred operations */
b626fb59
DC
74} xfs_trans_t;
75
76void xfs_trans_init(struct xfs_mount *);
d67406c9 77int xfs_trans_roll(struct xfs_trans **);
b626fb59 78
9074815c
CH
79int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
80 uint blocks, uint rtextents, uint flags,
81 struct xfs_trans **tpp);
225e4bb2
DW
82int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks,
83 struct xfs_trans **tpp);
3680a764 84int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp);
de5a3f46 85int libxfs_trans_commit(struct xfs_trans *);
3d7434fe 86void libxfs_trans_cancel(struct xfs_trans *);
ac0a2228
BF
87
88/* cancel dfops associated with a transaction */
89void xfs_defer_cancel(struct xfs_trans *);
90
67c4a324 91struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *);
b626fb59 92
b626fb59 93void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
b626fb59
DC
94void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *,
95 uint);
d67406c9 96int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *);
b626fb59
DC
97
98void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *);
99void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *);
100void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *);
101void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *);
9833c1a4 102void libxfs_trans_bhold_release(struct xfs_trans *, struct xfs_buf *);
59630067 103void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
b626fb59
DC
104void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *,
105 uint, uint);
38fa71a7 106bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
b626fb59
DC
107
108struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp,
109 struct xfs_buftarg *btp,
110 struct xfs_buf_map *map, int nmaps,
3a3f5b14 111 xfs_buf_flags_t flags);
b626fb59
DC
112
113int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
114 struct xfs_buftarg *btp,
115 struct xfs_buf_map *map, int nmaps,
3a3f5b14 116 xfs_buf_flags_t flags, struct xfs_buf **bpp,
b626fb59
DC
117 const struct xfs_buf_ops *ops);
118static inline struct xfs_buf *
119libxfs_trans_get_buf(
120 struct xfs_trans *tp,
121 struct xfs_buftarg *btp,
122 xfs_daddr_t blkno,
123 int numblks,
124 uint flags)
125{
126 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
127 return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags);
128}
129
130static inline int
131libxfs_trans_read_buf(
132 struct xfs_mount *mp,
133 struct xfs_trans *tp,
134 struct xfs_buftarg *btp,
135 xfs_daddr_t blkno,
136 int numblks,
3a3f5b14 137 xfs_buf_flags_t flags,
b626fb59
DC
138 struct xfs_buf **bpp,
139 const struct xfs_buf_ops *ops)
140{
141 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
142 return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
143}
144
145#endif /* __XFS_TRANS_H__ */