xref: /linux/fs/bcachefs/reflink_format.h (revision 2622f290417001b0440f4a48dc6978f5f1e12a56)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_REFLINK_FORMAT_H
3 #define _BCACHEFS_REFLINK_FORMAT_H
4 
5 struct bch_reflink_p {
6 	struct bch_val		v;
7 	__le64			idx_flags;
8 	/*
9 	 * A reflink pointer might point to an indirect extent which is then
10 	 * later split (by copygc or rebalance). If we only pointed to part of
11 	 * the original indirect extent, and then one of the fragments is
12 	 * outside the range we point to, we'd leak a refcount: so when creating
13 	 * reflink pointers, we need to store pad values to remember the full
14 	 * range we were taking a reference on.
15 	 */
16 	__le32			front_pad;
17 	__le32			back_pad;
18 } __packed __aligned(8);
19 
20 LE64_BITMASK(REFLINK_P_IDX,	struct bch_reflink_p, idx_flags,  0, 56);
21 LE64_BITMASK(REFLINK_P_ERROR,	struct bch_reflink_p, idx_flags, 56, 57);
22 LE64_BITMASK(REFLINK_P_MAY_UPDATE_OPTIONS,
23 				struct bch_reflink_p, idx_flags, 57, 58);
24 
25 struct bch_reflink_v {
26 	struct bch_val		v;
27 	__le64			refcount;
28 	union bch_extent_entry	start[0];
29 	__u64			_data[];
30 } __packed __aligned(8);
31 
32 struct bch_indirect_inline_data {
33 	struct bch_val		v;
34 	__le64			refcount;
35 	u8			data[];
36 };
37 
38 #endif /* _BCACHEFS_REFLINK_FORMAT_H */
39