]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_trans.h
xfs: remove "no-allocation" reservations for file creations
[thirdparty/xfsprogs-dev.git] / include / xfs_trans.h
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef __XFS_TRANS_H__
20 #define __XFS_TRANS_H__
21
22 struct xfs_mount;
23 struct xfs_buftarg;
24 struct xfs_buf;
25 struct xfs_buf_map;
26
27 /*
28 * Userspace Transaction interface
29 */
30
31 typedef struct xfs_log_item {
32 struct xfs_log_item_desc *li_desc; /* ptr to current desc*/
33 struct xfs_mount *li_mountp; /* ptr to fs mount */
34 uint li_type; /* item type */
35 xfs_lsn_t li_lsn;
36 } xfs_log_item_t;
37
38 typedef struct xfs_inode_log_item {
39 xfs_log_item_t ili_item; /* common portion */
40 struct xfs_inode *ili_inode; /* inode pointer */
41 unsigned short ili_flags; /* misc flags */
42 unsigned int ili_fields; /* fields to be logged */
43 unsigned int ili_last_fields; /* fields when flushed*/
44 } xfs_inode_log_item_t;
45
46 typedef struct xfs_buf_log_item {
47 xfs_log_item_t bli_item; /* common item structure */
48 struct xfs_buf *bli_buf; /* real buffer pointer */
49 unsigned int bli_flags; /* misc flags */
50 unsigned int bli_recur; /* recursion count */
51 xfs_buf_log_format_t bli_format; /* in-log header */
52 } xfs_buf_log_item_t;
53
54 #define XFS_BLI_DIRTY (1<<0)
55 #define XFS_BLI_HOLD (1<<1)
56 #define XFS_BLI_STALE (1<<2)
57 #define XFS_BLI_INODE_ALLOC_BUF (1<<3)
58
59 typedef struct xfs_dq_logitem {
60 xfs_log_item_t qli_item; /* common portion */
61 struct xfs_dquot *qli_dquot; /* dquot ptr */
62 xfs_lsn_t qli_flush_lsn; /* lsn at last flush */
63 xfs_dq_logformat_t qli_format; /* logged structure */
64 } xfs_dq_logitem_t;
65
66 typedef struct xfs_qoff_logitem {
67 xfs_log_item_t qql_item; /* common portion */
68 struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
69 xfs_qoff_logformat_t qql_format; /* logged structure */
70 } xfs_qoff_logitem_t;
71
72 typedef struct xfs_trans {
73 unsigned int t_type; /* transaction type */
74 unsigned int t_log_res; /* amt of log space resvd */
75 unsigned int t_log_count; /* count for perm log res */
76 unsigned int t_blk_res; /* # of blocks resvd */
77 struct xfs_mount *t_mountp; /* ptr to fs mount struct */
78 unsigned int t_flags; /* misc flags */
79 long t_icount_delta; /* superblock icount change */
80 long t_ifree_delta; /* superblock ifree change */
81 long t_fdblocks_delta; /* superblock fdblocks chg */
82 long t_frextents_delta; /* superblock freextents chg */
83 struct list_head t_items; /* first log item desc chunk */
84 } xfs_trans_t;
85
86 void xfs_trans_init(struct xfs_mount *);
87 int xfs_trans_roll(struct xfs_trans **);
88
89 int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
90 uint blocks, uint rtextents, uint flags,
91 struct xfs_trans **tpp);
92 int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp);
93 int libxfs_trans_commit(struct xfs_trans *);
94 void libxfs_trans_cancel(struct xfs_trans *);
95 struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int);
96
97 int libxfs_trans_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
98 uint, uint, struct xfs_inode **);
99 void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint);
100 void libxfs_trans_ijoin_ref(struct xfs_trans *, struct xfs_inode *, int);
101 void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *,
102 uint);
103 int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *);
104
105 void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *);
106 void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *);
107 void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *);
108 void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *);
109 void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *,
110 uint, uint);
111 bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
112
113 struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp,
114 struct xfs_buftarg *btp,
115 struct xfs_buf_map *map, int nmaps,
116 uint flags);
117
118 int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
119 struct xfs_buftarg *btp,
120 struct xfs_buf_map *map, int nmaps,
121 uint flags, struct xfs_buf **bpp,
122 const struct xfs_buf_ops *ops);
123 static inline struct xfs_buf *
124 libxfs_trans_get_buf(
125 struct xfs_trans *tp,
126 struct xfs_buftarg *btp,
127 xfs_daddr_t blkno,
128 int numblks,
129 uint flags)
130 {
131 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
132 return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags);
133 }
134
135 static inline int
136 libxfs_trans_read_buf(
137 struct xfs_mount *mp,
138 struct xfs_trans *tp,
139 struct xfs_buftarg *btp,
140 xfs_daddr_t blkno,
141 int numblks,
142 uint flags,
143 struct xfs_buf **bpp,
144 const struct xfs_buf_ops *ops)
145 {
146 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
147 return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops);
148 }
149
150 void xfs_extent_free_init_defer_op(void);
151 void xfs_rmap_update_init_defer_op(void);
152 void xfs_refcount_update_init_defer_op(void);
153 void xfs_bmap_update_init_defer_op(void);
154
155 #endif /* __XFS_TRANS_H__ */