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 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 */
86 void xfs_trans_init(struct xfs_mount
*);
87 int xfs_trans_roll(struct xfs_trans
**, struct xfs_inode
*);
89 xfs_trans_t
*libxfs_trans_alloc(struct xfs_mount
*, int);
90 int libxfs_trans_reserve(struct xfs_trans
*, struct xfs_trans_res
*,
92 int libxfs_trans_commit(struct xfs_trans
*);
93 void libxfs_trans_cancel(struct xfs_trans
*);
94 struct xfs_buf
*libxfs_trans_getsb(struct xfs_trans
*, struct xfs_mount
*, int);
96 int libxfs_trans_iget(struct xfs_mount
*, struct xfs_trans
*, xfs_ino_t
,
97 uint
, uint
, struct xfs_inode
**);
98 void libxfs_trans_ijoin(struct xfs_trans
*, struct xfs_inode
*, uint
);
99 void libxfs_trans_ijoin_ref(struct xfs_trans
*, struct xfs_inode
*, int);
100 void libxfs_trans_log_inode (struct xfs_trans
*, struct xfs_inode
*,
103 void libxfs_trans_brelse(struct xfs_trans
*, struct xfs_buf
*);
104 void libxfs_trans_binval(struct xfs_trans
*, struct xfs_buf
*);
105 void libxfs_trans_bjoin(struct xfs_trans
*, struct xfs_buf
*);
106 void libxfs_trans_bhold(struct xfs_trans
*, struct xfs_buf
*);
107 void libxfs_trans_log_buf(struct xfs_trans
*, struct xfs_buf
*,
110 struct xfs_buf
*libxfs_trans_get_buf_map(struct xfs_trans
*tp
,
111 struct xfs_buftarg
*btp
,
112 struct xfs_buf_map
*map
, int nmaps
,
115 int libxfs_trans_read_buf_map(struct xfs_mount
*mp
, struct xfs_trans
*tp
,
116 struct xfs_buftarg
*btp
,
117 struct xfs_buf_map
*map
, int nmaps
,
118 uint flags
, struct xfs_buf
**bpp
,
119 const struct xfs_buf_ops
*ops
);
120 static inline struct xfs_buf
*
121 libxfs_trans_get_buf(
122 struct xfs_trans
*tp
,
123 struct xfs_buftarg
*btp
,
128 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
129 return libxfs_trans_get_buf_map(tp
, btp
, &map
, 1, flags
);
133 libxfs_trans_read_buf(
134 struct xfs_mount
*mp
,
135 struct xfs_trans
*tp
,
136 struct xfs_buftarg
*btp
,
140 struct xfs_buf
**bpp
,
141 const struct xfs_buf_ops
*ops
)
143 DEFINE_SINGLE_BUF_MAP(map
, blkno
, numblks
);
144 return libxfs_trans_read_buf_map(mp
, tp
, btp
, &map
, 1, flags
, bpp
, ops
);
147 #endif /* __XFS_TRANS_H__ */