aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-04-25 14:35:51 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-04-25 14:35:59 -0400
commit693e278c14efae893a6f051446fbbc0cf5e408cd (patch)
treed07889b0a94a05e9610b1d100a214ca3927d7a23
parentfbe4e11c2615b65a0f91941b1e85d6d5ca8ebaf4 (diff)
downloadbcachefs-tools-693e278c14efae893a6f051446fbbc0cf5e408cd.tar.gz
Update bcachefs sources to fd6fb298aa bcachefs: Make sure hash info gets initialized in fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--.bcachefs_revision2
-rw-r--r--libbcachefs/btree_io.c2
-rw-r--r--libbcachefs/error.c5
-rw-r--r--libbcachefs/fsck.c25
4 files changed, 19 insertions, 15 deletions
diff --git a/.bcachefs_revision b/.bcachefs_revision
index baf525b7..bed19acb 100644
--- a/.bcachefs_revision
+++ b/.bcachefs_revision
@@ -1 +1 @@
-2115a2ffde28a51adbb8a62fd3c1a3e4dd1b6160
+fd6fb298aa869dc009e525baa9be67ad52588361
diff --git a/libbcachefs/btree_io.c b/libbcachefs/btree_io.c
index 1dfa3690..945d1b9e 100644
--- a/libbcachefs/btree_io.c
+++ b/libbcachefs/btree_io.c
@@ -1748,7 +1748,7 @@ static void btree_node_write_work(struct work_struct *work)
struct bch_fs *c = wbio->wbio.c;
struct btree *b = wbio->wbio.bio.bi_private;
struct bch_extent_ptr *ptr;
- int ret;
+ int ret = 0;
btree_bounce_free(c,
wbio->data_bytes,
diff --git a/libbcachefs/error.c b/libbcachefs/error.c
index aa640284..545c55da 100644
--- a/libbcachefs/error.c
+++ b/libbcachefs/error.c
@@ -158,6 +158,11 @@ int bch2_fsck_err(struct bch_fs *c, unsigned flags, const char *fmt, ...)
mutex_lock(&c->fsck_error_lock);
s = fsck_err_get(c, fmt);
if (s) {
+ /*
+ * We may be called multiple times for the same error on
+ * transaction restart - this memoizes instead of asking the user
+ * multiple times for the same error:
+ */
if (s->last_msg && !strcmp(buf.buf, s->last_msg)) {
ret = s->ret;
mutex_unlock(&c->fsck_error_lock);
diff --git a/libbcachefs/fsck.c b/libbcachefs/fsck.c
index 6319f2f7..4e710057 100644
--- a/libbcachefs/fsck.c
+++ b/libbcachefs/fsck.c
@@ -673,10 +673,8 @@ static int __walk_inode(struct btree_trans *trans,
pos.snapshot = bch2_snapshot_equiv(c, pos.snapshot);
- if (pos.inode == w->cur_inum) {
- w->first_this_inode = false;
+ if (pos.inode == w->cur_inum)
goto lookup_snapshot;
- }
w->inodes.nr = 0;
@@ -862,10 +860,10 @@ bad_hash:
(printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) {
ret = hash_redo_key(trans, desc, hash_info, k_iter, hash_k);
- if (ret) {
+ if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "hash_redo_key err %s", bch2_err_str(ret));
+ if (ret)
return ret;
- }
ret = -BCH_ERR_transaction_restart_nested;
}
fsck_err:
@@ -1639,6 +1637,10 @@ static int check_dirent(struct btree_trans *trans, struct btree_iter *iter,
if (ret < 0)
goto err;
+ if (dir->first_this_inode)
+ *hash_info = bch2_hash_info_init(c, &dir->inodes.data[0].inode);
+ dir->first_this_inode = false;
+
if (fsck_err_on(ret == INT_MAX, c,
"dirent in nonexisting directory:\n%s",
(printbuf_reset(&buf),
@@ -1665,11 +1667,7 @@ static int check_dirent(struct btree_trans *trans, struct btree_iter *iter,
goto out;
}
- if (dir->first_this_inode)
- *hash_info = bch2_hash_info_init(c, &dir->inodes.data[0].inode);
-
- ret = hash_check_key(trans, bch2_dirent_hash_desc,
- hash_info, iter, k);
+ ret = hash_check_key(trans, bch2_dirent_hash_desc, hash_info, iter, k);
if (ret < 0)
goto err;
if (ret) {
@@ -1822,6 +1820,10 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
if (ret < 0)
return ret;
+ if (inode->first_this_inode)
+ *hash_info = bch2_hash_info_init(c, &inode->inodes.data[0].inode);
+ inode->first_this_inode = false;
+
if (fsck_err_on(ret == INT_MAX, c,
"xattr for missing inode %llu",
k.k->p.inode))
@@ -1832,9 +1834,6 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
ret = 0;
- if (inode->first_this_inode)
- *hash_info = bch2_hash_info_init(c, &inode->inodes.data[0].inode);
-
ret = hash_check_key(trans, bch2_xattr_hash_desc, hash_info, iter, k);
fsck_err:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))