From nobody Sun Feb 8 14:10:40 2026 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21AF71F7569 for ; Fri, 2 May 2025 20:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746216015; cv=none; b=kQ/JTpomTWAlxvIgXOWpT6DErr0F4vs0Ppmcz2e6ObL65yUbqQ4YVFqWzVDIF04ifkSHPSsU9gpZ0IKqyA61nBn5Lrk12MNQdcU3PnEJS3OvmTy20/w21SCUImoI7KKssIWKp2tz79XDCFaTUk4sNZJTploprbKzFTNsIwCY3KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746216015; c=relaxed/simple; bh=RcKkJtsoCg4JEJhBqrBT9I2/p66KBZXHKCNjzceiIgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPpKLpNke3LVilo8RsLeYx7NlCHTKbu4LySoKTOBCZp3u3a5FJE0798G6oDm5qjaxxRpRa9LLcX5dg0f2xtuxjIYl+9DfpuB3J41VHvQUgYvoMw6uH778ByfNg4SenChpMLDVexPooYXmuz2SckeyO4Kg48RLf3fdL6Oj8kRoag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RwqluP+B; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RwqluP+B" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1746216011; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ReUYFSWRiMLieiP4blFnICzA1f5cEZz7EuEF3waNFEM=; b=RwqluP+BwPz7xncWNhvsjsnXmyLwSsGI7x0539bGRwn3aakoLktYiUgKr5RVUvO3nuGe0a ILEjYgLn08Jci8WzMMuASOxnpgtvHA8ZMfpWgCLmimtYQLb/7kpoSMPHdAfVchx1EhshZt 4tE6se55T/y6xsYXb1QVeOBbFKicSYA= From: Kent Overstreet To: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 3/8] bcachefs: kill inode_walker_entry.snapshot Date: Fri, 2 May 2025 15:59:55 -0400 Message-ID: <20250502200002.1309862-4-kent.overstreet@linux.dev> In-Reply-To: <20250502200002.1309862-1-kent.overstreet@linux.dev> References: <20250502200002.1309862-1-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" redundant Signed-off-by: Kent Overstreet --- fs/bcachefs/fsck.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 7d3dd1a0ae4f..f0aa3c7479e1 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -785,12 +785,11 @@ static int ref_visible2(struct bch_fs *c, =20 #define for_each_visible_inode(_c, _s, _w, _snapshot, _i) \ for (_i =3D (_w)->inodes.data; _i < (_w)->inodes.data + (_w)->inodes.nr &= & \ - (_i)->snapshot <=3D (_snapshot); _i++) \ - if (key_visible_in_snapshot(_c, _s, _i->snapshot, _snapshot)) + (_i)->inode.bi_snapshot <=3D (_snapshot); _i++) \ + if (key_visible_in_snapshot(_c, _s, _i->inode.bi_snapshot, _snapshot)) =20 struct inode_walker_entry { struct bch_inode_unpacked inode; - u32 snapshot; u64 count; u64 i_size; }; @@ -824,7 +823,6 @@ static int add_inode(struct bch_fs *c, struct inode_wal= ker *w, return bch2_inode_unpack(inode, &u) ?: darray_push(&w->inodes, ((struct inode_walker_entry) { .inode =3D u, - .snapshot =3D inode.k->p.snapshot, })); } =20 @@ -870,19 +868,19 @@ lookup_inode_for_snapshot(struct bch_fs *c, struct in= ode_walker *w, struct bkey_ =20 struct inode_walker_entry *i; __darray_for_each(w->inodes, i) - if (bch2_snapshot_is_ancestor(c, k.k->p.snapshot, i->snapshot)) + if (bch2_snapshot_is_ancestor(c, k.k->p.snapshot, i->inode.bi_snapshot)) goto found; =20 return NULL; found: - BUG_ON(k.k->p.snapshot > i->snapshot); + BUG_ON(k.k->p.snapshot > i->inode.bi_snapshot); =20 - if (k.k->p.snapshot !=3D i->snapshot && !is_whiteout) { + if (k.k->p.snapshot !=3D i->inode.bi_snapshot && !is_whiteout) { struct inode_walker_entry new =3D *i; =20 - new.snapshot =3D k.k->p.snapshot; - new.count =3D 0; - new.i_size =3D 0; + new.inode.bi_snapshot =3D k.k->p.snapshot; + new.count =3D 0; + new.i_size =3D 0; =20 struct printbuf buf =3D PRINTBUF; bch2_bkey_val_to_text(&buf, c, k); @@ -890,10 +888,10 @@ lookup_inode_for_snapshot(struct bch_fs *c, struct in= ode_walker *w, struct bkey_ bch_info(c, "have key for inode %llu:%u but have inode in ancestor snaps= hot %u\n" "unexpected because we should always update the inode when we update a= key in that inode\n" "%s", - w->last_pos.inode, k.k->p.snapshot, i->snapshot, buf.buf); + w->last_pos.inode, k.k->p.snapshot, i->inode.bi_snapshot, buf.buf); printbuf_exit(&buf); =20 - while (i > w->inodes.data && i[-1].snapshot > k.k->p.snapshot) + while (i > w->inodes.data && i[-1].inode.bi_snapshot > k.k->p.snapshot) --i; =20 size_t pos =3D i - w->inodes.data; @@ -1496,21 +1494,21 @@ static int check_i_sectors_notnested(struct btree_t= rans *trans, struct inode_wal if (i->inode.bi_sectors =3D=3D i->count) continue; =20 - count2 =3D bch2_count_inode_sectors(trans, w->last_pos.inode, i->snapsho= t); + count2 =3D bch2_count_inode_sectors(trans, w->last_pos.inode, i->inode.b= i_snapshot); =20 if (w->recalculate_sums) i->count =3D count2; =20 if (i->count !=3D count2) { bch_err_ratelimited(c, "fsck counted i_sectors wrong for inode %llu:%u:= got %llu should be %llu", - w->last_pos.inode, i->snapshot, i->count, count2); + w->last_pos.inode, i->inode.bi_snapshot, i->count, count2); i->count =3D count2; } =20 if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty), trans, inode_i_sectors_wrong, "inode %llu:%u has incorrect i_sectors: got %llu, should be %llu", - w->last_pos.inode, i->snapshot, + w->last_pos.inode, i->inode.bi_snapshot, i->inode.bi_sectors, i->count)) { i->inode.bi_sectors =3D i->count; ret =3D bch2_fsck_write_inode(trans, &i->inode); @@ -1821,20 +1819,20 @@ static int check_extent(struct btree_trans *trans, = struct btree_iter *iter, for (struct inode_walker_entry *i =3D extent_i ?: &darray_last(inode->in= odes); inode->inodes.data && i >=3D inode->inodes.data; --i) { - if (i->snapshot > k.k->p.snapshot || - !key_visible_in_snapshot(c, s, i->snapshot, k.k->p.snapshot)) + if (i->inode.bi_snapshot > k.k->p.snapshot || + !key_visible_in_snapshot(c, s, i->inode.bi_snapshot, k.k->p.snapsho= t)) continue; =20 if (fsck_err_on(k.k->p.offset > round_up(i->inode.bi_size, block_bytes(= c)) >> 9 && !bkey_extent_is_reservation(k), trans, extent_past_end_of_inode, "extent type past end of inode %llu:%u, i_size %llu\n%s", - i->inode.bi_inum, i->snapshot, i->inode.bi_size, + i->inode.bi_inum, i->inode.bi_snapshot, i->inode.bi_size, (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) { struct btree_iter iter2; =20 bch2_trans_copy_iter(trans, &iter2, iter); - bch2_btree_iter_set_snapshot(trans, &iter2, i->snapshot); + bch2_btree_iter_set_snapshot(trans, &iter2, i->inode.bi_snapshot); ret =3D bch2_btree_iter_traverse(trans, &iter2) ?: bch2_btree_delete_at(trans, &iter2, BTREE_UPDATE_internal_snapshot_node); @@ -1856,8 +1854,8 @@ static int check_extent(struct btree_trans *trans, st= ruct btree_iter *iter, for (struct inode_walker_entry *i =3D extent_i ?: &darray_last(inode->in= odes); inode->inodes.data && i >=3D inode->inodes.data; --i) { - if (i->snapshot > k.k->p.snapshot || - !key_visible_in_snapshot(c, s, i->snapshot, k.k->p.snapshot)) + if (i->inode.bi_snapshot > k.k->p.snapshot || + !key_visible_in_snapshot(c, s, i->inode.bi_snapshot, k.k->p.snapsho= t)) continue; =20 i->count +=3D k.k->size; @@ -1939,13 +1937,13 @@ static int check_subdir_count_notnested(struct btre= e_trans *trans, struct inode_ if (i->inode.bi_nlink =3D=3D i->count) continue; =20 - count2 =3D bch2_count_subdirs(trans, w->last_pos.inode, i->snapshot); + count2 =3D bch2_count_subdirs(trans, w->last_pos.inode, i->inode.bi_snap= shot); if (count2 < 0) return count2; =20 if (i->count !=3D count2) { bch_err_ratelimited(c, "fsck counted subdirectories wrong for inum %llu= :%u: got %llu should be %llu", - w->last_pos.inode, i->snapshot, i->count, count2); + w->last_pos.inode, i->inode.bi_snapshot, i->count, count2); i->count =3D count2; if (i->inode.bi_nlink =3D=3D i->count) continue; @@ -1954,7 +1952,7 @@ static int check_subdir_count_notnested(struct btree_= trans *trans, struct inode_ if (fsck_err_on(i->inode.bi_nlink !=3D i->count, trans, inode_dir_wrong_nlink, "directory %llu:%u with wrong i_nlink: got %u, should be %llu", - w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) { + w->last_pos.inode, i->inode.bi_snapshot, i->inode.bi_nlink, i->count))= { i->inode.bi_nlink =3D i->count; ret =3D bch2_fsck_write_inode(trans, &i->inode); if (ret) --=20 2.49.0