diff options
Diffstat (limited to 'fs/bcachefs/quota.c')
-rw-r--r-- | fs/bcachefs/quota.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c index 7734e0dfe523..310eb9d26571 100644 --- a/fs/bcachefs/quota.c +++ b/fs/bcachefs/quota.c @@ -2,6 +2,7 @@ #include "bcachefs.h" #include "btree_update.h" #include "errcode.h" +#include "error.h" #include "inode.h" #include "quota.h" #include "subvolume.h" @@ -556,23 +557,25 @@ static int bch2_fs_quota_read_inode(struct btree_trans *trans, { struct bch_fs *c = trans->c; struct bch_inode_unpacked u; - struct bch_subvolume subvolume; + struct bch_snapshot_tree s_t; int ret; - ret = bch2_snapshot_get_subvol(trans, k.k->p.snapshot, &subvolume); + ret = bch2_snapshot_tree_lookup(trans, + snapshot_t(c, k.k->p.snapshot)->tree, &s_t); + bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), c, + "%s: snapshot tree %u not found", __func__, + snapshot_t(c, k.k->p.snapshot)->tree); if (ret) return ret; - /* - * We don't do quota accounting in snapshots: - */ - if (BCH_SUBVOLUME_SNAP(&subvolume)) + if (!s_t.master_subvol) goto advance; - if (!bkey_is_inode(k.k)) - goto advance; - - ret = bch2_inode_unpack(k, &u); + ret = bch2_inode_find_by_inum_trans(trans, + (subvol_inum) { + le32_to_cpu(s_t.master_subvol), + k.k->p.offset, + }, &u); if (ret) return ret; @@ -581,7 +584,7 @@ static int bch2_fs_quota_read_inode(struct btree_trans *trans, bch2_quota_acct(c, bch_qid(&u), Q_INO, 1, KEY_TYPE_QUOTA_NOCHECK); advance: - bch2_btree_iter_set_pos(iter, POS(iter->pos.inode, iter->pos.offset + 1)); + bch2_btree_iter_set_pos(iter, bpos_nosnap_successor(iter->pos)); return 0; } |