hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/xfs/libxfs/xfs_inode_fork.h
....@@ -13,16 +13,18 @@
1313 * File incore extent information, present for each of data & attr forks.
1414 */
1515 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 */
1817 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 */
2119 int if_height; /* height of the extent tree */
2220 union {
2321 void *if_root; /* extent tree root */
2422 char *if_data; /* inline file data */
2523 } 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 */
2628 };
2729
2830 /*
....@@ -46,59 +48,53 @@
4648 (ip)->i_afp : \
4749 (ip)->i_cowfp))
4850 #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))
5252 #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)
5754 #define XFS_IFORK_SIZE(ip,w) \
5855 ((w) == XFS_DATA_FORK ? \
5956 XFS_IFORK_DSIZE(ip) : \
6057 ((w) == XFS_ATTR_FORK ? \
6158 XFS_IFORK_ASIZE(ip) : \
6259 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))))
8760 #define XFS_IFORK_MAXEXT(ip, w) \
8861 (XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t))
8962
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
+
9083 struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state);
9184
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 *);
9387 void xfs_iflush_fork(struct xfs_inode *, struct xfs_dinode *,
9488 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);
9792 void xfs_iroot_realloc(struct xfs_inode *, int, int);
9893 int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
9994 int xfs_iextents_copy(struct xfs_inode *, struct xfs_bmbt_rec *,
10095 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);
10298
10399 xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp);
104100 void xfs_iext_insert(struct xfs_inode *, struct xfs_iext_cursor *cur,
....@@ -174,18 +170,7 @@
174170
175171 extern void xfs_ifork_init_cow(struct xfs_inode *ip);
176172
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);
190175
191176 #endif /* __XFS_INODE_FORK_H__ */