bcachefs: Kill BCH_TRANS_COMMIT_lazy_rw
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 31 Oct 2024 07:39:32 +0000 (03:39 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:16 +0000 (01:36 -0500)
We unconditionally go read-write, if we're going to do so, before
journal replay: lazy_rw is obsolete.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_trans_commit.c
fs/bcachefs/btree_update.c
fs/bcachefs/btree_update.h
fs/bcachefs/lru.c
fs/bcachefs/rebalance.c
fs/bcachefs/snapshot.c
fs/bcachefs/subvolume.c
fs/bcachefs/super.h

index 3c4e66da1ca402bdc098c19498d960f6e9831a94..833d743dee0cf30a163222eabdf3d1ae0d23335c 100644 (file)
@@ -908,7 +908,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c)
                                        POS(ca->dev_idx, ca->mi.first_bucket),
                                        POS(ca->dev_idx, ca->mi.nbuckets - 1),
                                        BTREE_ITER_slots|BTREE_ITER_prefetch, k,
-                                       NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
+                                       NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
                                bch2_alloc_write_key(trans, &iter, ca, k)));
                if (ret) {
                        bch2_dev_put(ca);
index 529a5a19ab8a16f9b745dd78ea58efcff4e0f369..3aca746d08f6c9d37a5b27ce5dd122136cc4a5d4 100644 (file)
@@ -971,24 +971,6 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags,
        return ret;
 }
 
-static noinline int
-bch2_trans_commit_get_rw_cold(struct btree_trans *trans, unsigned flags)
-{
-       struct bch_fs *c = trans->c;
-       int ret;
-
-       if (likely(!(flags & BCH_TRANS_COMMIT_lazy_rw)) ||
-           test_bit(BCH_FS_started, &c->flags))
-               return -BCH_ERR_erofs_trans_commit;
-
-       ret = drop_locks_do(trans, bch2_fs_read_write_early(c));
-       if (ret)
-               return ret;
-
-       bch2_write_ref_get(c, BCH_WRITE_REF_trans);
-       return 0;
-}
-
 /*
  * This is for updates done in the early part of fsck - btree_gc - before we've
  * gone RW. we only add the new key to the list of keys for journal replay to
@@ -1037,16 +1019,13 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
        if (ret)
                goto out_reset;
 
-       if (unlikely(!test_bit(BCH_FS_may_go_rw, &c->flags))) {
-               ret = do_bch2_trans_commit_to_journal_replay(trans);
-               goto out_reset;
-       }
-
        if (!(flags & BCH_TRANS_COMMIT_no_check_rw) &&
            unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_trans))) {
-               ret = bch2_trans_commit_get_rw_cold(trans, flags);
-               if (ret)
-                       goto out_reset;
+               if (unlikely(!test_bit(BCH_FS_may_go_rw, &c->flags)))
+                       ret = do_bch2_trans_commit_to_journal_replay(trans);
+               else
+                       ret = -BCH_ERR_erofs_trans_commit;
+               goto out_reset;
        }
 
        EBUG_ON(test_bit(BCH_FS_clean_shutdown, &c->flags));
index 79a274dcd17bb0244293940ed46cba4f0d8a4a2d..a9a29fba49025727407e1a779b17716c780b31ef 100644 (file)
@@ -865,8 +865,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
                memcpy(l->d, buf.buf, buf.pos);
                c->journal.early_journal_entries.nr += jset_u64s(u64s);
        } else {
-               ret = bch2_trans_commit_do(c, NULL, NULL,
-                       BCH_TRANS_COMMIT_lazy_rw|commit_flags,
+               ret = bch2_trans_commit_do(c, NULL, NULL, commit_flags,
                        __bch2_trans_log_msg(trans, &buf, u64s));
        }
 err:
index 7e71c4d1111d4f14d391982fae199d6b75239547..3bc57d43aa8310cce0c63df8998b3b08d8723a0a 100644 (file)
@@ -24,7 +24,6 @@ void bch2_btree_insert_key_leaf(struct btree_trans *, struct btree_path *,
 #define BCH_TRANS_COMMIT_FLAGS()                                                       \
        x(no_enospc,    "don't check for enospc")                                       \
        x(no_check_rw,  "don't attempt to take a ref on c->writes")                     \
-       x(lazy_rw,      "go read-write if we haven't yet - only for use in recovery")   \
        x(no_journal_res, "don't take a journal reservation, instead "                  \
                        "pin journal entry referred to by trans->journal_res.seq")      \
        x(journal_reclaim, "operation required for journal reclaim; may return error"   \
index 10857eccdeafe8f629eee8c2a2578862da749574..c18242748ca3451cca7e9a3e3b27994c7cec04ae 100644 (file)
@@ -192,7 +192,7 @@ int bch2_check_lrus(struct bch_fs *c)
        int ret = bch2_trans_run(c,
                for_each_btree_key_commit(trans, iter,
                                BTREE_ID_lru, POS_MIN, BTREE_ITER_prefetch, k,
-                               NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
+                               NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
                        bch2_check_lru_key(trans, &iter, k, &last_flushed)));
 
        bch2_bkey_buf_exit(&last_flushed, c);
index d1b580e76ba489f431c9dabf81e54fc4f95dbe04..4adc74cd3f70b41830c3811f81058c7f936765ad 100644 (file)
@@ -257,8 +257,7 @@ err:
 int bch2_set_rebalance_needs_scan(struct bch_fs *c, u64 inum)
 {
        int ret = bch2_trans_commit_do(c, NULL, NULL,
-                                      BCH_TRANS_COMMIT_no_enospc|
-                                      BCH_TRANS_COMMIT_lazy_rw,
+                                      BCH_TRANS_COMMIT_no_enospc,
                            bch2_set_rebalance_needs_scan_trans(trans, inum));
        rebalance_wakeup(c);
        return ret;
index 34e01bd8127f955d1c5a9c1afd13a66d22b8311f..6a52090485dca6280de13ae235a9df5433ba0485 100644 (file)
@@ -1733,8 +1733,12 @@ void bch2_delete_dead_snapshots_work(struct work_struct *work)
 
 void bch2_delete_dead_snapshots_async(struct bch_fs *c)
 {
-       if (bch2_write_ref_tryget(c, BCH_WRITE_REF_delete_dead_snapshots) &&
-           !queue_work(c->write_ref_wq, &c->snapshot_delete_work))
+       if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_delete_dead_snapshots))
+               return;
+
+       BUG_ON(!test_bit(BCH_FS_may_go_rw, &c->flags));
+
+       if (!queue_work(c->write_ref_wq, &c->snapshot_delete_work))
                bch2_write_ref_put(c, BCH_WRITE_REF_delete_dead_snapshots);
 }
 
index 80e5efaff524be09a421f5dc62c3032c52914b7a..cb45ef769c540be19e52c865e8bd4c6ef7b29bf5 100644 (file)
@@ -675,7 +675,7 @@ err:
 /* set bi_subvol on root inode */
 int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c)
 {
-       int ret = bch2_trans_commit_do(c, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
+       int ret = bch2_trans_commit_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
                                       __bch2_fs_upgrade_for_subvolumes(trans));
        bch_err_fn(c, ret);
        return ret;
index dada09331d2eb78e4f2e40841ed6f2de1d88f453..fa6d5221651082600c28d4c761e62bd18cb4e15c 100644 (file)
@@ -34,16 +34,6 @@ void bch2_fs_read_only(struct bch_fs *);
 int bch2_fs_read_write(struct bch_fs *);
 int bch2_fs_read_write_early(struct bch_fs *);
 
-/*
- * Only for use in the recovery/fsck path:
- */
-static inline void bch2_fs_lazy_rw(struct bch_fs *c)
-{
-       if (!test_bit(BCH_FS_rw, &c->flags) &&
-           !test_bit(BCH_FS_was_rw, &c->flags))
-               bch2_fs_read_write_early(c);
-}
-
 void __bch2_fs_stop(struct bch_fs *);
 void bch2_fs_free(struct bch_fs *);
 void bch2_fs_stop(struct bch_fs *);