bcachefs: data move path should not be trying to move reflink_p keys
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 7 Sep 2019 20:13:20 +0000 (16:13 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:26 +0000 (17:08 -0400)
This was spotted when the move_extent() path tried to allocate a bio for
a reflink_p extent, but adding pages to the bio failed because we
overflowed bi_max_vecs. Oops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/extents.h
fs/bcachefs/move.c

index 4c4a7945a751c126cb7c34d4324dc919fa4e2df9..766584939304fa2132a362a46875aa67357932cd 100644 (file)
@@ -455,12 +455,11 @@ unsigned bch2_extent_is_compressed(struct bkey_s_c);
 bool bch2_bkey_matches_ptr(struct bch_fs *, struct bkey_s_c,
                           struct bch_extent_ptr, u64);
 
-static inline bool bkey_extent_is_data(const struct bkey *k)
+static inline bool bkey_extent_is_direct_data(const struct bkey *k)
 {
        switch (k->type) {
        case KEY_TYPE_btree_ptr:
        case KEY_TYPE_extent:
-       case KEY_TYPE_reflink_p:
        case KEY_TYPE_reflink_v:
                return true;
        default:
@@ -468,6 +467,12 @@ static inline bool bkey_extent_is_data(const struct bkey *k)
        }
 }
 
+static inline bool bkey_extent_is_data(const struct bkey *k)
+{
+       return bkey_extent_is_direct_data(k) ||
+               k->type == KEY_TYPE_reflink_p;
+}
+
 /*
  * Should extent be counted under inode->i_sectors?
  */
index d01c96ff00d7bfc84f2c44be6e4a18b69479f35d..8855dd19f7f2186a3c19c16602c31e037441f633 100644 (file)
@@ -547,7 +547,7 @@ peek:
                if (bkey_cmp(bkey_start_pos(k.k), end) >= 0)
                        break;
 
-               if (!bkey_extent_is_data(k.k))
+               if (!bkey_extent_is_direct_data(k.k))
                        goto next_nondata;
 
                if (cur_inum != k.k->p.inode) {