]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/quota.c
Update bcachefs sources to 1336a995cbc3 bcachefs: Silence transaction restart error...
[bcachefs-tools-debian] / libbcachefs / quota.c
index 7e1f1828ab2074d503f3ce9b3d464e4e710d3c88..36de2f071d8000e8218745f8d7c926cfc0c778a5 100644 (file)
@@ -5,7 +5,7 @@
 #include "error.h"
 #include "inode.h"
 #include "quota.h"
-#include "subvolume.h"
+#include "snapshot.h"
 #include "super-io.h"
 
 static const char * const bch2_quota_types[] = {
@@ -60,7 +60,8 @@ const struct bch_sb_field_ops bch_sb_field_ops_quota = {
 };
 
 int bch2_quota_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                      unsigned flags, struct printbuf *err)
+                      enum bkey_invalid_flags flags,
+                      struct printbuf *err)
 {
        if (k.k->p.inode >= QTYP_NR) {
                prt_printf(err, "invalid quota type (%llu >= %u)",
@@ -480,13 +481,13 @@ static int __bch2_quota_set(struct bch_fs *c, struct bkey_s_c k,
                }
 
                if (qdq && qdq->d_fieldmask & QC_SPC_TIMER)
-                       mq->c[Q_SPC].timer      = cpu_to_le64(qdq->d_spc_timer);
+                       mq->c[Q_SPC].timer      = qdq->d_spc_timer;
                if (qdq && qdq->d_fieldmask & QC_SPC_WARNS)
-                       mq->c[Q_SPC].warns      = cpu_to_le64(qdq->d_spc_warns);
+                       mq->c[Q_SPC].warns      = qdq->d_spc_warns;
                if (qdq && qdq->d_fieldmask & QC_INO_TIMER)
-                       mq->c[Q_INO].timer      = cpu_to_le64(qdq->d_ino_timer);
+                       mq->c[Q_INO].timer      = qdq->d_ino_timer;
                if (qdq && qdq->d_fieldmask & QC_INO_WARNS)
-                       mq->c[Q_INO].warns      = cpu_to_le64(qdq->d_ino_warns);
+                       mq->c[Q_INO].warns      = qdq->d_ino_warns;
 
                mutex_unlock(&q->lock);
        }
@@ -561,7 +562,7 @@ static int bch2_fs_quota_read_inode(struct btree_trans *trans,
        int ret;
 
        ret = bch2_snapshot_tree_lookup(trans,
-                       snapshot_t(c, k.k->p.snapshot)->tree, &s_t);
+                       bch2_snapshot_tree(c, k.k->p.snapshot), &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);
@@ -571,7 +572,7 @@ static int bch2_fs_quota_read_inode(struct btree_trans *trans,
        if (!s_t.master_subvol)
                goto advance;
 
-       ret = bch2_inode_find_by_inum_trans(trans,
+       ret = bch2_inode_find_by_inum_nowarn_trans(trans,
                                (subvol_inum) {
                                        le32_to_cpu(s_t.master_subvol),
                                        k.k->p.offset,
@@ -598,7 +599,7 @@ advance:
 int bch2_fs_quota_read(struct bch_fs *c)
 {
        struct bch_sb_field_quota *sb_quota;
-       struct btree_trans trans;
+       struct btree_trans *trans;
        struct btree_iter iter;
        struct bkey_s_c k;
        int ret;
@@ -613,16 +614,16 @@ int bch2_fs_quota_read(struct bch_fs *c)
        bch2_sb_quota_read(c);
        mutex_unlock(&c->sb_lock);
 
-       bch2_trans_init(&trans, c, 0, 0);
+       trans = bch2_trans_get(c);
 
-       ret = for_each_btree_key2(&trans, iter, BTREE_ID_quotas,
+       ret = for_each_btree_key2(trans, iter, BTREE_ID_quotas,
                        POS_MIN, BTREE_ITER_PREFETCH, k,
                __bch2_quota_set(c, k, NULL)) ?:
-             for_each_btree_key2(&trans, iter, BTREE_ID_inodes,
+             for_each_btree_key2(trans, iter, BTREE_ID_inodes,
                        POS_MIN, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
-               bch2_fs_quota_read_inode(&trans, &iter, k));
+               bch2_fs_quota_read_inode(trans, &iter, k));
 
-       bch2_trans_exit(&trans);
+       bch2_trans_put(trans);
 
        if (ret)
                bch_err_fn(c, ret);
@@ -785,7 +786,6 @@ static int bch2_quota_set_info(struct super_block *sb, int type,
 {
        struct bch_fs *c = sb->s_fs_info;
        struct bch_sb_field_quota *sb_quota;
-       struct bch_memquota_type *q;
        int ret = 0;
 
        if (0) {
@@ -809,8 +809,6 @@ static int bch2_quota_set_info(struct super_block *sb, int type,
            ~(QC_SPC_TIMER|QC_INO_TIMER|QC_SPC_WARNS|QC_INO_WARNS))
                return -EINVAL;
 
-       q = &c->quotas[type];
-
        mutex_lock(&c->sb_lock);
        sb_quota = bch2_sb_get_or_create_quota(&c->disk_sb);
        if (!sb_quota) {
@@ -958,7 +956,7 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid,
        new_quota.k.p = POS(qid.type, from_kqid(&init_user_ns, qid));
 
        ret = bch2_trans_do(c, NULL, NULL, 0,
-                           bch2_set_quota_trans(&trans, &new_quota, qdq)) ?:
+                           bch2_set_quota_trans(trans, &new_quota, qdq)) ?:
                __bch2_quota_set(c, bkey_i_to_s_c(&new_quota.k_i), qdq);
 
        return bch2_err_class(ret);