.. | .. |
---|
13 | 13 | * File incore extent information, present for each of data & attr forks. |
---|
14 | 14 | */ |
---|
15 | 15 | struct xfs_ifork { |
---|
16 | | - int if_bytes; /* bytes in if_u1 */ |
---|
17 | | - unsigned int if_seq; /* cow fork mod counter */ |
---|
| 16 | + int64_t if_bytes; /* bytes in if_u1 */ |
---|
18 | 17 | struct xfs_btree_block *if_broot; /* file's incore btree root */ |
---|
19 | | - short if_broot_bytes; /* bytes allocated for root */ |
---|
20 | | - unsigned char if_flags; /* per-fork flags */ |
---|
| 18 | + unsigned int if_seq; /* fork mod counter */ |
---|
21 | 19 | int if_height; /* height of the extent tree */ |
---|
22 | 20 | union { |
---|
23 | 21 | void *if_root; /* extent tree root */ |
---|
24 | 22 | char *if_data; /* inline file data */ |
---|
25 | 23 | } if_u1; |
---|
| 24 | + short if_broot_bytes; /* bytes allocated for root */ |
---|
| 25 | + unsigned char if_flags; /* per-fork flags */ |
---|
| 26 | + int8_t if_format; /* format of this fork */ |
---|
| 27 | + xfs_extnum_t if_nextents; /* # of extents in this fork */ |
---|
26 | 28 | }; |
---|
27 | 29 | |
---|
28 | 30 | /* |
---|
.. | .. |
---|
46 | 48 | (ip)->i_afp : \ |
---|
47 | 49 | (ip)->i_cowfp)) |
---|
48 | 50 | #define XFS_IFORK_DSIZE(ip) \ |
---|
49 | | - (XFS_IFORK_Q(ip) ? \ |
---|
50 | | - XFS_IFORK_BOFF(ip) : \ |
---|
51 | | - XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version)) |
---|
| 51 | + (XFS_IFORK_Q(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount)) |
---|
52 | 52 | #define XFS_IFORK_ASIZE(ip) \ |
---|
53 | | - (XFS_IFORK_Q(ip) ? \ |
---|
54 | | - XFS_LITINO((ip)->i_mount, (ip)->i_d.di_version) - \ |
---|
55 | | - XFS_IFORK_BOFF(ip) : \ |
---|
56 | | - 0) |
---|
| 53 | + (XFS_IFORK_Q(ip) ? XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : 0) |
---|
57 | 54 | #define XFS_IFORK_SIZE(ip,w) \ |
---|
58 | 55 | ((w) == XFS_DATA_FORK ? \ |
---|
59 | 56 | XFS_IFORK_DSIZE(ip) : \ |
---|
60 | 57 | ((w) == XFS_ATTR_FORK ? \ |
---|
61 | 58 | XFS_IFORK_ASIZE(ip) : \ |
---|
62 | 59 | 0)) |
---|
63 | | -#define XFS_IFORK_FORMAT(ip,w) \ |
---|
64 | | - ((w) == XFS_DATA_FORK ? \ |
---|
65 | | - (ip)->i_d.di_format : \ |
---|
66 | | - ((w) == XFS_ATTR_FORK ? \ |
---|
67 | | - (ip)->i_d.di_aformat : \ |
---|
68 | | - (ip)->i_cformat)) |
---|
69 | | -#define XFS_IFORK_FMT_SET(ip,w,n) \ |
---|
70 | | - ((w) == XFS_DATA_FORK ? \ |
---|
71 | | - ((ip)->i_d.di_format = (n)) : \ |
---|
72 | | - ((w) == XFS_ATTR_FORK ? \ |
---|
73 | | - ((ip)->i_d.di_aformat = (n)) : \ |
---|
74 | | - ((ip)->i_cformat = (n)))) |
---|
75 | | -#define XFS_IFORK_NEXTENTS(ip,w) \ |
---|
76 | | - ((w) == XFS_DATA_FORK ? \ |
---|
77 | | - (ip)->i_d.di_nextents : \ |
---|
78 | | - ((w) == XFS_ATTR_FORK ? \ |
---|
79 | | - (ip)->i_d.di_anextents : \ |
---|
80 | | - (ip)->i_cnextents)) |
---|
81 | | -#define XFS_IFORK_NEXT_SET(ip,w,n) \ |
---|
82 | | - ((w) == XFS_DATA_FORK ? \ |
---|
83 | | - ((ip)->i_d.di_nextents = (n)) : \ |
---|
84 | | - ((w) == XFS_ATTR_FORK ? \ |
---|
85 | | - ((ip)->i_d.di_anextents = (n)) : \ |
---|
86 | | - ((ip)->i_cnextents = (n)))) |
---|
87 | 60 | #define XFS_IFORK_MAXEXT(ip, w) \ |
---|
88 | 61 | (XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t)) |
---|
89 | 62 | |
---|
| 63 | +static inline bool xfs_ifork_has_extents(struct xfs_ifork *ifp) |
---|
| 64 | +{ |
---|
| 65 | + return ifp->if_format == XFS_DINODE_FMT_EXTENTS || |
---|
| 66 | + ifp->if_format == XFS_DINODE_FMT_BTREE; |
---|
| 67 | +} |
---|
| 68 | + |
---|
| 69 | +static inline xfs_extnum_t xfs_ifork_nextents(struct xfs_ifork *ifp) |
---|
| 70 | +{ |
---|
| 71 | + if (!ifp) |
---|
| 72 | + return 0; |
---|
| 73 | + return ifp->if_nextents; |
---|
| 74 | +} |
---|
| 75 | + |
---|
| 76 | +static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) |
---|
| 77 | +{ |
---|
| 78 | + if (!ifp) |
---|
| 79 | + return XFS_DINODE_FMT_EXTENTS; |
---|
| 80 | + return ifp->if_format; |
---|
| 81 | +} |
---|
| 82 | + |
---|
90 | 83 | struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); |
---|
91 | 84 | |
---|
92 | | -int xfs_iformat_fork(struct xfs_inode *, struct xfs_dinode *); |
---|
| 85 | +int xfs_iformat_data_fork(struct xfs_inode *, struct xfs_dinode *); |
---|
| 86 | +int xfs_iformat_attr_fork(struct xfs_inode *, struct xfs_dinode *); |
---|
93 | 87 | void xfs_iflush_fork(struct xfs_inode *, struct xfs_dinode *, |
---|
94 | 88 | struct xfs_inode_log_item *, int); |
---|
95 | | -void xfs_idestroy_fork(struct xfs_inode *, int); |
---|
96 | | -void xfs_idata_realloc(struct xfs_inode *, int, int); |
---|
| 89 | +void xfs_idestroy_fork(struct xfs_ifork *ifp); |
---|
| 90 | +void xfs_idata_realloc(struct xfs_inode *ip, int64_t byte_diff, |
---|
| 91 | + int whichfork); |
---|
97 | 92 | void xfs_iroot_realloc(struct xfs_inode *, int, int); |
---|
98 | 93 | int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int); |
---|
99 | 94 | int xfs_iextents_copy(struct xfs_inode *, struct xfs_bmbt_rec *, |
---|
100 | 95 | int); |
---|
101 | | -void xfs_init_local_fork(struct xfs_inode *, int, const void *, int); |
---|
| 96 | +void xfs_init_local_fork(struct xfs_inode *ip, int whichfork, |
---|
| 97 | + const void *data, int64_t size); |
---|
102 | 98 | |
---|
103 | 99 | xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp); |
---|
104 | 100 | void xfs_iext_insert(struct xfs_inode *, struct xfs_iext_cursor *cur, |
---|
.. | .. |
---|
174 | 170 | |
---|
175 | 171 | extern void xfs_ifork_init_cow(struct xfs_inode *ip); |
---|
176 | 172 | |
---|
177 | | -typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_inode *); |
---|
178 | | - |
---|
179 | | -struct xfs_ifork_ops { |
---|
180 | | - xfs_ifork_verifier_t verify_symlink; |
---|
181 | | - xfs_ifork_verifier_t verify_dir; |
---|
182 | | - xfs_ifork_verifier_t verify_attr; |
---|
183 | | -}; |
---|
184 | | -extern struct xfs_ifork_ops xfs_default_ifork_ops; |
---|
185 | | - |
---|
186 | | -xfs_failaddr_t xfs_ifork_verify_data(struct xfs_inode *ip, |
---|
187 | | - struct xfs_ifork_ops *ops); |
---|
188 | | -xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_inode *ip, |
---|
189 | | - struct xfs_ifork_ops *ops); |
---|
| 173 | +int xfs_ifork_verify_local_data(struct xfs_inode *ip); |
---|
| 174 | +int xfs_ifork_verify_local_attr(struct xfs_inode *ip); |
---|
190 | 175 | |
---|
191 | 176 | #endif /* __XFS_INODE_FORK_H__ */ |
---|