1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __XFS_INODE_FORK_H__
19#define __XFS_INODE_FORK_H__
20
21struct xfs_inode_log_item;
22struct xfs_dinode;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43typedef struct xfs_ext_irec {
44 xfs_bmbt_rec_host_t *er_extbuf;
45 xfs_extnum_t er_extoff;
46 xfs_extnum_t er_extcount;
47} xfs_ext_irec_t;
48
49
50
51
52#define XFS_IEXT_BUFSZ 4096
53#define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t))
54#define XFS_INLINE_EXTS 2
55#define XFS_INLINE_DATA 32
56typedef struct xfs_ifork {
57 int if_bytes;
58 int if_real_bytes;
59 struct xfs_btree_block *if_broot;
60 short if_broot_bytes;
61 unsigned char if_flags;
62 union {
63 xfs_bmbt_rec_host_t *if_extents;
64 xfs_ext_irec_t *if_ext_irec;
65 char *if_data;
66 } if_u1;
67 union {
68 xfs_bmbt_rec_host_t if_inline_ext[XFS_INLINE_EXTS];
69
70 char if_inline_data[XFS_INLINE_DATA];
71
72 xfs_dev_t if_rdev;
73 uuid_t if_uuid;
74 } if_u2;
75} xfs_ifork_t;
76
77
78
79
80#define XFS_IFINLINE 0x01
81#define XFS_IFEXTENTS 0x02
82#define XFS_IFBROOT 0x04
83#define XFS_IFEXTIREC 0x08
84
85
86
87
88
89#define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0)
90#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3))
91
92#define XFS_IFORK_PTR(ip,w) \
93 ((w) == XFS_DATA_FORK ? \
94 &(ip)->i_df : \
95 (ip)->i_afp)
96#define XFS_IFORK_DSIZE(ip) \
97 (XFS_IFORK_Q(ip) ? \
98 XFS_IFORK_BOFF(ip) : \
99 XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version))
100#define XFS_IFORK_ASIZE(ip) \
101 (XFS_IFORK_Q(ip) ? \
102 XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version) - \
103 XFS_IFORK_BOFF(ip) : \
104 0)
105#define XFS_IFORK_SIZE(ip,w) \
106 ((w) == XFS_DATA_FORK ? \
107 XFS_IFORK_DSIZE(ip) : \
108 XFS_IFORK_ASIZE(ip))
109#define XFS_IFORK_FORMAT(ip,w) \
110 ((w) == XFS_DATA_FORK ? \
111 (ip)->i_d.di_format : \
112 (ip)->i_d.di_aformat)
113#define XFS_IFORK_FMT_SET(ip,w,n) \
114 ((w) == XFS_DATA_FORK ? \
115 ((ip)->i_d.di_format = (n)) : \
116 ((ip)->i_d.di_aformat = (n)))
117#define XFS_IFORK_NEXTENTS(ip,w) \
118 ((w) == XFS_DATA_FORK ? \
119 (ip)->i_d.di_nextents : \
120 (ip)->i_d.di_anextents)
121#define XFS_IFORK_NEXT_SET(ip,w,n) \
122 ((w) == XFS_DATA_FORK ? \
123 ((ip)->i_d.di_nextents = (n)) : \
124 ((ip)->i_d.di_anextents = (n)))
125#define XFS_IFORK_MAXEXT(ip, w) \
126 (XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t))
127
128int xfs_iformat_fork(struct xfs_inode *, struct xfs_dinode *);
129void xfs_iflush_fork(struct xfs_inode *, struct xfs_dinode *,
130 struct xfs_inode_log_item *, int);
131void xfs_idestroy_fork(struct xfs_inode *, int);
132void xfs_idata_realloc(struct xfs_inode *, int, int);
133void xfs_iroot_realloc(struct xfs_inode *, int, int);
134int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
135int xfs_iextents_copy(struct xfs_inode *, struct xfs_bmbt_rec *,
136 int);
137
138struct xfs_bmbt_rec_host *
139 xfs_iext_get_ext(struct xfs_ifork *, xfs_extnum_t);
140void xfs_iext_insert(struct xfs_inode *, xfs_extnum_t, xfs_extnum_t,
141 struct xfs_bmbt_irec *, int);
142void xfs_iext_add(struct xfs_ifork *, xfs_extnum_t, int);
143void xfs_iext_add_indirect_multi(struct xfs_ifork *, int,
144 xfs_extnum_t, int);
145void xfs_iext_remove(struct xfs_inode *, xfs_extnum_t, int, int);
146void xfs_iext_remove_inline(struct xfs_ifork *, xfs_extnum_t, int);
147void xfs_iext_remove_direct(struct xfs_ifork *, xfs_extnum_t, int);
148void xfs_iext_remove_indirect(struct xfs_ifork *, xfs_extnum_t, int);
149void xfs_iext_realloc_direct(struct xfs_ifork *, int);
150void xfs_iext_direct_to_inline(struct xfs_ifork *, xfs_extnum_t);
151void xfs_iext_inline_to_direct(struct xfs_ifork *, int);
152void xfs_iext_destroy(struct xfs_ifork *);
153struct xfs_bmbt_rec_host *
154 xfs_iext_bno_to_ext(struct xfs_ifork *, xfs_fileoff_t, int *);
155struct xfs_ext_irec *
156 xfs_iext_bno_to_irec(struct xfs_ifork *, xfs_fileoff_t, int *);
157struct xfs_ext_irec *
158 xfs_iext_idx_to_irec(struct xfs_ifork *, xfs_extnum_t *, int *,
159 int);
160void xfs_iext_irec_init(struct xfs_ifork *);
161struct xfs_ext_irec *
162 xfs_iext_irec_new(struct xfs_ifork *, int);
163void xfs_iext_irec_remove(struct xfs_ifork *, int);
164void xfs_iext_irec_compact(struct xfs_ifork *);
165void xfs_iext_irec_compact_pages(struct xfs_ifork *);
166void xfs_iext_irec_compact_full(struct xfs_ifork *);
167void xfs_iext_irec_update_extoffs(struct xfs_ifork *, int, int);
168
169extern struct kmem_zone *xfs_ifork_zone;
170
171#endif
172