blob: 82404da2ca6747c010a4c666132ebede1c9c7f90 [file] [log] [blame]
Dave Chinner70a9883c2013-10-23 10:36:05 +11001/*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * Copyright (c) 2013 Red Hat, Inc.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it would be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#ifndef __XFS_SHARED_H__
20#define __XFS_SHARED_H__
21
22/*
23 * Definitions shared between kernel and userspace that don't fit into any other
24 * header file that is shared with userspace.
25 */
26struct xfs_ifork;
27struct xfs_buf;
28struct xfs_buf_ops;
29struct xfs_mount;
30struct xfs_trans;
31struct xfs_inode;
32
33/*
34 * Buffer verifier operations are widely used, including userspace tools
35 */
36extern const struct xfs_buf_ops xfs_agf_buf_ops;
37extern const struct xfs_buf_ops xfs_agi_buf_ops;
38extern const struct xfs_buf_ops xfs_agf_buf_ops;
39extern const struct xfs_buf_ops xfs_agfl_buf_ops;
40extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
41extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
42extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
43extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
44extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
45extern const struct xfs_buf_ops xfs_dquot_buf_ops;
46extern const struct xfs_buf_ops xfs_symlink_buf_ops;
47extern const struct xfs_buf_ops xfs_agi_buf_ops;
48extern const struct xfs_buf_ops xfs_inobt_buf_ops;
49extern const struct xfs_buf_ops xfs_inode_buf_ops;
50extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
51extern const struct xfs_buf_ops xfs_dquot_buf_ops;
52extern const struct xfs_buf_ops xfs_sb_buf_ops;
53extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
54extern const struct xfs_buf_ops xfs_symlink_buf_ops;
55
56/*
57 * Transaction types. Used to distinguish types of buffers. These never reach
58 * the log.
59 */
60#define XFS_TRANS_SETATTR_NOT_SIZE 1
61#define XFS_TRANS_SETATTR_SIZE 2
62#define XFS_TRANS_INACTIVE 3
63#define XFS_TRANS_CREATE 4
64#define XFS_TRANS_CREATE_TRUNC 5
65#define XFS_TRANS_TRUNCATE_FILE 6
66#define XFS_TRANS_REMOVE 7
67#define XFS_TRANS_LINK 8
68#define XFS_TRANS_RENAME 9
69#define XFS_TRANS_MKDIR 10
70#define XFS_TRANS_RMDIR 11
71#define XFS_TRANS_SYMLINK 12
72#define XFS_TRANS_SET_DMATTRS 13
73#define XFS_TRANS_GROWFS 14
74#define XFS_TRANS_STRAT_WRITE 15
75#define XFS_TRANS_DIOSTRAT 16
76/* 17 was XFS_TRANS_WRITE_SYNC */
77#define XFS_TRANS_WRITEID 18
78#define XFS_TRANS_ADDAFORK 19
79#define XFS_TRANS_ATTRINVAL 20
80#define XFS_TRANS_ATRUNCATE 21
81#define XFS_TRANS_ATTR_SET 22
82#define XFS_TRANS_ATTR_RM 23
83#define XFS_TRANS_ATTR_FLAG 24
84#define XFS_TRANS_CLEAR_AGI_BUCKET 25
85#define XFS_TRANS_QM_SBCHANGE 26
86/*
87 * Dummy entries since we use the transaction type to index into the
88 * trans_type[] in xlog_recover_print_trans_head()
89 */
90#define XFS_TRANS_DUMMY1 27
91#define XFS_TRANS_DUMMY2 28
92#define XFS_TRANS_QM_QUOTAOFF 29
93#define XFS_TRANS_QM_DQALLOC 30
94#define XFS_TRANS_QM_SETQLIM 31
95#define XFS_TRANS_QM_DQCLUSTER 32
96#define XFS_TRANS_QM_QINOCREATE 33
97#define XFS_TRANS_QM_QUOTAOFF_END 34
98#define XFS_TRANS_SB_UNIT 35
99#define XFS_TRANS_FSYNC_TS 36
100#define XFS_TRANS_GROWFSRT_ALLOC 37
101#define XFS_TRANS_GROWFSRT_ZERO 38
102#define XFS_TRANS_GROWFSRT_FREE 39
103#define XFS_TRANS_SWAPEXT 40
104#define XFS_TRANS_SB_COUNT 41
105#define XFS_TRANS_CHECKPOINT 42
106#define XFS_TRANS_ICREATE 43
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800107#define XFS_TRANS_CREATE_TMPFILE 44
108#define XFS_TRANS_TYPE_MAX 44
Dave Chinner70a9883c2013-10-23 10:36:05 +1100109/* new transaction types need to be reflected in xfs_logprint(8) */
110
111#define XFS_TRANS_TYPES \
112 { XFS_TRANS_SETATTR_NOT_SIZE, "SETATTR_NOT_SIZE" }, \
113 { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \
114 { XFS_TRANS_INACTIVE, "INACTIVE" }, \
115 { XFS_TRANS_CREATE, "CREATE" }, \
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800116 { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \
Dave Chinner70a9883c2013-10-23 10:36:05 +1100117 { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \
118 { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \
119 { XFS_TRANS_REMOVE, "REMOVE" }, \
120 { XFS_TRANS_LINK, "LINK" }, \
121 { XFS_TRANS_RENAME, "RENAME" }, \
122 { XFS_TRANS_MKDIR, "MKDIR" }, \
123 { XFS_TRANS_RMDIR, "RMDIR" }, \
124 { XFS_TRANS_SYMLINK, "SYMLINK" }, \
125 { XFS_TRANS_SET_DMATTRS, "SET_DMATTRS" }, \
126 { XFS_TRANS_GROWFS, "GROWFS" }, \
127 { XFS_TRANS_STRAT_WRITE, "STRAT_WRITE" }, \
128 { XFS_TRANS_DIOSTRAT, "DIOSTRAT" }, \
129 { XFS_TRANS_WRITEID, "WRITEID" }, \
130 { XFS_TRANS_ADDAFORK, "ADDAFORK" }, \
131 { XFS_TRANS_ATTRINVAL, "ATTRINVAL" }, \
132 { XFS_TRANS_ATRUNCATE, "ATRUNCATE" }, \
133 { XFS_TRANS_ATTR_SET, "ATTR_SET" }, \
134 { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \
135 { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \
136 { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \
137 { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \
138 { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \
139 { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \
140 { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \
141 { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \
142 { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \
143 { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \
144 { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \
145 { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \
146 { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \
147 { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \
148 { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \
149 { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \
150 { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \
151 { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \
152 { XFS_TRANS_DUMMY1, "DUMMY1" }, \
153 { XFS_TRANS_DUMMY2, "DUMMY2" }, \
154 { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" }
155
156/*
157 * This structure is used to track log items associated with
158 * a transaction. It points to the log item and keeps some
159 * flags to track the state of the log item. It also tracks
160 * the amount of space needed to log the item it describes
161 * once we get to commit processing (see xfs_trans_commit()).
162 */
163struct xfs_log_item_desc {
164 struct xfs_log_item *lid_item;
165 struct list_head lid_trans;
166 unsigned char lid_flags;
167};
168
169#define XFS_LID_DIRTY 0x1
170
171/* log size calculation functions */
172int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
173int xfs_log_calc_minimum_size(struct xfs_mount *);
174
175
176/*
177 * Values for t_flags.
178 */
179#define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
180#define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
181#define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
182#define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
183#define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
184#define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
185#define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer
186 count in superblock */
187/*
188 * Values for call flags parameter.
189 */
190#define XFS_TRANS_RELEASE_LOG_RES 0x4
191#define XFS_TRANS_ABORT 0x8
192
193/*
194 * Field values for xfs_trans_mod_sb.
195 */
196#define XFS_TRANS_SB_ICOUNT 0x00000001
197#define XFS_TRANS_SB_IFREE 0x00000002
198#define XFS_TRANS_SB_FDBLOCKS 0x00000004
199#define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
200#define XFS_TRANS_SB_FREXTENTS 0x00000010
201#define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
202#define XFS_TRANS_SB_DBLOCKS 0x00000040
203#define XFS_TRANS_SB_AGCOUNT 0x00000080
204#define XFS_TRANS_SB_IMAXPCT 0x00000100
205#define XFS_TRANS_SB_REXTSIZE 0x00000200
206#define XFS_TRANS_SB_RBMBLOCKS 0x00000400
207#define XFS_TRANS_SB_RBLOCKS 0x00000800
208#define XFS_TRANS_SB_REXTENTS 0x00001000
209#define XFS_TRANS_SB_REXTSLOG 0x00002000
210
211/*
212 * Here we centralize the specification of XFS meta-data buffer reference count
213 * values. This determines how hard the buffer cache tries to hold onto the
214 * buffer.
215 */
216#define XFS_AGF_REF 4
217#define XFS_AGI_REF 4
218#define XFS_AGFL_REF 3
219#define XFS_INO_BTREE_REF 3
220#define XFS_ALLOC_BTREE_REF 2
221#define XFS_BMAP_BTREE_REF 2
222#define XFS_DIR_BTREE_REF 2
223#define XFS_INO_REF 2
224#define XFS_ATTR_BTREE_REF 1
225#define XFS_DQUOT_REF 1
226
227/*
228 * Flags for xfs_trans_ichgtime().
229 */
230#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
231#define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
232#define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */
233
234
235/*
236 * Symlink decoding/encoding functions
237 */
238int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
239int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
240 uint32_t size, struct xfs_buf *bp);
Eric Sandeenbda65ef2014-04-14 19:05:43 +1000241bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
Dave Chinner70a9883c2013-10-23 10:36:05 +1100242 uint32_t size, struct xfs_buf *bp);
243void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
244 struct xfs_inode *ip, struct xfs_ifork *ifp);
245
246#endif /* __XFS_SHARED_H__ */