]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/quota.c
Update bcachefs sources to 1a739db0b256 bcachefs; guard against overflow in btree...
[bcachefs-tools-debian] / libbcachefs / quota.c
index 79724a7aaab094184d1fe1cd1fe74b58c3f86635..e68b34eab90a912a55727b1da0428b3655cb3834 100644 (file)
@@ -599,14 +599,9 @@ advance:
 
 int bch2_fs_quota_read(struct bch_fs *c)
 {
-       struct bch_sb_field_quota *sb_quota;
-       struct btree_trans *trans;
-       struct btree_iter iter;
-       struct bkey_s_c k;
-       int ret;
 
        mutex_lock(&c->sb_lock);
-       sb_quota = bch2_sb_get_or_create_quota(&c->disk_sb);
+       struct bch_sb_field_quota *sb_quota = bch2_sb_get_or_create_quota(&c->disk_sb);
        if (!sb_quota) {
                mutex_unlock(&c->sb_lock);
                return -BCH_ERR_ENOSPC_sb_quota;
@@ -615,19 +610,14 @@ int bch2_fs_quota_read(struct bch_fs *c)
        bch2_sb_quota_read(c);
        mutex_unlock(&c->sb_lock);
 
-       trans = bch2_trans_get(c);
-
-       ret = for_each_btree_key(trans, iter, BTREE_ID_quotas, POS_MIN,
-                                BTREE_ITER_PREFETCH, k,
-               __bch2_quota_set(c, k, NULL)) ?:
-             for_each_btree_key(trans, iter, BTREE_ID_inodes, POS_MIN,
-                                BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
-               bch2_fs_quota_read_inode(trans, &iter, k));
-
-       bch2_trans_put(trans);
-
-       if (ret)
-               bch_err_fn(c, ret);
+       int ret = bch2_trans_run(c,
+               for_each_btree_key(trans, iter, BTREE_ID_quotas, POS_MIN,
+                                  BTREE_ITER_PREFETCH, k,
+                       __bch2_quota_set(c, k, NULL)) ?:
+               for_each_btree_key(trans, iter, BTREE_ID_inodes, POS_MIN,
+                                  BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
+                       bch2_fs_quota_read_inode(trans, &iter, k)));
+       bch_err_fn(c, ret);
        return ret;
 }