]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/alloc_foreground.c
Update bcachefs sources to 24c6361e20 bcachefs: Fix a trans path overflow in bch2_btr...
[bcachefs-tools-debian] / libbcachefs / alloc_foreground.c
index dce227c54a7ed980416ce0d5490adee010be8c4f..ce365fec7f4129ed45089d06d461c1f7ff873677 100644 (file)
@@ -268,7 +268,6 @@ static struct open_bucket *__try_alloc_bucket(struct bch_fs *c, struct bch_dev *
 
        spin_unlock(&c->freelist_lock);
 
-       trace_and_count(c, bucket_alloc, ca, bch2_alloc_reserves[reserve]);
        return ob;
 }
 
@@ -575,7 +574,10 @@ err:
        if (!ob)
                ob = ERR_PTR(-BCH_ERR_no_buckets_found);
 
-       if (IS_ERR(ob))
+       if (!IS_ERR(ob))
+               trace_and_count(c, bucket_alloc, ca, bch2_alloc_reserves[reserve],
+                               may_alloc_partial, ob->bucket);
+       else
                trace_and_count(c, bucket_alloc_fail,
                                ca, bch2_alloc_reserves[reserve],
                                usage.d[BCH_DATA_free].buckets,
@@ -1223,7 +1225,9 @@ err:
 
        if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty) ||
            bch2_err_matches(ret, BCH_ERR_freelist_empty))
-               return cl ? ERR_PTR(-EAGAIN) : ERR_PTR(-ENOSPC);
+               return cl
+                       ? ERR_PTR(-EAGAIN)
+                       : ERR_PTR(-BCH_ERR_ENOSPC_bucket_alloc);
 
        if (bch2_err_matches(ret, BCH_ERR_insufficient_devices))
                return ERR_PTR(-EROFS);