2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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.
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.
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
19 #ifndef __XFS_TRANS_H__
20 #define __XFS_TRANS_H__
28 * Userspace Transaction interface
31 typedef struct xfs_log_item
{
32 struct list_head li_trans
; /* transaction list */
33 xfs_lsn_t li_lsn
; /* last on-disk lsn */
34 struct xfs_mount
*li_mountp
; /* ptr to fs mount */
35 uint li_type
; /* item type */
36 unsigned long li_flags
; /* misc flags */
39 #define XFS_LI_DIRTY 3 /* log item dirty in transaction */
41 typedef struct xfs_inode_log_item
{
42 xfs_log_item_t ili_item
; /* common portion */
43 struct xfs_inode
*ili_inode
; /* inode pointer */
44 unsigned short ili_flags
; /* misc flags */
45 unsigned int ili_fields
; /* fields to be logged */
46 unsigned int ili_last_fields
; /* fields when flushed*/
47 } xfs_inode_log_item_t
;
49 typedef struct xfs_buf_log_item
{
50 xfs_log_item_t bli_item
; /* common item structure */
51 struct xfs_buf
*bli_buf
; /* real buffer pointer */
52 unsigned int bli_flags
; /* misc flags */
53 unsigned int bli_recur
; /* recursion count */
54 xfs_buf_log_format_t bli_format
; /* in-log header */
57 #define XFS_BLI_DIRTY (1<<0)
58 #define XFS_BLI_HOLD (1<<1)
59 #define XFS_BLI_STALE (1<<2)
60 #define XFS_BLI_INODE_ALLOC_BUF (1<<3)
62 typedef struct xfs_dq_logitem
{
63 xfs_log_item_t qli_item
; /* common portion */
64 struct xfs_dquot
*qli_dquot
; /* dquot ptr */
65 xfs_lsn_t qli_flush_lsn
; /* lsn at last flush */
66 xfs_dq_logformat_t qli_format
; /* logged structure */
69 typedef struct xfs_qoff_logitem
{
70 xfs_log_item_t qql_item
; /* common portion */
71 struct xfs_qoff_logitem
*qql_start_lip
; /* qoff-start logitem, if any */
72 xfs_qoff_logformat_t qql_format
; /* logged structure */
75 typedef struct xfs_trans
{
76 unsigned int t_type
; /* transaction type */
77 unsigned int t_log_res
; /* amt of log space resvd */
78 unsigned int t_log_count
; /* count for perm log res */
79 unsigned int t_blk_res
; /* # of blocks resvd */
80 struct xfs_mount
*t_mountp
; /* ptr to fs mount struct */
81 unsigned int t_flags
; /* misc flags */
82 long t_icount_delta
; /* superblock icount change */
83 long t_ifree_delta
; /* superblock ifree change */
84 long t_fdblocks_delta
; /* superblock fdblocks chg */
85 long t_frextents_delta
; /* superblock freextents chg */
86 struct list_head t_items
; /* first log item desc chunk */
87 struct xfs_defer_ops
*t_agfl_dfops
; /* optional agfl fixup dfops */
91 void xfs_trans_init(struct xfs_mount
*);
92 int xfs_trans_roll(struct xfs_trans
**);
94 int libxfs_trans_alloc(struct xfs_mount
*mp
, struct xfs_trans_res
*resp
,
95 uint blocks
, uint rtextents
, uint flags
,
96 struct xfs_trans
**tpp
);
97 int libxfs_trans_alloc_empty(struct xfs_mount
*mp
, struct xfs_trans
**tpp
);
98 int libxfs_trans_commit(struct xfs_trans
*);
99 void libxfs_trans_cancel(struct xfs_trans
*);
100 struct xfs_buf
*libxfs_trans_getsb(struct xfs_trans
*, struct xfs_mount
*, int);
102 int libxfs_trans_iget(struct xfs_mount
*, struct xfs_trans
*, xfs_ino_t
,
103 uint
, uint
, struct xfs_inode
**);
104 void libxfs_trans_ijoin(struct xfs_trans
*, struct xfs_inode
*, uint
);
105 void libxfs_trans_ijoin_ref(struct xfs_trans
*, struct xfs_inode
*, int);
106 void libxfs_trans_log_inode (struct xfs_trans
*, struct xfs_inode
*,
108 int libxfs_trans_roll_inode (struct xfs_trans
**, struct xfs_inode
*);
110 void libxfs_trans_brelse(struct xfs_trans
*, struct xfs_buf
*);
111 void libxfs_trans_binval(struct xfs_trans
*, struct xfs_buf
*);
112 void libxfs_trans_bjoin(struct xfs_trans
*, struct xfs_buf
*);
113 void libxfs_trans_bhold(struct xfs_trans
*, struct xfs_buf
*);
114 void libxfs_trans_dirty_buf(struct xfs_trans
*, struct xfs_buf
*);
115 void libxfs_trans_log_buf(struct xfs_trans
*, struct xfs_buf
*,
117 bool libxfs_trans_ordered_buf(xfs_trans_t
*, struct xfs_buf
*);
119 struct xfs_buf
*libxfs_trans_get_buf_map(struct xfs_trans
*tp
,
120 struct xfs_buftarg
*btp
,
121 struct xfs_buf_map
*map
, int nmaps
,
124 int libxfs_trans_read_buf_map(struct xfs_mount
*mp
, struct xfs_trans
*tp
,
125 struct xfs_buftarg
*btp
,
126 struct xfs_buf_map
*map
, int nmaps
,
127 uint flags
, struct xfs_buf
**bpp
,
128 const struct xfs_buf_ops
*ops
);
129 static inline struct xfs_buf
*
130 libxfs_trans_get_buf(
131 struct xfs_trans
*tp
,
132 struct xfs_buftarg
*btp
,
137 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
138 return libxfs_trans_get_buf_map(tp
, btp
, &map
, 1, flags
);
142 libxfs_trans_read_buf(
143 struct xfs_mount
*mp
,
144 struct xfs_trans
*tp
,
145 struct xfs_buftarg
*btp
,
149 struct xfs_buf
**bpp
,
150 const struct xfs_buf_ops
*ops
)
152 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
153 return libxfs_trans_read_buf_map(mp
, tp
, btp
, &map
, 1, flags
, bpp
, ops
);
156 void xfs_extent_free_init_defer_op(void);
157 void xfs_rmap_update_init_defer_op(void);
158 void xfs_refcount_update_init_defer_op(void);
159 void xfs_bmap_update_init_defer_op(void);
161 #endif /* __XFS_TRANS_H__ */