]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/quota.c
Update bcachefs sources to 1569db10e2 bcachefs: Use KEY_TYPE_deleted whitouts for...
[bcachefs-tools-debian] / libbcachefs / quota.c
index 6606e85cc8dec57048bc885f63778c5bf862f9ae..0fa6f33c049bca2849c803353dabb023820d2056 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 #include "bcachefs.h"
 #include "btree_update.h"
 #include "inode.h"
@@ -355,12 +356,15 @@ static int __bch2_quota_set(struct bch_fs *c, struct bkey_s_c k)
 
 static int bch2_quota_init_type(struct bch_fs *c, enum quota_types type)
 {
-       struct btree_iter iter;
+       struct btree_trans trans;
+       struct btree_iter *iter;
        struct bkey_s_c k;
        int ret = 0;
 
-       for_each_btree_key(&iter, c, BTREE_ID_QUOTAS, POS(type, 0),
-                          BTREE_ITER_PREFETCH, k) {
+       bch2_trans_init(&trans, c, 0, 0);
+
+       for_each_btree_key(&trans, iter, BTREE_ID_QUOTAS, POS(type, 0),
+                          BTREE_ITER_PREFETCH, k, ret) {
                if (k.k->p.inode != type)
                        break;
 
@@ -369,7 +373,7 @@ static int bch2_quota_init_type(struct bch_fs *c, enum quota_types type)
                        break;
        }
 
-       return bch2_btree_iter_unlock(&iter) ?: ret;
+       return bch2_trans_exit(&trans) ?: ret;
 }
 
 void bch2_fs_quota_exit(struct bch_fs *c)
@@ -413,7 +417,8 @@ int bch2_fs_quota_read(struct bch_fs *c)
 {
        unsigned i, qtypes = enabled_qtypes(c);
        struct bch_memquota_type *q;
-       struct btree_iter iter;
+       struct btree_trans trans;
+       struct btree_iter *iter;
        struct bch_inode_unpacked u;
        struct bkey_s_c k;
        int ret;
@@ -428,8 +433,10 @@ int bch2_fs_quota_read(struct bch_fs *c)
                        return ret;
        }
 
-       for_each_btree_key(&iter, c, BTREE_ID_INODES, POS_MIN,
-                          BTREE_ITER_PREFETCH, k) {
+       bch2_trans_init(&trans, c, 0, 0);
+
+       for_each_btree_key(&trans, iter, BTREE_ID_INODES, POS_MIN,
+                          BTREE_ITER_PREFETCH, k, ret) {
                switch (k.k->type) {
                case KEY_TYPE_inode:
                        ret = bch2_inode_unpack(bkey_s_c_to_inode(k), &u);
@@ -442,7 +449,7 @@ int bch2_fs_quota_read(struct bch_fs *c)
                                        KEY_TYPE_QUOTA_NOCHECK);
                }
        }
-       return bch2_btree_iter_unlock(&iter) ?: ret;
+       return bch2_trans_exit(&trans) ?: ret;
 }
 
 /* Enable/disable/delete quotas for an entire filesystem: */
@@ -451,7 +458,7 @@ static int bch2_quota_enable(struct super_block     *sb, unsigned uflags)
 {
        struct bch_fs *c = sb->s_fs_info;
 
-       if (sb->s_flags & MS_RDONLY)
+       if (sb->s_flags & SB_RDONLY)
                return -EROFS;
 
        /* Accounting must be enabled at mount time: */
@@ -488,7 +495,7 @@ static int bch2_quota_disable(struct super_block *sb, unsigned uflags)
 {
        struct bch_fs *c = sb->s_fs_info;
 
-       if (sb->s_flags & MS_RDONLY)
+       if (sb->s_flags & SB_RDONLY)
                return -EROFS;
 
        mutex_lock(&c->sb_lock);
@@ -512,7 +519,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
        struct bch_fs *c = sb->s_fs_info;
        int ret;
 
-       if (sb->s_flags & MS_RDONLY)
+       if (sb->s_flags & SB_RDONLY)
                return -EROFS;
 
        if (uflags & FS_USER_QUOTA) {
@@ -594,7 +601,7 @@ static int bch2_quota_set_info(struct super_block *sb, int type,
        struct bch_sb_field_quota *sb_quota;
        struct bch_memquota_type *q;
 
-       if (sb->s_flags & MS_RDONLY)
+       if (sb->s_flags & SB_RDONLY)
                return -EROFS;
 
        if (type >= QTYP_NR)
@@ -713,19 +720,19 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid,
        struct bkey_i_quota new_quota;
        int ret;
 
-       if (sb->s_flags & MS_RDONLY)
+       if (sb->s_flags & SB_RDONLY)
                return -EROFS;
 
        bkey_quota_init(&new_quota.k_i);
        new_quota.k.p = POS(qid.type, from_kqid(&init_user_ns, qid));
 
-       bch2_trans_init(&trans, c);
+       bch2_trans_init(&trans, c, 0, 0);
 
        iter = bch2_trans_get_iter(&trans, BTREE_ID_QUOTAS, new_quota.k.p,
                                   BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
        k = bch2_btree_iter_peek_slot(iter);
 
-       ret = btree_iter_err(k);
+       ret = bkey_err(k);
        if (unlikely(ret))
                return ret;
 
@@ -745,7 +752,7 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid,
        if (qdq->d_fieldmask & QC_INO_HARD)
                new_quota.v.c[Q_INO].hardlimit = cpu_to_le64(qdq->d_ino_hardlimit);
 
-       bch2_trans_update(&trans, BTREE_INSERT_ENTRY(iter, &new_quota.k_i));
+       bch2_trans_update(&trans, iter, &new_quota.k_i);
 
        ret = bch2_trans_commit(&trans, NULL, NULL, 0);