bcachefs: Add an assertion to check for journal writes to same location
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 29 Jan 2021 18:58:10 +0000 (13:58 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:52 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/journal_io.c

index 19ba23f7d9dda67dcfba03e278cc9bfb475e1d69..bd675b88b35412db31ac864f1004382b29b62bd7 100644 (file)
@@ -473,6 +473,7 @@ struct bch_dev {
        atomic64_t              rebalance_work;
 
        struct journal_device   journal;
+       u64                     prev_journal_sector;
 
        struct work_struct      io_error_work;
 
index 252993ffcb1b16d4e9e408ccd667d4b160ce49ac..60cefb4ace45fc62ac3c3ab88e1eea58c0f9d8b3 100644 (file)
@@ -1286,6 +1286,9 @@ static void do_journal_write(struct closure *cl)
                bio->bi_end_io          = journal_write_endio;
                bio->bi_private         = ca;
 
+               BUG_ON(bio->bi_iter.bi_sector == ca->prev_journal_sector);
+               ca->prev_journal_sector = bio->bi_iter.bi_sector;
+
                if (!JSET_NO_FLUSH(w->data))
                        bio->bi_opf    |= REQ_FUA;
                if (!JSET_NO_FLUSH(w->data) && !w->separate_flush)