]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
bcachefs: handle restarts in bch2_bucket_io_time_reset()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 15 Oct 2024 03:58:45 +0000 (23:58 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 18 Oct 2024 04:49:48 +0000 (00:49 -0400)
bch2_bucket_io_time_reset() doesn't need to succeed, which is why it
didn't previously retry on transaction restart - but we're now treating
these as errors.

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

index 50f1919f4cbf670ed83a51d71bbbe721ebc2191c..69c7fc97e467941817a4572ada1aee6538f621e6 100644 (file)
@@ -2351,24 +2351,19 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
 
 /* Bucket IO clocks: */
 
-int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
-                             size_t bucket_nr, int rw)
+static int __bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
+                               size_t bucket_nr, int rw)
 {
        struct bch_fs *c = trans->c;
-       struct btree_iter iter;
-       struct bkey_i_alloc_v4 *a;
-       u64 now;
-       int ret = 0;
 
-       if (bch2_trans_relock(trans))
-               bch2_trans_begin(trans);
-
-       a = bch2_trans_start_alloc_update_noupdate(trans, &iter, POS(dev, bucket_nr));
-       ret = PTR_ERR_OR_ZERO(a);
+       struct btree_iter iter;
+       struct bkey_i_alloc_v4 *a =
+               bch2_trans_start_alloc_update_noupdate(trans, &iter, POS(dev, bucket_nr));
+       int ret = PTR_ERR_OR_ZERO(a);
        if (ret)
                return ret;
 
-       now = bch2_current_io_time(c, rw);
+       u64 now = bch2_current_io_time(c, rw);
        if (a->v.io_time[rw] == now)
                goto out;
 
@@ -2381,6 +2376,15 @@ out:
        return ret;
 }
 
+int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
+                             size_t bucket_nr, int rw)
+{
+       if (bch2_trans_relock(trans))
+               bch2_trans_begin(trans);
+
+       return nested_lockrestart_do(trans, __bch2_bucket_io_time_reset(trans, dev, bucket_nr, rw));
+}
+
 /* Startup/shutdown (ro/rw): */
 
 void bch2_recalc_capacity(struct bch_fs *c)