return (struct inode_walker) { 0, };
}
-static int inode_walker_realloc(struct inode_walker *w)
+static int inode_walker_realloc(struct bch_fs *c, struct inode_walker *w)
{
if (w->nr == w->size) {
size_t new_size = max_t(size_t, 8UL, w->size * 2);
void *d = krealloc(w->d, new_size * sizeof(w->d[0]),
GFP_KERNEL);
- if (!d)
+ if (!d) {
+ bch_err(c, "fsck: error allocating memory for inode_walker, size %zu",
+ new_size);
return -ENOMEM;
+ }
w->d = d;
w->size = new_size;
struct bch_inode_unpacked u;
int ret;
- ret = inode_walker_realloc(w);
+ ret = inode_walker_realloc(c, w);
if (ret)
return ret;
while (i && w->d[i - 1].snapshot > pos.snapshot)
--i;
- ret = inode_walker_realloc(w);
+ ret = inode_walker_realloc(c, w);
if (ret)
return ret;
count2 = lockrestart_do(trans,
bch2_count_inode_sectors(trans, w->cur_inum, i->snapshot));
- if (fsck_err_on(i->count != count2, c,
- "fsck counted i_sectors wrong: got %llu should be %llu",
- i->count, count2)) {
+ if (i->count != count2) {
+ bch_err(c, "fsck counted i_sectors wrong: got %llu should be %llu",
+ i->count, count2);
i->count = count2;
if (i->inode.bi_sectors == i->count)
continue;
if (i->inode.bi_nlink == i->count)
continue;
- count2 = lockrestart_do(trans,
- bch2_count_subdirs(trans, w->cur_inum, i->snapshot));
+ count2 = bch2_count_subdirs(trans, w->cur_inum, i->snapshot);
+ if (count2 < 0)
+ return count2;
- if (fsck_err_on(i->count != count2, c,
- "directory %llu:%u: fsck counted subdirectories wrong, got %llu should be %llu",
- w->cur_inum, i->snapshot, i->count, count2)) {
+ if (i->count != count2) {
+ bch_err(c, "fsck counted subdirectories wrong: got %llu should be %llu",
+ i->count, count2);
i->count = count2;
if (i->inode.bi_nlink == i->count)
continue;
return false;
}
-static int path_down(struct pathbuf *p, u64 inum, u32 snapshot)
+static int path_down(struct bch_fs *c, struct pathbuf *p,
+ u64 inum, u32 snapshot)
{
if (p->nr == p->size) {
size_t new_size = max_t(size_t, 256UL, p->size * 2);
new_size * sizeof(p->entries[0]),
GFP_KERNEL);
if (!n) {
+ bch_err(c, "fsck: error allocating memory for pathbuf, size %zu",
+ new_size);
return -ENOMEM;
}
if (!S_ISDIR(inode->bi_mode))
break;
- ret = path_down(p, inode->bi_inum, snapshot);
+ ret = path_down(c, p, inode->bi_inum, snapshot);
if (ret) {
bch_err(c, "memory allocation failure");
return ret;
} *d;
};
-static int add_nlink(struct nlink_table *t, u64 inum, u32 snapshot)
+static int add_nlink(struct bch_fs *c, struct nlink_table *t,
+ u64 inum, u32 snapshot)
{
if (t->nr == t->size) {
size_t new_size = max_t(size_t, 128UL, t->size * 2);
void *d = kvmalloc(new_size * sizeof(t->d[0]), GFP_KERNEL);
if (!d) {
+ bch_err(c, "fsck: error allocating memory for nlink_table, size %zu",
+ new_size);
return -ENOMEM;
}
if (!u.bi_nlink)
continue;
- ret = add_nlink(t, k.k->p.offset, k.k->p.snapshot);
+ ret = add_nlink(c, t, k.k->p.offset, k.k->p.snapshot);
if (ret) {
*end = k.k->p.offset;
ret = 0;