mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-23 00:07:07 +03:00
Update bcachefs sources to fb39031ade bcachefs: bch2_sb_maybe_downgrade(), bch2_sb_upgrade()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
ffa950ce1d
commit
73bf371f4c
@ -1 +1 @@
|
||||
1e3ca87f7b8e33f8d96260afebc7e78959f93073
|
||||
fb39031ade476044b4d89e6a8f20de8e025be39c
|
||||
|
@ -1158,6 +1158,17 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
|
||||
bch2_err_matches(ret, ENOMEM)) {
|
||||
struct closure cl;
|
||||
|
||||
/*
|
||||
* XXX: this should probably be a separate BTREE_INSERT_NONBLOCK
|
||||
* flag
|
||||
*/
|
||||
if (bch2_err_matches(ret, ENOSPC) &&
|
||||
(flags & BTREE_INSERT_JOURNAL_RECLAIM) &&
|
||||
watermark != BCH_WATERMARK_reclaim) {
|
||||
ret = -BCH_ERR_journal_reclaim_would_deadlock;
|
||||
goto err;
|
||||
}
|
||||
|
||||
closure_init_stack(&cl);
|
||||
|
||||
do {
|
||||
|
@ -958,6 +958,10 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags,
|
||||
bch2_replicas_delta_list_mark(c, trans->fs_usage_deltas));
|
||||
break;
|
||||
case -BCH_ERR_journal_res_get_blocked:
|
||||
/*
|
||||
* XXX: this should probably be a separate BTREE_INSERT_NONBLOCK
|
||||
* flag
|
||||
*/
|
||||
if ((flags & BTREE_INSERT_JOURNAL_RECLAIM) &&
|
||||
(flags & BCH_WATERMARK_MASK) != BCH_WATERMARK_reclaim) {
|
||||
ret = -BCH_ERR_journal_reclaim_would_deadlock;
|
||||
|
@ -1169,8 +1169,7 @@ static void check_version_upgrade(struct bch_fs *c)
|
||||
c->opts.fix_errors = FSCK_OPT_YES;
|
||||
|
||||
mutex_lock(&c->sb_lock);
|
||||
c->disk_sb.sb->version = cpu_to_le16(new_version);
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL);
|
||||
bch2_sb_upgrade(c, new_version);
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
||||
printbuf_exit(&buf);
|
||||
@ -1528,10 +1527,11 @@ int bch2_fs_initialize(struct bch_fs *c)
|
||||
c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_extents_above_btree_updates_done);
|
||||
c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_bformat_overflow_done);
|
||||
|
||||
bch2_sb_maybe_downgrade(c);
|
||||
|
||||
if (c->opts.version_upgrade != BCH_VERSION_UPGRADE_none) {
|
||||
c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
|
||||
bch2_sb_upgrade(c, bcachefs_metadata_version_current);
|
||||
SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current);
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL);
|
||||
bch2_write_super(c);
|
||||
}
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
@ -1197,17 +1197,10 @@ int bch2_sb_clean_validate_late(struct bch_fs *c, struct bch_sb_field_clean *cle
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bch2_fs_mark_dirty(struct bch_fs *c)
|
||||
/* Downgrade if superblock is at a higher version than currently supported: */
|
||||
void bch2_sb_maybe_downgrade(struct bch_fs *c)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Unconditionally write superblock, to verify it hasn't changed before
|
||||
* we go rw:
|
||||
*/
|
||||
|
||||
mutex_lock(&c->sb_lock);
|
||||
SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
|
||||
lockdep_assert_held(&c->sb_lock);
|
||||
|
||||
/*
|
||||
* Downgrade, if superblock is at a higher version than currently
|
||||
@ -1220,8 +1213,31 @@ int bch2_fs_mark_dirty(struct bch_fs *c)
|
||||
if (c->sb.version_min > bcachefs_metadata_version_current)
|
||||
c->disk_sb.sb->version_min = cpu_to_le16(bcachefs_metadata_version_current);
|
||||
c->disk_sb.sb->compat[0] &= cpu_to_le64((1ULL << BCH_COMPAT_NR) - 1);
|
||||
}
|
||||
|
||||
void bch2_sb_upgrade(struct bch_fs *c, unsigned new_version)
|
||||
{
|
||||
lockdep_assert_held(&c->sb_lock);
|
||||
|
||||
c->disk_sb.sb->version = cpu_to_le16(new_version);
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL);
|
||||
}
|
||||
|
||||
int bch2_fs_mark_dirty(struct bch_fs *c)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Unconditionally write superblock, to verify it hasn't changed before
|
||||
* we go rw:
|
||||
*/
|
||||
|
||||
mutex_lock(&c->sb_lock);
|
||||
SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
|
||||
|
||||
bch2_sb_maybe_downgrade(c);
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALWAYS);
|
||||
|
||||
ret = bch2_write_super(c);
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
||||
|
@ -124,6 +124,9 @@ void bch2_journal_super_entries_add_common(struct bch_fs *,
|
||||
|
||||
int bch2_sb_clean_validate_late(struct bch_fs *, struct bch_sb_field_clean *, int);
|
||||
|
||||
void bch2_sb_maybe_downgrade(struct bch_fs *);
|
||||
void bch2_sb_upgrade(struct bch_fs *, unsigned);
|
||||
|
||||
int bch2_fs_mark_dirty(struct bch_fs *);
|
||||
void bch2_fs_mark_clean(struct bch_fs *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user