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 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 */
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_format_t ili_format
; /* logged structure */
45 } xfs_inode_log_item_t
;
47 typedef struct xfs_buf_log_item
{
48 xfs_log_item_t bli_item
; /* common item structure */
49 struct xfs_buf
*bli_buf
; /* real buffer pointer */
50 unsigned int bli_flags
; /* misc flags */
51 unsigned int bli_recur
; /* recursion count */
52 xfs_buf_log_format_t bli_format
; /* in-log header */
55 #define XFS_BLI_DIRTY (1<<0)
56 #define XFS_BLI_HOLD (1<<1)
57 #define XFS_BLI_STALE (1<<2)
58 #define XFS_BLI_INODE_ALLOC_BUF (1<<3)
60 typedef struct xfs_dq_logitem
{
61 xfs_log_item_t qli_item
; /* common portion */
62 struct xfs_dquot
*qli_dquot
; /* dquot ptr */
63 xfs_lsn_t qli_flush_lsn
; /* lsn at last flush */
64 xfs_dq_logformat_t qli_format
; /* logged structure */
67 typedef struct xfs_qoff_logitem
{
68 xfs_log_item_t qql_item
; /* common portion */
69 struct xfs_qoff_logitem
*qql_start_lip
; /* qoff-start logitem, if any */
70 xfs_qoff_logformat_t qql_format
; /* logged structure */
73 typedef struct xfs_trans
{
74 unsigned int t_type
; /* transaction type */
75 unsigned int t_log_res
; /* amt of log space resvd */
76 unsigned int t_log_count
; /* count for perm log res */
77 unsigned int t_blk_res
; /* # of blocks resvd */
78 struct xfs_mount
*t_mountp
; /* ptr to fs mount struct */
79 unsigned int t_flags
; /* misc flags */
80 long t_icount_delta
; /* superblock icount change */
81 long t_ifree_delta
; /* superblock ifree change */
82 long t_fdblocks_delta
; /* superblock fdblocks chg */
83 long t_frextents_delta
; /* superblock freextents chg */
84 struct list_head t_items
; /* first log item desc chunk */
87 void xfs_trans_init(struct xfs_mount
*);
88 int xfs_trans_roll(struct xfs_trans
**, struct xfs_inode
*);
90 int libxfs_trans_alloc(struct xfs_mount
*mp
, struct xfs_trans_res
*resp
,
91 uint blocks
, uint rtextents
, uint flags
,
92 struct xfs_trans
**tpp
);
93 int libxfs_trans_alloc_empty(struct xfs_mount
*mp
, struct xfs_trans
**tpp
);
94 int libxfs_trans_commit(struct xfs_trans
*);
95 void libxfs_trans_cancel(struct xfs_trans
*);
96 struct xfs_buf
*libxfs_trans_getsb(struct xfs_trans
*, struct xfs_mount
*, int);
98 int libxfs_trans_iget(struct xfs_mount
*, struct xfs_trans
*, xfs_ino_t
,
99 uint
, uint
, struct xfs_inode
**);
100 void libxfs_trans_ijoin(struct xfs_trans
*, struct xfs_inode
*, uint
);
101 void libxfs_trans_ijoin_ref(struct xfs_trans
*, struct xfs_inode
*, int);
102 void libxfs_trans_log_inode (struct xfs_trans
*, struct xfs_inode
*,
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
*,
112 struct xfs_buf
*libxfs_trans_get_buf_map(struct xfs_trans
*tp
,
113 struct xfs_buftarg
*btp
,
114 struct xfs_buf_map
*map
, int nmaps
,
117 int libxfs_trans_read_buf_map(struct xfs_mount
*mp
, struct xfs_trans
*tp
,
118 struct xfs_buftarg
*btp
,
119 struct xfs_buf_map
*map
, int nmaps
,
120 uint flags
, struct xfs_buf
**bpp
,
121 const struct xfs_buf_ops
*ops
);
122 static inline struct xfs_buf
*
123 libxfs_trans_get_buf(
124 struct xfs_trans
*tp
,
125 struct xfs_buftarg
*btp
,
130 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
131 return libxfs_trans_get_buf_map(tp
, btp
, &map
, 1, flags
);
135 libxfs_trans_read_buf(
136 struct xfs_mount
*mp
,
137 struct xfs_trans
*tp
,
138 struct xfs_buftarg
*btp
,
142 struct xfs_buf
**bpp
,
143 const struct xfs_buf_ops
*ops
)
145 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
146 return libxfs_trans_read_buf_map(mp
, tp
, btp
, &map
, 1, flags
, bpp
, ops
);
149 void xfs_extent_free_init_defer_op(void);
150 void xfs_rmap_update_init_defer_op(void);
151 void xfs_refcount_update_init_defer_op(void);
152 void xfs_bmap_update_init_defer_op(void);
154 #endif /* __XFS_TRANS_H__ */