Skip to content

Commit 6bee2a0

Browse files
author
Kent Overstreet
committed
bcachefs: handle restarts in bch2_bucket_io_time_reset()
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 <[email protected]>
1 parent 29fd10a commit 6bee2a0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,24 +2351,19 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
23512351

23522352
/* Bucket IO clocks: */
23532353

2354-
int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
2355-
size_t bucket_nr, int rw)
2354+
static int __bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
2355+
size_t bucket_nr, int rw)
23562356
{
23572357
struct bch_fs *c = trans->c;
2358-
struct btree_iter iter;
2359-
struct bkey_i_alloc_v4 *a;
2360-
u64 now;
2361-
int ret = 0;
23622358

2363-
if (bch2_trans_relock(trans))
2364-
bch2_trans_begin(trans);
2365-
2366-
a = bch2_trans_start_alloc_update_noupdate(trans, &iter, POS(dev, bucket_nr));
2367-
ret = PTR_ERR_OR_ZERO(a);
2359+
struct btree_iter iter;
2360+
struct bkey_i_alloc_v4 *a =
2361+
bch2_trans_start_alloc_update_noupdate(trans, &iter, POS(dev, bucket_nr));
2362+
int ret = PTR_ERR_OR_ZERO(a);
23682363
if (ret)
23692364
return ret;
23702365

2371-
now = bch2_current_io_time(c, rw);
2366+
u64 now = bch2_current_io_time(c, rw);
23722367
if (a->v.io_time[rw] == now)
23732368
goto out;
23742369

@@ -2381,6 +2376,15 @@ int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
23812376
return ret;
23822377
}
23832378

2379+
int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
2380+
size_t bucket_nr, int rw)
2381+
{
2382+
if (bch2_trans_relock(trans))
2383+
bch2_trans_begin(trans);
2384+
2385+
return nested_lockrestart_do(trans, __bch2_bucket_io_time_reset(trans, dev, bucket_nr, rw));
2386+
}
2387+
23842388
/* Startup/shutdown (ro/rw): */
23852389

23862390
void bch2_recalc_capacity(struct bch_fs *c)

0 commit comments

Comments
 (0)