Skip to content

Commit a7dc10c

Browse files
author
Kent Overstreet
committed
bcachefs: Make sure allocation failure errors are logged
The previous patch fixed a bug in allocation path error handling, and it would've been noticed sooner had it been logged properly. Generally speaking, errors that shouldn't happen in normal operation and are being returned up the stack should be logged: the write path was already logging IO errors, but non IO errors were missed. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 548673f commit a7dc10c

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ do { \
326326
bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\
327327
} while (0)
328328

329+
#define bch_err_fn_ratelimited(_c, _ret) \
330+
do { \
331+
if (should_print_err(_ret)) \
332+
bch_err_ratelimited(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\
333+
} while (0)
334+
329335
#define bch_err_msg(_c, _ret, _msg, ...) \
330336
do { \
331337
if (should_print_err(_ret)) \

fs/bcachefs/btree_update_interior.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,9 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
11901190
return as;
11911191
err:
11921192
bch2_btree_update_free(as, trans);
1193+
if (!bch2_err_matches(ret, ENOSPC) &&
1194+
!bch2_err_matches(ret, EROFS))
1195+
bch_err_fn_ratelimited(c, ret);
11931196
return ERR_PTR(ret);
11941197
}
11951198

fs/bcachefs/data_update.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ static void bch2_update_unwritten_extent(struct btree_trans *trans,
418418
continue;
419419
}
420420

421+
bch_err_fn_ratelimited(c, ret);
422+
421423
if (ret)
422424
return;
423425

fs/bcachefs/io_misc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int bch2_extent_fallocate(struct btree_trans *trans,
6161
*/
6262
ret = bch2_disk_reservation_get(c, &disk_res, sectors, new_replicas, 0);
6363
if (unlikely(ret))
64-
goto err;
64+
goto err_noprint;
6565

6666
bch2_bkey_buf_reassemble(&old, c, k);
6767
}
@@ -125,7 +125,12 @@ int bch2_extent_fallocate(struct btree_trans *trans,
125125
err:
126126
if (!ret && sectors_allocated)
127127
bch2_increment_clock(c, sectors_allocated, WRITE);
128-
128+
if (should_print_err(ret))
129+
bch_err_inum_offset_ratelimited(c,
130+
inum.inum,
131+
iter->pos.offset << 9,
132+
"%s(): error: %s", __func__, bch2_err_str(ret));
133+
err_noprint:
129134
bch2_open_buckets_put(c, &open_buckets);
130135
bch2_disk_reservation_put(c, &disk_res);
131136
bch2_bkey_buf_exit(&new, c);

fs/bcachefs/io_write.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,10 @@ static void __bch2_write(struct bch_write_op *op)
14631463
op->flags |= BCH_WRITE_DONE;
14641464

14651465
if (ret < 0) {
1466+
bch_err_inum_offset_ratelimited(c,
1467+
op->pos.inode,
1468+
op->pos.offset << 9,
1469+
"%s(): error: %s", __func__, bch2_err_str(ret));
14661470
op->error = ret;
14671471
break;
14681472
}

0 commit comments

Comments
 (0)