Merge branch 'linux-4.7' of git://github.com/skeggsb/linux into drm-fixes
[linux-2.6-block.git] / fs / xfs / libxfs / xfs_shared.h
1 /*
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  */
26 struct xfs_ifork;
27 struct xfs_buf;
28 struct xfs_buf_ops;
29 struct xfs_mount;
30 struct xfs_trans;
31 struct xfs_inode;
32
33 /*
34  * Buffer verifier operations are widely used, including userspace tools
35  */
36 extern const struct xfs_buf_ops xfs_agf_buf_ops;
37 extern const struct xfs_buf_ops xfs_agi_buf_ops;
38 extern const struct xfs_buf_ops xfs_agf_buf_ops;
39 extern const struct xfs_buf_ops xfs_agfl_buf_ops;
40 extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
41 extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
42 extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
43 extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
44 extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
45 extern const struct xfs_buf_ops xfs_dquot_buf_ops;
46 extern const struct xfs_buf_ops xfs_symlink_buf_ops;
47 extern const struct xfs_buf_ops xfs_agi_buf_ops;
48 extern const struct xfs_buf_ops xfs_inobt_buf_ops;
49 extern const struct xfs_buf_ops xfs_inode_buf_ops;
50 extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
51 extern const struct xfs_buf_ops xfs_dquot_buf_ops;
52 extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
53 extern const struct xfs_buf_ops xfs_sb_buf_ops;
54 extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
55 extern const struct xfs_buf_ops xfs_symlink_buf_ops;
56 extern const struct xfs_buf_ops xfs_rtbuf_ops;
57
58 /*
59  * This structure is used to track log items associated with
60  * a transaction.  It points to the log item and keeps some
61  * flags to track the state of the log item.  It also tracks
62  * the amount of space needed to log the item it describes
63  * once we get to commit processing (see xfs_trans_commit()).
64  */
65 struct xfs_log_item_desc {
66         struct xfs_log_item     *lid_item;
67         struct list_head        lid_trans;
68         unsigned char           lid_flags;
69 };
70
71 #define XFS_LID_DIRTY           0x1
72
73 /* log size calculation functions */
74 int     xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
75 int     xfs_log_calc_minimum_size(struct xfs_mount *);
76
77
78 /*
79  * Values for t_flags.
80  */
81 #define XFS_TRANS_DIRTY         0x01    /* something needs to be logged */
82 #define XFS_TRANS_SB_DIRTY      0x02    /* superblock is modified */
83 #define XFS_TRANS_PERM_LOG_RES  0x04    /* xact took a permanent log res */
84 #define XFS_TRANS_SYNC          0x08    /* make commit synchronous */
85 #define XFS_TRANS_DQ_DIRTY      0x10    /* at least one dquot in trx dirty */
86 #define XFS_TRANS_RESERVE       0x20    /* OK to use reserved data blocks */
87 #define XFS_TRANS_NO_WRITECOUNT 0x40    /* do not elevate SB writecount */
88 #define XFS_TRANS_NOFS          0x80    /* pass KM_NOFS to kmem_alloc */
89
90 /*
91  * Field values for xfs_trans_mod_sb.
92  */
93 #define XFS_TRANS_SB_ICOUNT             0x00000001
94 #define XFS_TRANS_SB_IFREE              0x00000002
95 #define XFS_TRANS_SB_FDBLOCKS           0x00000004
96 #define XFS_TRANS_SB_RES_FDBLOCKS       0x00000008
97 #define XFS_TRANS_SB_FREXTENTS          0x00000010
98 #define XFS_TRANS_SB_RES_FREXTENTS      0x00000020
99 #define XFS_TRANS_SB_DBLOCKS            0x00000040
100 #define XFS_TRANS_SB_AGCOUNT            0x00000080
101 #define XFS_TRANS_SB_IMAXPCT            0x00000100
102 #define XFS_TRANS_SB_REXTSIZE           0x00000200
103 #define XFS_TRANS_SB_RBMBLOCKS          0x00000400
104 #define XFS_TRANS_SB_RBLOCKS            0x00000800
105 #define XFS_TRANS_SB_REXTENTS           0x00001000
106 #define XFS_TRANS_SB_REXTSLOG           0x00002000
107
108 /*
109  * Here we centralize the specification of XFS meta-data buffer reference count
110  * values.  This determines how hard the buffer cache tries to hold onto the
111  * buffer.
112  */
113 #define XFS_AGF_REF             4
114 #define XFS_AGI_REF             4
115 #define XFS_AGFL_REF            3
116 #define XFS_INO_BTREE_REF       3
117 #define XFS_ALLOC_BTREE_REF     2
118 #define XFS_BMAP_BTREE_REF      2
119 #define XFS_DIR_BTREE_REF       2
120 #define XFS_INO_REF             2
121 #define XFS_ATTR_BTREE_REF      1
122 #define XFS_DQUOT_REF           1
123
124 /*
125  * Flags for xfs_trans_ichgtime().
126  */
127 #define XFS_ICHGTIME_MOD        0x1     /* data fork modification timestamp */
128 #define XFS_ICHGTIME_CHG        0x2     /* inode field change timestamp */
129 #define XFS_ICHGTIME_CREATE     0x4     /* inode create timestamp */
130
131
132 /*
133  * Symlink decoding/encoding functions
134  */
135 int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
136 int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
137                         uint32_t size, struct xfs_buf *bp);
138 bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
139                         uint32_t size, struct xfs_buf *bp);
140 void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
141                                  struct xfs_inode *ip, struct xfs_ifork *ifp);
142
143 #endif /* __XFS_SHARED_H__ */