]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/buckets.c
Update bcachefs sources to 7227ff07f14b Merge pull request #10 from modelrockettier...
[bcachefs-tools-debian] / libbcachefs / buckets.c
index 15a07e36d5cb72e57540884396b3e2a34096e254..c68683ebd4c079db8ea2f20ec71e3c691d8d4e6a 100644 (file)
@@ -338,12 +338,17 @@ void bch2_fs_usage_apply(struct bch_fs *c,
 {
        struct fs_usage_sum sum = __fs_usage_sum(*stats);
        s64 added = sum.data + sum.reserved;
+       s64 should_not_have_added;
 
        /*
         * Not allowed to reduce sectors_available except by getting a
         * reservation:
         */
-       BUG_ON(added > (s64) (disk_res ? disk_res->sectors : 0));
+       should_not_have_added = added - (s64) (disk_res ? disk_res->sectors : 0);
+       if (WARN_ON(should_not_have_added > 0)) {
+               atomic64_sub(should_not_have_added, &c->sectors_available);
+               added -= should_not_have_added;
+       }
 
        if (added > 0) {
                disk_res->sectors       -= added;
@@ -661,7 +666,7 @@ static void bch2_mark_extent(struct bch_fs *c, struct bkey_s_c k,
                        stats->replicas
                                [!p.ptr.cached && replicas ? replicas - 1 : 0].data
                                [!p.ptr.cached ? data_type : BCH_DATA_CACHED] +=
-                                       sectors;
+                                       disk_sectors;
 
                        bch2_mark_pointer(c, e, p, disk_sectors, data_type,
                                          stats, journal_seq, flags);