summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/extents.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-10-25 01:51:34 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:08:45 +0200
commit801a3de6427924d87ecc7e218a99ad3245ee8290 (patch)
tree9fb234d536b6e5d8dbc990ea89ae80a8ca7aa35f /fs/bcachefs/extents.h
parentbcachefs: Fix rare use after free in read path (diff)
downloadlinux-801a3de6427924d87ecc7e218a99ad3245ee8290.tar.xz
linux-801a3de6427924d87ecc7e218a99ad3245ee8290.zip
bcachefs: Indirect inline data extents
When inline data extents were added, reflink was forgotten about - we need indirect inline data extents for reflink + inline data to work correctly. This patch adds them, and a new feature bit that's flipped when they're used. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.h')
-rw-r--r--fs/bcachefs/extents.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/fs/bcachefs/extents.h b/fs/bcachefs/extents.h
index 29b15365d19c..74c7bb8f9104 100644
--- a/fs/bcachefs/extents.h
+++ b/fs/bcachefs/extents.h
@@ -445,10 +445,35 @@ static inline bool bkey_extent_is_direct_data(const struct bkey *k)
}
}
+static inline bool bkey_extent_is_inline_data(const struct bkey *k)
+{
+ return k->type == KEY_TYPE_inline_data ||
+ k->type == KEY_TYPE_indirect_inline_data;
+}
+
+static inline unsigned bkey_inline_data_offset(const struct bkey *k)
+{
+ switch (k->type) {
+ case KEY_TYPE_inline_data:
+ return sizeof(struct bch_inline_data);
+ case KEY_TYPE_indirect_inline_data:
+ return sizeof(struct bch_indirect_inline_data);
+ default:
+ BUG();
+ }
+}
+
+static inline unsigned bkey_inline_data_bytes(const struct bkey *k)
+{
+ return bkey_val_bytes(k) - bkey_inline_data_offset(k);
+}
+
+#define bkey_inline_data_p(_k) (((void *) (_k).v) + bkey_inline_data_offset((_k).k))
+
static inline bool bkey_extent_is_data(const struct bkey *k)
{
- return bkey_extent_is_direct_data(k) ||
- k->type == KEY_TYPE_inline_data ||
+ return bkey_extent_is_direct_data(k) ||
+ bkey_extent_is_inline_data(k) ||
k->type == KEY_TYPE_reflink_p;
}
@@ -463,6 +488,7 @@ static inline bool bkey_extent_is_allocation(const struct bkey *k)
case KEY_TYPE_reflink_p:
case KEY_TYPE_reflink_v:
case KEY_TYPE_inline_data:
+ case KEY_TYPE_indirect_inline_data:
return true;
default:
return false;