Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bcachefs version upgrade isn't written to disk immediately (umount is needed) [1166d22b67675611902976b36dbf38d45848826f] #759

Open
jpsollie opened this issue Oct 10, 2024 · 1 comment

Comments

@jpsollie
Copy link
Contributor

jpsollie commented Oct 10, 2024

when performing a version upgrade at mount, apparently the upgraded version isn't written to disk immediately,
but gets written after a umount, eg my multimedia fs gets mounted at boot:

#dmesg | grep bcachefs
[   40.053674] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): starting version 1.12: rebalance_work_acct_fix opts=metadata_replicas=2,data_checksum=xxhash,metadata_target=SSDM,foreground_target=SSDC,background_target=HDD,promote_target=SSDC
[   40.053684] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): recovering from clean shutdown, journal seq 88863359
[   40.053688] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): Doing compatible version upgrade from 1.12: rebalance_work_acct_fix to 1.13: inode_has_child_snapshots
[   40.148281] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): accounting_read...
[   42.840116] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): alloc_read... done
[   42.854930] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): stripes_read... done
[   42.854934] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): snapshots_read... done
[   43.003431] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): going read-write
[   43.219441] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): journal_replay... done
[   43.219444] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): check_inodes...
[   73.048135] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): resume_logged_ops... done
[   73.052540] [ T4446] bcachefs (ac7b718e-2f5b-4910-af1b-0255fa366f19): delete_dead_inodes... done

#bcachefs show-super /dev/md3
Device:                                     (unknown device)
External UUID:                             ac7b718e-2f5b-4910-af1b-0255fa366f19
Internal UUID:                             2a4933d1-83cb-4aa5-8635-fed38050445b
Magic number:                              c68573f6-66ce-90a9-d96a-60cf803df7ef
Device index:                              0
Label:                                     multimedia
Version:                                   1.12: rebalance_work_acct_fix
Version upgrade complete:                  1.12: rebalance_work_acct_fix
Oldest version on disk:                    1.12: rebalance_work_acct_fix
Created:                                   Sat Dec 16 22:09:09 2023
Sequence number:                           649
Time of last write:                        Thu Oct 10 10:12:25 2024
Superblock size:                           7.40 KiB/1.00 MiB
Clean:                                     1
Devices:                                   14
Sections:                                  members_v1,replicas_v0,disk_groups,clean,journal_seq_blacklist,journal_v2,counters,members_v2,errors,ext,downgrade
Features:                                  journal_seq_blacklist_v3,reflink,new_siphash,inline_data,new_extent_overwrite,btree_ptr_v2,reflink_inline_data,new_varint,journal_no_flush,alloc_v2,extents_across_btree_nodes
Compat features:                           alloc_info,alloc_metadata,extents_above_btree_updates_done,bformat_overflow_done
# umount /data/multimedia

# bcachefs show-super /dev/md3
Device:                                     (unknown device)
External UUID:                             ac7b718e-2f5b-4910-af1b-0255fa366f19
Internal UUID:                             2a4933d1-83cb-4aa5-8635-fed38050445b
Magic number:                              c68573f6-66ce-90a9-d96a-60cf803df7ef
Device index:                              0
Label:                                     multimedia
Version:                                   1.13: inode_has_child_snapshots
Version upgrade complete:                  1.13: inode_has_child_snapshots
Oldest version on disk:                    1.12: rebalance_work_acct_fix
Created:                                   Sat Dec 16 22:09:09 2023
Sequence number:                           654
Time of last write:                        Thu Oct 10 10:39:26 2024
Superblock size:                           7.41 KiB/1.00 MiB
Clean:                                     1
Devices:                                   14
Sections:                                  members_v1,replicas_v0,disk_groups,clean,journal_seq_blacklist,journal_v2,counters,members_v2,errors,ext,downgrade
Features:                                  journal_seq_blacklist_v3,reflink,new_siphash,inline_data,new_extent_overwrite,btree_ptr_v2,reflink_inline_data,new_varint,journal_no_flush,alloc_v2,extents_across_btree_nodes
Compat features:                           alloc_info,alloc_metadata,extents_above_btree_updates_done,bformat_overflow_done

this may result in a warning "incomplete upgrade" when the system uncleanly unmounts while it did a version upgrade at boot

@jpsollie
Copy link
Contributor Author

something like this is needed (BUT THIS ONE WOULD COULD DEADLOCK, SO DO NOT IMPLEMENT):

--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -620,7 +620,7 @@ static bool check_version_upgrade(struct bch_fs *c)
                bch_info(c, "%s", buf.buf);
 
                bch2_sb_upgrade(c, new_version);
-
+               c->vfs_sb->s_op->sync_fs(c->vfs_sb, 0);
                printbuf_exit(&buf);
                return true;
        }

... but I can't imagine a vfs sync() can be called before the upgrade is completed, so this patch won't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant