]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bcachefs: Fix setting of downgrade recovery passes/errors
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 27 May 2024 20:30:19 +0000 (16:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jul 2024 07:38:17 +0000 (09:38 +0200)
commit 247c056bde2ebc9fad2fc62332dc7cc99b58d720 upstream.

bch2_check_version_downgrade() was setting c->sb.version, which
bch2_sb_set_downgrade() expects to be at the previous version; and it
shouldn't even have been set directly because c->sb.version is updated
by write_super().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/bcachefs/super-io.c

index bfdb15e7d778e24e6d6d327168646d18b17f4464..a337246e912aa7e018f5546182c6abbb9bae3e6f 100644 (file)
@@ -1123,18 +1123,12 @@ bool bch2_check_version_downgrade(struct bch_fs *c)
         * c->sb will be checked before we write the superblock, so update it as
         * well:
         */
-       if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) > bcachefs_metadata_version_current) {
+       if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) > bcachefs_metadata_version_current)
                SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current);
-               c->sb.version_upgrade_complete = bcachefs_metadata_version_current;
-       }
-       if (c->sb.version > bcachefs_metadata_version_current) {
+       if (c->sb.version > bcachefs_metadata_version_current)
                c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
-               c->sb.version = bcachefs_metadata_version_current;
-       }
-       if (c->sb.version_min > bcachefs_metadata_version_current) {
+       if (c->sb.version_min > bcachefs_metadata_version_current)
                c->disk_sb.sb->version_min = cpu_to_le16(bcachefs_metadata_version_current);
-               c->sb.version_min = bcachefs_metadata_version_current;
-       }
        c->disk_sb.sb->compat[0] &= cpu_to_le64((1ULL << BCH_COMPAT_NR) - 1);
        return ret;
 }