Skip to content

Commit d393315

Browse files
boryaskdave
authored andcommitted
btrfs: make OWNER_REF_KEY type value smallest among inline refs
BTRFS_EXTENT_OWNER_REF_KEY is the type of simple quotas extent owner refs. This special inline ref goes in front of all other inline refs. In general, inline refs have a required sorted order s.t. type never decreases (among other requirements). This was recently reified into a tree-checker and fsck rule, which broke simple quotas. To be fair, though, in a sense, the new owner ref item had also violated that not yet fully enforced requirement. This fix brings the owner ref item into compliance with the requirement that inline ref type never decrease. btrfs/301 exercises this behavior and should pass again with this fix. Fixes: d9a620f ("btrfs: new inline ref storing owning subvol of data extents") Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 609d993 commit d393315

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

include/uapi/linux/btrfs_tree.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,22 @@
219219
*/
220220
#define BTRFS_METADATA_ITEM_KEY 169
221221

222+
/*
223+
* Special inline ref key which stores the id of the subvolume which originally
224+
* created the extent. This subvolume owns the extent permanently from the
225+
* perspective of simple quotas. Needed to know which subvolume to free quota
226+
* usage from when the extent is deleted.
227+
*
228+
* Stored as an inline ref rather to avoid wasting space on a separate item on
229+
* top of the existing extent item. However, unlike the other inline refs,
230+
* there is one one owner ref per extent rather than one per extent.
231+
*
232+
* Because of this, it goes at the front of the list of inline refs, and thus
233+
* must have a lower type value than any other inline ref type (to satisfy the
234+
* disk format rule that inline refs have non-decreasing type).
235+
*/
236+
#define BTRFS_EXTENT_OWNER_REF_KEY 172
237+
222238
#define BTRFS_TREE_BLOCK_REF_KEY 176
223239

224240
#define BTRFS_EXTENT_DATA_REF_KEY 178
@@ -233,14 +249,6 @@
233249

234250
#define BTRFS_SHARED_DATA_REF_KEY 184
235251

236-
/*
237-
* Special inline ref key which stores the id of the subvolume which originally
238-
* created the extent. This subvolume owns the extent permanently from the
239-
* perspective of simple quotas. Needed to know which subvolume to free quota
240-
* usage from when the extent is deleted.
241-
*/
242-
#define BTRFS_EXTENT_OWNER_REF_KEY 188
243-
244252
/*
245253
* block groups give us hints into the extent allocation trees. Which
246254
* blocks are free etc etc

0 commit comments

Comments
 (0)