bcachefs: Make sure to pass a disk reservation to bch2_extent_update()
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 17 May 2021 04:08:06 +0000 (00:08 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:03 +0000 (17:09 -0400)
It's needed when we split an existing compressed extent - we get a null
ptr deref without it.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/reflink.c

index 0978ad92614c649d61b3ed40cf0f89cb772f740c..405a194d10e5db7e6b1d9446351013c5be3b1791 100644 (file)
@@ -2,6 +2,7 @@
 #include "bcachefs.h"
 #include "bkey_buf.h"
 #include "btree_update.h"
+#include "buckets.h"
 #include "extents.h"
 #include "inode.h"
 #include "io.h"
@@ -224,6 +225,8 @@ s64 bch2_remap_range(struct bch_fs *c,
                                       BTREE_ITER_INTENT);
 
        while (ret == 0 || ret == -EINTR) {
+               struct disk_reservation disk_res = { 0 };
+
                bch2_trans_begin(&trans);
 
                if (fatal_signal_pending(current)) {
@@ -287,8 +290,9 @@ s64 bch2_remap_range(struct bch_fs *c,
                                    dst_end.offset - dst_iter->pos.offset));
 
                ret = bch2_extent_update(&trans, dst_iter, new_dst.k,
-                                        NULL, journal_seq,
+                                        &disk_res, journal_seq,
                                         new_i_size, i_sectors_delta);
+               bch2_disk_reservation_put(c, &disk_res);
                if (ret)
                        continue;