Skip to contentSkip to conversation

bcachefs: bcachefs_metadata_version_inode_has_child_snapshots

bug report Dan Carpenter 2 participants 2 messages Oct 9, 2024

lore
Share & tools
lore
#0 lore raw

Hello Kent Overstreet,

Commit 6375feaa7a3b ("bcachefs:
bcachefs_metadata_version_inode_has_child_snapshots") from Sep 29, 2024 (linux-next), leads to the following Smatch static checker warning:

	fs/bcachefs/fsck.c:1183 check_inode()
	warn: should this be a bitwise negate mask?

fs/bcachefs/fsck.c

    1168 
    1169         ret = bch2_inode_has_child_snapshots(trans, k.k->p);
    1170         if (ret < 0)
    1171                 goto err;
    1172 
    1173         if (fsck_err_on(ret != !!(u.bi_flags & BCH_INODE_has_child_snapshot),
    1174                         trans, inode_has_child_snapshots_wrong,
    1175                         "inode has_child_snapshots flag wrong (should be %u)\n%s",
    1176                         ret,
    1177                         (printbuf_reset(&buf),
    1178                          bch2_inode_unpacked_to_text(&buf, &u),
    1179                          buf.buf))) {
    1180                 if (ret)
    1181                         u.bi_flags |= BCH_INODE_has_child_snapshot;
    1182                 else

--> 1183 u.bi_flags &= !BCH_INODE_has_child_snapshot;

This was intended to be u.bi_flags &= ~BCH_INODE_has_child_snapshot otherwise it's the same as "u.bi_flags = 0;"

    1184                 do_update = true;
    1185         }
    1186         ret = 0;
    1187 
    1188         if ((u.bi_flags & BCH_INODE_unlinked) &&

regards,
dan carpenter

#1 lore raw
Quoted 26 lines · Dan Carpenter

Hello Kent Overstreet,

Commit 6375feaa7a3b ("bcachefs:
bcachefs_metadata_version_inode_has_child_snapshots") from Sep 29, 2024 (linux-next), leads to the following Smatch static checker warning:

	fs/bcachefs/fsck.c:1183 check_inode()
	warn: should this be a bitwise negate mask?

fs/bcachefs/fsck.c

    1168 
    1169         ret = bch2_inode_has_child_snapshots(trans, k.k->p);
    1170         if (ret < 0)
    1171                 goto err;
    1172 
    1173         if (fsck_err_on(ret != !!(u.bi_flags & BCH_INODE_has_child_snapshot),
    1174                         trans, inode_has_child_snapshots_wrong,
    1175                         "inode has_child_snapshots flag wrong (should be %u)\n%s",
    1176                         ret,
    1177                         (printbuf_reset(&buf),
    1178                          bch2_inode_unpacked_to_text(&buf, &u),
    1179                          buf.buf))) {
    1180                 if (ret)
    1181                         u.bi_flags |= BCH_INODE_has_child_snapshot;
    1182                 else
Quoted 4 lines

--> 1183 u.bi_flags &= !BCH_INODE_has_child_snapshot;

This was intended to be u.bi_flags &= ~BCH_INODE_has_child_snapshot otherwise it's the same as "u.bi_flags = 0;"

Thanks, fixed