mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 10:43:43 +00:00
bcachefs fixes for 6.11-rc2, more
- fix a bug that was causing ACLs to seemingly "disappear" - new on disk format version, bcachefs_metadata_version_disk_accounting_v3 bcachefs_metadata_version_disk_accounting_v2 accidentally included padding in disk_accounting_key; fortunately, 6.11 isn't out yet so we can fix this with another version bump. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEKnAFLkS8Qha+jvQrE6szbY3KbnYFAma3mGIACgkQE6szbY3K bnagAw//XP8wYgEE6worKtLb8sNx+w+jeKR1FeAsYBP012+58xBvljxsUm2J6Mct bs7nJmhextVEhcIhm43/SEaic1dXWNxlC5hvTPQzJCGAjyVCPH2naXpz284GQzIu HlwBlnWK2HjnSpPHFPEqRm3jq/H9SGEhENDJTrccg7E82towGktQspvmx1Bzyt/E cb31An0Y4lQmZGu1/bxX0IDjcKYdI4Jr+FQwiJV35KwGXSw9gzkfHii0wNY+gTAj OklXiw5oOtIR52Oy7FKLhYWdl6GIe4/hYS+yYJ3sMiSUuYY50otwIGGnCRLICRlf AsE4fmN8wjTPCRryOOTDvc/MCuKuanQa8x1pH0cM3WMKqhl4mrDD2wne+38gfgDN zQwoLHfDdDXtadf0NB/VoVQnHTfYSk6GKpHHduMhZeb45XNm0WNryZcefQMunSMz CTBq22f22iSngF0KCvHQgp7mm8XNk+d12keQ37ldINRkC+mDWPu7Yi/mhwYzN43O +6WrzxyQsQPhLE+nfYRlvAuDCCVsXqjL2U2EVyuaBmUJaMMZbFU+u9zpb48dMjIl dRxBQfOsJjvbvTMTNlG4EDslKi8HjoqHXMo5Y3nhvSAmQRjkltfhiXSRivdJxYuR NwjJYtszbbBIqSsUZ6DqR+1eTG6HSQ1ML0B+Nm8orLLMqIFlAkQ= =f3fR -----END PGP SIGNATURE----- Merge tag 'bcachefs-2024-08-10' of git://evilpiepirate.org/bcachefs Pull more bcachefs fixes from Kent Overstreet: "A couple last minute fixes for the new disk accounting - fix a bug that was causing ACLs to seemingly "disappear" - new on disk format version, bcachefs_metadata_version_disk_accounting_v3 bcachefs_metadata_version_disk_accounting_v2 accidentally included padding in disk_accounting_key; fortunately, 6.11 isn't out yet so we can fix this with another version bump" * tag 'bcachefs-2024-08-10' of git://evilpiepirate.org/bcachefs: bcachefs: bcachefs_metadata_version_disk_accounting_v3 bcachefs: improve bch2_dev_usage_to_text() bcachefs: bch2_accounting_invalid() bcachefs: Switch to .get_inode_acl()
This commit is contained in:
commit
31b2444606
@ -272,16 +272,19 @@ bch2_acl_to_xattr(struct btree_trans *trans,
|
||||
return xattr;
|
||||
}
|
||||
|
||||
struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, int type)
|
||||
struct posix_acl *bch2_get_acl(struct inode *vinode, int type, bool rcu)
|
||||
{
|
||||
struct bch_inode_info *inode = to_bch_ei(dentry->d_inode);
|
||||
struct bch_inode_info *inode = to_bch_ei(vinode);
|
||||
struct bch_fs *c = inode->v.i_sb->s_fs_info;
|
||||
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
|
||||
struct xattr_search_key search = X_SEARCH(acl_to_xattr_type(type), "", 0);
|
||||
struct btree_trans *trans = bch2_trans_get(c);
|
||||
struct btree_iter iter = { NULL };
|
||||
struct posix_acl *acl = NULL;
|
||||
|
||||
if (rcu)
|
||||
return ERR_PTR(-ECHILD);
|
||||
|
||||
struct btree_trans *trans = bch2_trans_get(c);
|
||||
retry:
|
||||
bch2_trans_begin(trans);
|
||||
|
||||
|
@ -28,7 +28,7 @@ void bch2_acl_to_text(struct printbuf *, const void *, size_t);
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_POSIX_ACL
|
||||
|
||||
struct posix_acl *bch2_get_acl(struct mnt_idmap *, struct dentry *, int);
|
||||
struct posix_acl *bch2_get_acl(struct inode *, int, bool);
|
||||
|
||||
int bch2_set_acl_trans(struct btree_trans *, subvol_inum,
|
||||
struct bch_inode_unpacked *,
|
||||
|
@ -1740,7 +1740,7 @@ void bch2_dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
|
||||
printbuf_tabstop_push(out, 16);
|
||||
printbuf_tabstop_push(out, 16);
|
||||
|
||||
bch2_dev_usage_to_text(out, &stats);
|
||||
bch2_dev_usage_to_text(out, ca, &stats);
|
||||
|
||||
prt_newline(out);
|
||||
|
||||
|
@ -675,7 +675,8 @@ struct bch_sb_field_ext {
|
||||
x(btree_subvolume_children, BCH_VERSION(1, 6)) \
|
||||
x(mi_btree_bitmap, BCH_VERSION(1, 7)) \
|
||||
x(bucket_stripe_sectors, BCH_VERSION(1, 8)) \
|
||||
x(disk_accounting_v2, BCH_VERSION(1, 9))
|
||||
x(disk_accounting_v2, BCH_VERSION(1, 9)) \
|
||||
x(disk_accounting_v3, BCH_VERSION(1, 10))
|
||||
|
||||
enum bcachefs_metadata_version {
|
||||
bcachefs_metadata_version_min = 9,
|
||||
|
@ -71,17 +71,21 @@ bch2_fs_usage_read_short(struct bch_fs *c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bch2_dev_usage_to_text(struct printbuf *out, struct bch_dev_usage *usage)
|
||||
void bch2_dev_usage_to_text(struct printbuf *out,
|
||||
struct bch_dev *ca,
|
||||
struct bch_dev_usage *usage)
|
||||
{
|
||||
prt_printf(out, "\tbuckets\rsectors\rfragmented\r\n");
|
||||
|
||||
for (unsigned i = 0; i < BCH_DATA_NR; i++) {
|
||||
bch2_prt_data_type(out, i);
|
||||
prt_printf(out, "\t%llu\r%llu\r%llu\r\n",
|
||||
usage->d[i].buckets,
|
||||
usage->d[i].sectors,
|
||||
usage->d[i].fragmented);
|
||||
usage->d[i].buckets,
|
||||
usage->d[i].sectors,
|
||||
usage->d[i].fragmented);
|
||||
}
|
||||
|
||||
prt_printf(out, "capacity\t%llu\r\n", ca->mi.nbuckets);
|
||||
}
|
||||
|
||||
static int bch2_check_fix_ptr(struct btree_trans *trans,
|
||||
|
@ -212,7 +212,7 @@ static inline struct bch_dev_usage bch2_dev_usage_read(struct bch_dev *ca)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bch2_dev_usage_to_text(struct printbuf *, struct bch_dev_usage *);
|
||||
void bch2_dev_usage_to_text(struct printbuf *, struct bch_dev *, struct bch_dev_usage *);
|
||||
|
||||
static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_watermark watermark)
|
||||
{
|
||||
|
@ -114,11 +114,74 @@ int bch2_mod_dev_cached_sectors(struct btree_trans *trans,
|
||||
return bch2_disk_accounting_mod(trans, &acc, §ors, 1, gc);
|
||||
}
|
||||
|
||||
static inline bool is_zero(char *start, char *end)
|
||||
{
|
||||
BUG_ON(start > end);
|
||||
|
||||
for (; start < end; start++)
|
||||
if (*start)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#define field_end(p, member) (((void *) (&p.member)) + sizeof(p.member))
|
||||
|
||||
int bch2_accounting_invalid(struct bch_fs *c, struct bkey_s_c k,
|
||||
enum bch_validate_flags flags,
|
||||
struct printbuf *err)
|
||||
{
|
||||
return 0;
|
||||
struct disk_accounting_pos acc_k;
|
||||
bpos_to_disk_accounting_pos(&acc_k, k.k->p);
|
||||
void *end = &acc_k + 1;
|
||||
int ret = 0;
|
||||
|
||||
switch (acc_k.type) {
|
||||
case BCH_DISK_ACCOUNTING_nr_inodes:
|
||||
end = field_end(acc_k, nr_inodes);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_persistent_reserved:
|
||||
end = field_end(acc_k, persistent_reserved);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_replicas:
|
||||
bkey_fsck_err_on(!acc_k.replicas.nr_devs,
|
||||
c, err, accounting_key_replicas_nr_devs_0,
|
||||
"accounting key replicas entry with nr_devs=0");
|
||||
|
||||
bkey_fsck_err_on(acc_k.replicas.nr_required > acc_k.replicas.nr_devs ||
|
||||
(acc_k.replicas.nr_required > 1 &&
|
||||
acc_k.replicas.nr_required == acc_k.replicas.nr_devs),
|
||||
c, err, accounting_key_replicas_nr_required_bad,
|
||||
"accounting key replicas entry with bad nr_required");
|
||||
|
||||
for (unsigned i = 0; i + 1 < acc_k.replicas.nr_devs; i++)
|
||||
bkey_fsck_err_on(acc_k.replicas.devs[i] > acc_k.replicas.devs[i + 1],
|
||||
c, err, accounting_key_replicas_devs_unsorted,
|
||||
"accounting key replicas entry with unsorted devs");
|
||||
|
||||
end = (void *) &acc_k.replicas + replicas_entry_bytes(&acc_k.replicas);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_dev_data_type:
|
||||
end = field_end(acc_k, dev_data_type);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_compression:
|
||||
end = field_end(acc_k, compression);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_snapshot:
|
||||
end = field_end(acc_k, snapshot);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_btree:
|
||||
end = field_end(acc_k, btree);
|
||||
break;
|
||||
case BCH_DISK_ACCOUNTING_rebalance_work:
|
||||
end = field_end(acc_k, rebalance_work);
|
||||
break;
|
||||
}
|
||||
|
||||
bkey_fsck_err_on(!is_zero(end, (void *) (&acc_k + 1)),
|
||||
c, err, accounting_key_junk_at_end,
|
||||
"junk at end of accounting key");
|
||||
fsck_err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bch2_accounting_key_to_text(struct printbuf *out, struct disk_accounting_pos *k)
|
||||
|
@ -124,20 +124,19 @@ struct bch_dev_data_type {
|
||||
__u8 data_type;
|
||||
};
|
||||
|
||||
struct bch_dev_stripe_buckets {
|
||||
__u8 dev;
|
||||
};
|
||||
|
||||
struct bch_acct_compression {
|
||||
__u8 type;
|
||||
};
|
||||
|
||||
struct bch_acct_snapshot {
|
||||
__u32 id;
|
||||
};
|
||||
} __packed;
|
||||
|
||||
struct bch_acct_btree {
|
||||
__u32 id;
|
||||
} __packed;
|
||||
|
||||
struct bch_acct_rebalance_work {
|
||||
};
|
||||
|
||||
struct disk_accounting_pos {
|
||||
@ -149,12 +148,12 @@ struct disk_accounting_pos {
|
||||
struct bch_persistent_reserved persistent_reserved;
|
||||
struct bch_replicas_entry_v1 replicas;
|
||||
struct bch_dev_data_type dev_data_type;
|
||||
struct bch_dev_stripe_buckets dev_stripe_buckets;
|
||||
struct bch_acct_compression compression;
|
||||
struct bch_acct_snapshot snapshot;
|
||||
struct bch_acct_btree btree;
|
||||
};
|
||||
};
|
||||
struct bch_acct_rebalance_work rebalance_work;
|
||||
} __packed;
|
||||
} __packed;
|
||||
struct bpos _pad;
|
||||
};
|
||||
};
|
||||
|
@ -1199,7 +1199,7 @@ static const struct inode_operations bch_file_inode_operations = {
|
||||
.fiemap = bch2_fiemap,
|
||||
.listxattr = bch2_xattr_list,
|
||||
#ifdef CONFIG_BCACHEFS_POSIX_ACL
|
||||
.get_acl = bch2_get_acl,
|
||||
.get_inode_acl = bch2_get_acl,
|
||||
.set_acl = bch2_set_acl,
|
||||
#endif
|
||||
};
|
||||
@ -1219,7 +1219,7 @@ static const struct inode_operations bch_dir_inode_operations = {
|
||||
.tmpfile = bch2_tmpfile,
|
||||
.listxattr = bch2_xattr_list,
|
||||
#ifdef CONFIG_BCACHEFS_POSIX_ACL
|
||||
.get_acl = bch2_get_acl,
|
||||
.get_inode_acl = bch2_get_acl,
|
||||
.set_acl = bch2_set_acl,
|
||||
#endif
|
||||
};
|
||||
@ -1241,7 +1241,7 @@ static const struct inode_operations bch_symlink_inode_operations = {
|
||||
.setattr = bch2_setattr,
|
||||
.listxattr = bch2_xattr_list,
|
||||
#ifdef CONFIG_BCACHEFS_POSIX_ACL
|
||||
.get_acl = bch2_get_acl,
|
||||
.get_inode_acl = bch2_get_acl,
|
||||
.set_acl = bch2_set_acl,
|
||||
#endif
|
||||
};
|
||||
@ -1251,7 +1251,7 @@ static const struct inode_operations bch_special_inode_operations = {
|
||||
.setattr = bch2_setattr,
|
||||
.listxattr = bch2_xattr_list,
|
||||
#ifdef CONFIG_BCACHEFS_POSIX_ACL
|
||||
.get_acl = bch2_get_acl,
|
||||
.get_inode_acl = bch2_get_acl,
|
||||
.set_acl = bch2_set_acl,
|
||||
#endif
|
||||
};
|
||||
|
@ -24,7 +24,6 @@ static int bch2_memcmp(const void *l, const void *r, const void *priv)
|
||||
static void verify_replicas_entry(struct bch_replicas_entry_v1 *e)
|
||||
{
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
BUG_ON(e->data_type >= BCH_DATA_NR);
|
||||
BUG_ON(!e->nr_devs);
|
||||
BUG_ON(e->nr_required > 1 &&
|
||||
e->nr_required >= e->nr_devs);
|
||||
|
@ -61,12 +61,37 @@
|
||||
BCH_FSCK_ERR_dev_usage_buckets_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_sectors_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_fragmented_wrong, \
|
||||
BCH_FSCK_ERR_accounting_mismatch)
|
||||
BCH_FSCK_ERR_accounting_mismatch) \
|
||||
x(disk_accounting_v3, \
|
||||
BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \
|
||||
BCH_FSCK_ERR_bkey_version_in_future, \
|
||||
BCH_FSCK_ERR_dev_usage_buckets_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_sectors_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_fragmented_wrong, \
|
||||
BCH_FSCK_ERR_accounting_mismatch, \
|
||||
BCH_FSCK_ERR_accounting_key_replicas_nr_devs_0, \
|
||||
BCH_FSCK_ERR_accounting_key_replicas_nr_required_bad, \
|
||||
BCH_FSCK_ERR_accounting_key_replicas_devs_unsorted, \
|
||||
BCH_FSCK_ERR_accounting_key_junk_at_end)
|
||||
|
||||
#define DOWNGRADE_TABLE() \
|
||||
x(bucket_stripe_sectors, \
|
||||
0) \
|
||||
x(disk_accounting_v2, \
|
||||
BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \
|
||||
BCH_FSCK_ERR_dev_usage_buckets_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_sectors_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_fragmented_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_hidden_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_btree_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_data_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_cached_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_reserved_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_nr_inodes_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_persistent_reserved_wrong, \
|
||||
BCH_FSCK_ERR_fs_usage_replicas_wrong, \
|
||||
BCH_FSCK_ERR_bkey_version_in_future) \
|
||||
x(disk_accounting_v3, \
|
||||
BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \
|
||||
BCH_FSCK_ERR_dev_usage_buckets_wrong, \
|
||||
BCH_FSCK_ERR_dev_usage_sectors_wrong, \
|
||||
|
@ -287,7 +287,11 @@ enum bch_fsck_flags {
|
||||
x(accounting_replicas_not_marked, 273, 0) \
|
||||
x(invalid_btree_id, 274, 0) \
|
||||
x(alloc_key_io_time_bad, 275, 0) \
|
||||
x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX)
|
||||
x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX) \
|
||||
x(accounting_key_junk_at_end, 277, 0) \
|
||||
x(accounting_key_replicas_nr_devs_0, 278, 0) \
|
||||
x(accounting_key_replicas_nr_required_bad, 279, 0) \
|
||||
x(accounting_key_replicas_devs_unsorted, 280, 0) \
|
||||
|
||||
enum bch_sb_error_id {
|
||||
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,
|
||||
|
Loading…
Reference in New Issue
Block a user