mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
bcachefs fixes for v6.8-rc5
Mostly pretty trivial, the user visible ones are: - don't barf when replicas_required > replicas - fix check_version_upgrade() so it doesn't do something nonsensical when we're downgrading -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEKnAFLkS8Qha+jvQrE6szbY3KbnYFAmXQ7/0ACgkQE6szbY3K bnbAVQ//V+25RfGRdb7JW7aXZJHyWdlpJE2Om0Vhbd3kYsEeMwqtugkuS4eE7nLV Xbi70de7Y7STXKrrTCAYZp7QIN0HY3VHtMnmh1IzbF31JZtI69AfZDRDKC9ITNhp Cf3jwmD9OypanVhdAlH/PIecxFdqglJ3e0V5r8zFibb4H2phn3rGPooNl9NCK+KN VZOz2W0roCslPutT89SWBRZl7og8BNky1ZYS3cjE+4gFg+/TTeCqgZXteoJkYR70 0oS+e33AdhxdLoPV6ePN0faFp4rpwh3mpy2gL4MhddSEqTEoUd0/Is4jmBUJtCps pgnFz+D2L4zRg2NnyAMVt4DrjyXNhjZDkbd43aK11yyCYSLmG87KW/95K7ocU60i /ZqUWWJ9IQO92ihQ+FxJcFw4pNTTWuzNNjZiGKvSad2/rU6btMKW4g+JbTNt2mqn 3X43s9pdx1sKvR5HNwvwm3R0mrT1baP+/mdfbgbmVPMS6ijD7KQ6JLhB3wGCFSKA /yNxasBt+Rfmn9gVsqRTBaH39GWbVwSwJO+gthLAdqylB/j8xne414BxPdhCXeOW 5KLvUUoJmIx7VW9NsJms4ES/yMd3xmlsyjOnRLqs4Q1WvxCIoyJnM/i02jRHfrjA 49qlZIR0Gm8rQw7qmjA/R6LzaY9T70uC1xCAHTQ1C+bvpzQW3M0= =XWHd -----END PGP SIGNATURE----- Merge tag 'bcachefs-2024-02-17' of https://evilpiepirate.org/git/bcachefs Pull bcachefs fixes from Kent Overstreet: "Mostly pretty trivial, the user visible ones are: - don't barf when replicas_required > replicas - fix check_version_upgrade() so it doesn't do something nonsensical when we're downgrading" * tag 'bcachefs-2024-02-17' of https://evilpiepirate.org/git/bcachefs: bcachefs: Fix missing va_end() bcachefs: Fix check_version_upgrade() bcachefs: Clamp replicas_required to replicas bcachefs: fix missing endiannes conversion in sb_members bcachefs: fix kmemleak in __bch2_read_super error handling path bcachefs: Fix missing bch2_err_class() calls
This commit is contained in:
commit
f2667e0c32
@ -1249,6 +1249,18 @@ static inline struct stdio_redirect *bch2_fs_stdio_redirect(struct bch_fs *c)
|
||||
return stdio;
|
||||
}
|
||||
|
||||
static inline unsigned metadata_replicas_required(struct bch_fs *c)
|
||||
{
|
||||
return min(c->opts.metadata_replicas,
|
||||
c->opts.metadata_replicas_required);
|
||||
}
|
||||
|
||||
static inline unsigned data_replicas_required(struct bch_fs *c)
|
||||
{
|
||||
return min(c->opts.data_replicas,
|
||||
c->opts.data_replicas_required);
|
||||
}
|
||||
|
||||
#define BKEY_PADDED_ONSTACK(key, pad) \
|
||||
struct { struct bkey_i key; __u64 key ## _pad[pad]; }
|
||||
|
||||
|
@ -280,7 +280,8 @@ retry:
|
||||
writepoint_ptr(&c->btree_write_point),
|
||||
&devs_have,
|
||||
res->nr_replicas,
|
||||
c->opts.metadata_replicas_required,
|
||||
min(res->nr_replicas,
|
||||
c->opts.metadata_replicas_required),
|
||||
watermark, 0, cl, &wp);
|
||||
if (unlikely(ret))
|
||||
return ERR_PTR(ret);
|
||||
|
@ -435,7 +435,7 @@ static int bch2_link(struct dentry *old_dentry, struct inode *vdir,
|
||||
bch2_subvol_is_ro(c, inode->ei_subvol) ?:
|
||||
__bch2_link(c, inode, dir, dentry);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
return bch2_err_class(ret);
|
||||
|
||||
ihold(&inode->v);
|
||||
d_instantiate(dentry, &inode->v);
|
||||
@ -487,8 +487,9 @@ static int bch2_unlink(struct inode *vdir, struct dentry *dentry)
|
||||
struct bch_inode_info *dir= to_bch_ei(vdir);
|
||||
struct bch_fs *c = dir->v.i_sb->s_fs_info;
|
||||
|
||||
return bch2_subvol_is_ro(c, dir->ei_subvol) ?:
|
||||
int ret = bch2_subvol_is_ro(c, dir->ei_subvol) ?:
|
||||
__bch2_unlink(vdir, dentry, false);
|
||||
return bch2_err_class(ret);
|
||||
}
|
||||
|
||||
static int bch2_symlink(struct mnt_idmap *idmap,
|
||||
@ -523,7 +524,7 @@ static int bch2_symlink(struct mnt_idmap *idmap,
|
||||
return 0;
|
||||
err:
|
||||
iput(&inode->v);
|
||||
return ret;
|
||||
return bch2_err_class(ret);
|
||||
}
|
||||
|
||||
static int bch2_mkdir(struct mnt_idmap *idmap,
|
||||
@ -641,7 +642,7 @@ err:
|
||||
src_inode,
|
||||
dst_inode);
|
||||
|
||||
return ret;
|
||||
return bch2_err_class(ret);
|
||||
}
|
||||
|
||||
static void bch2_setattr_copy(struct mnt_idmap *idmap,
|
||||
|
@ -1564,6 +1564,7 @@ CLOSURE_CALLBACK(bch2_write)
|
||||
BUG_ON(!op->write_point.v);
|
||||
BUG_ON(bkey_eq(op->pos, POS_MAX));
|
||||
|
||||
op->nr_replicas_required = min_t(unsigned, op->nr_replicas_required, op->nr_replicas);
|
||||
op->start_time = local_clock();
|
||||
bch2_keylist_init(&op->insert_keys, op->inline_keys);
|
||||
wbio_init(bio)->put_bio = false;
|
||||
|
@ -1478,6 +1478,8 @@ static int journal_write_alloc(struct journal *j, struct journal_buf *w)
|
||||
c->opts.foreground_target;
|
||||
unsigned i, replicas = 0, replicas_want =
|
||||
READ_ONCE(c->opts.metadata_replicas);
|
||||
unsigned replicas_need = min_t(unsigned, replicas_want,
|
||||
READ_ONCE(c->opts.metadata_replicas_required));
|
||||
|
||||
rcu_read_lock();
|
||||
retry:
|
||||
@ -1526,7 +1528,7 @@ done:
|
||||
|
||||
BUG_ON(bkey_val_u64s(&w->key.k) > BCH_REPLICAS_MAX);
|
||||
|
||||
return replicas >= c->opts.metadata_replicas_required ? 0 : -EROFS;
|
||||
return replicas >= replicas_need ? 0 : -EROFS;
|
||||
}
|
||||
|
||||
static void journal_buf_realloc(struct journal *j, struct journal_buf *buf)
|
||||
|
@ -205,7 +205,7 @@ void bch2_journal_space_available(struct journal *j)
|
||||
|
||||
j->can_discard = can_discard;
|
||||
|
||||
if (nr_online < c->opts.metadata_replicas_required) {
|
||||
if (nr_online < metadata_replicas_required(c)) {
|
||||
ret = JOURNAL_ERR_insufficient_devices;
|
||||
goto out;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ void bch2_prt_vprintf(struct printbuf *out, const char *fmt, va_list args)
|
||||
|
||||
va_copy(args2, args);
|
||||
len = vsnprintf(out->buf + out->pos, printbuf_remaining(out), fmt, args2);
|
||||
va_end(args2);
|
||||
} while (len + 1 >= printbuf_remaining(out) &&
|
||||
!bch2_printbuf_make_room(out, len + 1));
|
||||
|
||||
|
@ -577,8 +577,9 @@ u64 bch2_recovery_passes_from_stable(u64 v)
|
||||
|
||||
static bool check_version_upgrade(struct bch_fs *c)
|
||||
{
|
||||
unsigned latest_compatible = bch2_latest_compatible_version(c->sb.version);
|
||||
unsigned latest_version = bcachefs_metadata_version_current;
|
||||
unsigned latest_compatible = min(latest_version,
|
||||
bch2_latest_compatible_version(c->sb.version));
|
||||
unsigned old_version = c->sb.version_upgrade_complete ?: c->sb.version;
|
||||
unsigned new_version = 0;
|
||||
|
||||
@ -597,7 +598,7 @@ static bool check_version_upgrade(struct bch_fs *c)
|
||||
new_version = latest_version;
|
||||
break;
|
||||
case BCH_VERSION_UPGRADE_none:
|
||||
new_version = old_version;
|
||||
new_version = min(old_version, latest_version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -774,7 +775,7 @@ int bch2_fs_recovery(struct bch_fs *c)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(c->opts.nochanges && c->opts.norecovery)) {
|
||||
if (!c->opts.nochanges) {
|
||||
mutex_lock(&c->sb_lock);
|
||||
bool write_sb = false;
|
||||
|
||||
@ -804,7 +805,7 @@ int bch2_fs_recovery(struct bch_fs *c)
|
||||
if (bch2_check_version_downgrade(c)) {
|
||||
struct printbuf buf = PRINTBUF;
|
||||
|
||||
prt_str(&buf, "Version downgrade required:\n");
|
||||
prt_str(&buf, "Version downgrade required:");
|
||||
|
||||
__le64 passes = ext->recovery_passes_required[0];
|
||||
bch2_sb_set_downgrade(c,
|
||||
@ -812,7 +813,7 @@ int bch2_fs_recovery(struct bch_fs *c)
|
||||
BCH_VERSION_MINOR(c->sb.version));
|
||||
passes = ext->recovery_passes_required[0] & ~passes;
|
||||
if (passes) {
|
||||
prt_str(&buf, " running recovery passes: ");
|
||||
prt_str(&buf, "\n running recovery passes: ");
|
||||
prt_bitflags(&buf, bch2_recovery_passes,
|
||||
bch2_recovery_passes_from_stable(le64_to_cpu(passes)));
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ void bch2_dev_errors_reset(struct bch_dev *ca)
|
||||
m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(m->errors_at_reset); i++)
|
||||
m->errors_at_reset[i] = cpu_to_le64(atomic64_read(&ca->errors[i]));
|
||||
m->errors_reset_time = ktime_get_real_seconds();
|
||||
m->errors_reset_time = cpu_to_le64(ktime_get_real_seconds());
|
||||
|
||||
bch2_write_super(c);
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
@ -717,7 +717,7 @@ retry:
|
||||
|
||||
if (IS_ERR(sb->bdev_handle)) {
|
||||
ret = PTR_ERR(sb->bdev_handle);
|
||||
goto out;
|
||||
goto err;
|
||||
}
|
||||
sb->bdev = sb->bdev_handle->bdev;
|
||||
|
||||
|
@ -1428,10 +1428,10 @@ bool bch2_dev_state_allowed(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
required = max(!(flags & BCH_FORCE_IF_METADATA_DEGRADED)
|
||||
? c->opts.metadata_replicas
|
||||
: c->opts.metadata_replicas_required,
|
||||
: metadata_replicas_required(c),
|
||||
!(flags & BCH_FORCE_IF_DATA_DEGRADED)
|
||||
? c->opts.data_replicas
|
||||
: c->opts.data_replicas_required);
|
||||
: data_replicas_required(c));
|
||||
|
||||
return nr_rw >= required;
|
||||
case BCH_MEMBER_STATE_failed:
|
||||
|
Loading…
Reference in New Issue
Block a user