summaryrefslogtreecommitdiff
path: root/libbcachefs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-11 22:40:16 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-04-11 22:40:16 -0400
commit04ad4ade4c42aa716eae5ec12ba577eda4ab055e (patch)
tree4c57c6223e37885634d2672506a4eae80d69b555 /libbcachefs
parent7923c2ee0616ef35d984e292dd9e799babe96662 (diff)
Update bcachefs sources to fb8a27f6d4 bcachefs: Delete a redundant tracepoint
Diffstat (limited to 'libbcachefs')
-rw-r--r--libbcachefs/alloc_background.c11
-rw-r--r--libbcachefs/alloc_foreground.c2
-rw-r--r--libbcachefs/fsck.c39
-rw-r--r--libbcachefs/lru.c25
-rw-r--r--libbcachefs/lru.h4
5 files changed, 59 insertions, 22 deletions
diff --git a/libbcachefs/alloc_background.c b/libbcachefs/alloc_background.c
index a44d93b1..7be48297 100644
--- a/libbcachefs/alloc_background.c
+++ b/libbcachefs/alloc_background.c
@@ -545,6 +545,7 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
{
struct bch_fs *c = trans->c;
struct bch_alloc_v4 old_a, *new_a;
+ u64 old_lru, new_lru;
int ret = 0;
/*
@@ -586,13 +587,13 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
!new_a->io_time[READ])
new_a->io_time[READ] = max_t(u64, 1, atomic64_read(&c->io_clock[READ].now));
- if ((old_a.data_type == BCH_DATA_cached) !=
- (new_a->data_type == BCH_DATA_cached)) {
- u64 old_lru = alloc_lru_idx(old_a);
- u64 new_lru = alloc_lru_idx(*new_a);
+ old_lru = alloc_lru_idx(old_a);
+ new_lru = alloc_lru_idx(*new_a);
+
+ if (old_lru != new_lru) {
ret = bch2_lru_change(trans, new->k.p.inode, new->k.p.offset,
- old_lru, &new_lru);
+ old_lru, &new_lru, old);
if (ret)
return ret;
diff --git a/libbcachefs/alloc_foreground.c b/libbcachefs/alloc_foreground.c
index a789666d..c2af3600 100644
--- a/libbcachefs/alloc_foreground.c
+++ b/libbcachefs/alloc_foreground.c
@@ -226,8 +226,6 @@ static struct open_bucket *__try_alloc_bucket(struct bch_fs *c, struct bch_dev *
c->blocked_allocate_open_bucket = local_clock();
spin_unlock(&c->freelist_lock);
-
- trace_open_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve]);
return ERR_PTR(-OPEN_BUCKETS_EMPTY);
}
diff --git a/libbcachefs/fsck.c b/libbcachefs/fsck.c
index d2b155f0..5e2d24c4 100644
--- a/libbcachefs/fsck.c
+++ b/libbcachefs/fsck.c
@@ -304,7 +304,7 @@ static int __remove_dirent(struct btree_trans *trans, struct bpos pos)
ret = lookup_first_inode(trans, pos.inode, &dir_inode);
if (ret)
- return ret;
+ goto err;
dir_hash_info = bch2_hash_info_init(c, &dir_inode);
@@ -313,6 +313,9 @@ static int __remove_dirent(struct btree_trans *trans, struct bpos pos)
ret = bch2_hash_delete_at(trans, bch2_dirent_hash_desc,
&dir_hash_info, &iter, 0);
bch2_trans_iter_exit(trans, &iter);
+err:
+ if (ret && ret != -EINTR)
+ bch_err(c, "error %i from __remove_dirent()", ret);
return ret;
}
@@ -799,8 +802,10 @@ static int check_inode(struct btree_trans *trans,
return ret;
ret = check_key_has_snapshot(trans, iter, k);
+ if (ret < 0)
+ goto err;
if (ret)
- return ret < 0 ? ret : 0;
+ return 0;
/*
* if snapshot id isn't a leaf node, skip it - deletion in
@@ -911,7 +916,10 @@ static int check_inode(struct btree_trans *trans,
bch_err(c, "error in fsck: error %i "
"updating inode", ret);
}
+err:
fsck_err:
+ if (ret)
+ bch_err(c, "error %i from check_inode()", ret);
return ret;
}
@@ -941,6 +949,8 @@ static int check_inodes(struct bch_fs *c, bool full)
bch2_trans_iter_exit(&trans, &iter);
bch2_trans_exit(&trans);
+ if (ret)
+ bch_err(c, "error %i from check_inodes()", ret);
return ret;
}
@@ -1092,7 +1102,7 @@ static int inode_backpointer_exists(struct btree_trans *trans,
SPOS(inode->bi_dir, inode->bi_dir_offset, snapshot));
ret = bkey_err(d.s_c);
if (ret)
- return ret;
+ return ret == -ENOENT ? 0 : ret;
ret = dirent_points_to_inode(d, inode);
bch2_trans_iter_exit(trans, &iter);
@@ -1134,6 +1144,8 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
ret2 = -EINTR;
}
fsck_err:
+ if (ret)
+ bch_err(c, "error %i from check_i_sectors()", ret);
return ret ?: ret2;
}
@@ -1257,6 +1269,9 @@ out:
err:
fsck_err:
printbuf_exit(&buf);
+
+ if (ret && ret != -EINTR)
+ bch_err(c, "error %i from check_extent()", ret);
return ret;
}
@@ -1305,6 +1320,8 @@ static int check_extents(struct bch_fs *c)
bch2_trans_exit(&trans);
snapshots_seen_exit(&s);
+ if (ret)
+ bch_err(c, "error %i from check_extents()", ret);
return ret;
}
@@ -1342,6 +1359,8 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
}
}
fsck_err:
+ if (ret)
+ bch_err(c, "error %i from check_subdir_count()", ret);
return ret ?: ret2;
}
@@ -1458,6 +1477,9 @@ out:
err:
fsck_err:
printbuf_exit(&buf);
+
+ if (ret && ret != -EINTR)
+ bch_err(c, "error %i from check_target()", ret);
return ret;
}
@@ -1631,6 +1653,9 @@ out:
err:
fsck_err:
printbuf_exit(&buf);
+
+ if (ret && ret != -EINTR)
+ bch_err(c, "error %i from check_dirent()", ret);
return ret;
}
@@ -1675,6 +1700,9 @@ static int check_dirents(struct bch_fs *c)
snapshots_seen_exit(&s);
inode_walker_exit(&dir);
inode_walker_exit(&target);
+
+ if (ret)
+ bch_err(c, "error %i from check_dirents()", ret);
return ret;
}
@@ -1717,6 +1745,8 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
ret = hash_check_key(trans, bch2_xattr_hash_desc, hash_info, iter, k);
fsck_err:
+ if (ret && ret != -EINTR)
+ bch_err(c, "error %i from check_xattr()", ret);
return ret;
}
@@ -1754,6 +1784,9 @@ static int check_xattrs(struct bch_fs *c)
bch2_trans_iter_exit(&trans, &iter);
bch2_trans_exit(&trans);
+
+ if (ret)
+ bch_err(c, "error %i from check_xattrs()", ret);
return ret;
}
diff --git a/libbcachefs/lru.c b/libbcachefs/lru.c
index 08437d4a..fe9d1574 100644
--- a/libbcachefs/lru.c
+++ b/libbcachefs/lru.c
@@ -30,12 +30,13 @@ void bch2_lru_to_text(struct printbuf *out, struct bch_fs *c,
pr_buf(out, "idx %llu", le64_to_cpu(lru->idx));
}
-int bch2_lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time)
+int bch2_lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time,
+ struct bkey_s_c orig_k)
{
- struct bch_fs *c = trans->c;
struct btree_iter iter;
struct bkey_s_c k;
u64 existing_idx;
+ struct printbuf buf = PRINTBUF;
int ret = 0;
if (!time)
@@ -51,18 +52,20 @@ int bch2_lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time)
goto err;
if (k.k->type != KEY_TYPE_lru) {
- bch2_fs_inconsistent(c,
- "pointer to nonexistent lru %llu:%llu",
- id, time);
+ bch2_bkey_val_to_text(&buf, trans->c, orig_k);
+ bch2_trans_inconsistent(trans,
+ "pointer to nonexistent lru %llu:%llu\n%s",
+ id, time, buf.buf);
ret = -EIO;
goto err;
}
existing_idx = le64_to_cpu(bkey_s_c_to_lru(k).v->idx);
if (existing_idx != idx) {
- bch2_fs_inconsistent(c,
- "lru %llu:%llu with wrong backpointer: got %llu, should be %llu",
- id, time, existing_idx, idx);
+ bch2_bkey_val_to_text(&buf, trans->c, orig_k);
+ bch2_trans_inconsistent(trans,
+ "lru %llu:%llu with wrong backpointer: got %llu, should be %llu\n%s",
+ id, time, existing_idx, idx, buf.buf);
ret = -EIO;
goto err;
}
@@ -70,6 +73,7 @@ int bch2_lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time)
ret = bch2_btree_delete_at(trans, &iter, 0);
err:
bch2_trans_iter_exit(trans, &iter);
+ printbuf_exit(&buf);
return ret;
}
@@ -115,12 +119,13 @@ err:
}
int bch2_lru_change(struct btree_trans *trans, u64 id, u64 idx,
- u64 old_time, u64 *new_time)
+ u64 old_time, u64 *new_time,
+ struct bkey_s_c k)
{
if (old_time == *new_time)
return 0;
- return bch2_lru_delete(trans, id, idx, old_time) ?:
+ return bch2_lru_delete(trans, id, idx, old_time, k) ?:
bch2_lru_set(trans, id, idx, new_time);
}
diff --git a/libbcachefs/lru.h b/libbcachefs/lru.h
index 0a01836c..bfe38a67 100644
--- a/libbcachefs/lru.h
+++ b/libbcachefs/lru.h
@@ -10,9 +10,9 @@ void bch2_lru_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
.val_to_text = bch2_lru_to_text, \
}
-int bch2_lru_delete(struct btree_trans *, u64, u64, u64);
+int bch2_lru_delete(struct btree_trans *, u64, u64, u64, struct bkey_s_c);
int bch2_lru_set(struct btree_trans *, u64, u64, u64 *);
-int bch2_lru_change(struct btree_trans *, u64, u64, u64, u64 *);
+int bch2_lru_change(struct btree_trans *, u64, u64, u64, u64 *, struct bkey_s_c);
int bch2_check_lrus(struct bch_fs *, bool);