hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/fs/xfs/libxfs/xfs_bmap.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
44 * All Rights Reserved.
....@@ -95,12 +95,6 @@
9595 /* Map something in the CoW fork. */
9696 #define XFS_BMAPI_COWFORK 0x200
9797
98
-/* Only convert delalloc space, don't allocate entirely new extents */
99
-#define XFS_BMAPI_DELALLOC 0x400
100
-
101
-/* Only convert unwritten extents, don't allocate new blocks */
102
-#define XFS_BMAPI_CONVERT_ONLY 0x800
103
-
10498 /* Skip online discard of freed extents */
10599 #define XFS_BMAPI_NODISCARD 0x1000
106100
....@@ -117,8 +111,6 @@
117111 { XFS_BMAPI_ZERO, "ZERO" }, \
118112 { XFS_BMAPI_REMAP, "REMAP" }, \
119113 { XFS_BMAPI_COWFORK, "COWFORK" }, \
120
- { XFS_BMAPI_DELALLOC, "DELALLOC" }, \
121
- { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" }, \
122114 { XFS_BMAPI_NODISCARD, "NODISCARD" }, \
123115 { XFS_BMAPI_NORMAP, "NORMAP" }
124116
....@@ -166,27 +158,39 @@
166158 { BMAP_ATTRFORK, "ATTR" }, \
167159 { BMAP_COWFORK, "COW" }
168160
161
+/* Return true if the extent is an allocated extent, written or not. */
162
+static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
163
+{
164
+ return irec->br_startblock != HOLESTARTBLOCK &&
165
+ irec->br_startblock != DELAYSTARTBLOCK &&
166
+ !isnullstartblock(irec->br_startblock);
167
+}
169168
170169 /*
171170 * Return true if the extent is a real, allocated extent, or false if it is a
172171 * delayed allocation, and unwritten extent or a hole.
173172 */
174
-static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
173
+static inline bool xfs_bmap_is_written_extent(struct xfs_bmbt_irec *irec)
175174 {
176
- return irec->br_state != XFS_EXT_UNWRITTEN &&
177
- irec->br_startblock != HOLESTARTBLOCK &&
178
- irec->br_startblock != DELAYSTARTBLOCK &&
179
- !isnullstartblock(irec->br_startblock);
175
+ return xfs_bmap_is_real_extent(irec) &&
176
+ irec->br_state != XFS_EXT_UNWRITTEN;
180177 }
178
+
179
+/*
180
+ * Check the mapping for obviously garbage allocations that could trash the
181
+ * filesystem immediately.
182
+ */
183
+#define xfs_valid_startblock(ip, startblock) \
184
+ ((startblock) != 0 || XFS_IS_REALTIME_INODE(ip))
181185
182186 void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
183187 xfs_filblks_t len);
184
-void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *);
185188 int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
186189 int xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version);
187
-void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork);
190
+void xfs_bmap_local_to_extents_empty(struct xfs_trans *tp,
191
+ struct xfs_inode *ip, int whichfork);
188192 void __xfs_bmap_add_free(struct xfs_trans *tp, xfs_fsblock_t bno,
189
- xfs_filblks_t len, struct xfs_owner_info *oinfo,
193
+ xfs_filblks_t len, const struct xfs_owner_info *oinfo,
190194 bool skip_discard);
191195 void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
192196 int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
....@@ -223,18 +227,25 @@
223227 int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
224228 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
225229 bool *done, xfs_fileoff_t stop_fsb);
226
-int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
230
+int xfs_bmap_split_extent(struct xfs_trans *tp, struct xfs_inode *ip,
231
+ xfs_fileoff_t split_offset);
227232 int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
228233 xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
229234 struct xfs_bmbt_irec *got, struct xfs_iext_cursor *cur,
230235 int eof);
236
+int xfs_bmapi_convert_delalloc(struct xfs_inode *ip, int whichfork,
237
+ xfs_off_t offset, struct iomap *iomap, unsigned int *seq);
238
+int xfs_bmap_add_extent_unwritten_real(struct xfs_trans *tp,
239
+ struct xfs_inode *ip, int whichfork,
240
+ struct xfs_iext_cursor *icur, struct xfs_btree_cur **curp,
241
+ struct xfs_bmbt_irec *new, int *logflagsp);
231242
232243 static inline void
233244 xfs_bmap_add_free(
234245 struct xfs_trans *tp,
235246 xfs_fsblock_t bno,
236247 xfs_filblks_t len,
237
- struct xfs_owner_info *oinfo)
248
+ const struct xfs_owner_info *oinfo)
238249 {
239250 __xfs_bmap_add_free(tp, bno, len, oinfo, false);
240251 }
....@@ -256,9 +267,9 @@
256267 enum xfs_bmap_intent_type type, int whichfork,
257268 xfs_fileoff_t startoff, xfs_fsblock_t startblock,
258269 xfs_filblks_t *blockcount, xfs_exntst_t state);
259
-int xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
270
+void xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
260271 struct xfs_bmbt_irec *imap);
261
-int xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
272
+void xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
262273 struct xfs_bmbt_irec *imap);
263274
264275 static inline int xfs_bmap_fork_to_state(int whichfork)