diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-04-28 03:50:57 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:01 -0400 |
commit | cb1b479dc1c78d1d224e4aa6aba212a7bd3263a4 (patch) | |
tree | 513bb9bfc7c62be3eadc1ec622f420b4497d9d28 /fs/bcachefs/quota.c | |
parent | 653693beea8ac93e57fc17afc7353bd158bcd5ff (diff) | |
download | lwn-cb1b479dc1c78d1d224e4aa6aba212a7bd3263a4.tar.gz lwn-cb1b479dc1c78d1d224e4aa6aba212a7bd3263a4.zip |
bcachefs: Fix quotas + snapshots
Now that we can reliably designate and find the master subvolume out of
a tree of snapshots, we can finally make quotas work with snapshots:
That is - quotas will now _ignore_ snapshot subvolumes, and only be in
effect for the master (non snapshot) subvolume.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
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; } |