@@ -724,9 +724,7 @@ static int __trigger_extent(struct btree_trans *trans,
724
724
.replicas .nr_required = 1 ,
725
725
};
726
726
727
- struct disk_accounting_pos acct_compression_key = {
728
- .type = BCH_DISK_ACCOUNTING_compression ,
729
- };
727
+ unsigned cur_compression_type = 0 ;
730
728
u64 compression_acct [3 ] = { 1 , 0 , 0 };
731
729
732
730
bkey_for_each_ptr_decode (k .k , ptrs , p , entry ) {
@@ -760,13 +758,13 @@ static int __trigger_extent(struct btree_trans *trans,
760
758
acc_replicas_key .replicas .nr_required = 0 ;
761
759
}
762
760
763
- if (acct_compression_key . compression . type &&
764
- acct_compression_key . compression . type != p .crc .compression_type ) {
761
+ if (cur_compression_type &&
762
+ cur_compression_type != p .crc .compression_type ) {
765
763
if (flags & BTREE_TRIGGER_overwrite )
766
764
bch2_u64s_neg (compression_acct , ARRAY_SIZE (compression_acct ));
767
765
768
- ret = bch2_disk_accounting_mod (trans , & acct_compression_key , compression_acct ,
769
- ARRAY_SIZE ( compression_acct ), gc );
766
+ ret = bch2_disk_accounting_mod2 (trans , gc , compression_acct ,
767
+ compression , cur_compression_type );
770
768
if (ret )
771
769
return ret ;
772
770
@@ -775,7 +773,7 @@ static int __trigger_extent(struct btree_trans *trans,
775
773
compression_acct [2 ] = 0 ;
776
774
}
777
775
778
- acct_compression_key . compression . type = p .crc .compression_type ;
776
+ cur_compression_type = p .crc .compression_type ;
779
777
if (p .crc .compression_type ) {
780
778
compression_acct [1 ] += p .crc .uncompressed_size ;
781
779
compression_acct [2 ] += p .crc .compressed_size ;
@@ -789,45 +787,34 @@ static int __trigger_extent(struct btree_trans *trans,
789
787
}
790
788
791
789
if (acc_replicas_key .replicas .nr_devs && !level && k .k -> p .snapshot ) {
792
- struct disk_accounting_pos acc_snapshot_key = {
793
- .type = BCH_DISK_ACCOUNTING_snapshot ,
794
- .snapshot .id = k .k -> p .snapshot ,
795
- };
796
- ret = bch2_disk_accounting_mod (trans , & acc_snapshot_key , replicas_sectors , 1 , gc );
790
+ ret = bch2_disk_accounting_mod2_nr (trans , gc , replicas_sectors , 1 , snapshot , k .k -> p .snapshot );
797
791
if (ret )
798
792
return ret ;
799
793
}
800
794
801
- if (acct_compression_key . compression . type ) {
795
+ if (cur_compression_type ) {
802
796
if (flags & BTREE_TRIGGER_overwrite )
803
797
bch2_u64s_neg (compression_acct , ARRAY_SIZE (compression_acct ));
804
798
805
- ret = bch2_disk_accounting_mod (trans , & acct_compression_key , compression_acct ,
806
- ARRAY_SIZE ( compression_acct ), gc );
799
+ ret = bch2_disk_accounting_mod2 (trans , gc , compression_acct ,
800
+ compression , cur_compression_type );
807
801
if (ret )
808
802
return ret ;
809
803
}
810
804
811
805
if (level ) {
812
- struct disk_accounting_pos acc_btree_key = {
813
- .type = BCH_DISK_ACCOUNTING_btree ,
814
- .btree .id = btree_id ,
815
- };
816
- ret = bch2_disk_accounting_mod (trans , & acc_btree_key , replicas_sectors , 1 , gc );
806
+ ret = bch2_disk_accounting_mod2_nr (trans , gc , replicas_sectors , 1 , btree , btree_id );
817
807
if (ret )
818
808
return ret ;
819
809
} else {
820
810
bool insert = !(flags & BTREE_TRIGGER_overwrite );
821
- struct disk_accounting_pos acc_inum_key = {
822
- .type = BCH_DISK_ACCOUNTING_inum ,
823
- .inum .inum = k .k -> p .inode ,
824
- };
811
+
825
812
s64 v [3 ] = {
826
813
insert ? 1 : -1 ,
827
814
insert ? k .k -> size : - ((s64 ) k .k -> size ),
828
815
* replicas_sectors ,
829
816
};
830
- ret = bch2_disk_accounting_mod (trans , & acc_inum_key , v , ARRAY_SIZE ( v ), gc );
817
+ ret = bch2_disk_accounting_mod2 (trans , gc , v , inum , k . k -> p . inode );
831
818
if (ret )
832
819
return ret ;
833
820
}
@@ -876,15 +863,15 @@ int bch2_trigger_extent(struct btree_trans *trans,
876
863
}
877
864
878
865
int need_rebalance_delta = 0 ;
879
- s64 need_rebalance_sectors_delta = 0 ;
866
+ s64 need_rebalance_sectors_delta [ 1 ] = { 0 } ;
880
867
881
868
s64 s = bch2_bkey_sectors_need_rebalance (c , old );
882
869
need_rebalance_delta -= s != 0 ;
883
- need_rebalance_sectors_delta -= s ;
870
+ need_rebalance_sectors_delta [ 0 ] -= s ;
884
871
885
872
s = bch2_bkey_sectors_need_rebalance (c , new .s_c );
886
873
need_rebalance_delta += s != 0 ;
887
- need_rebalance_sectors_delta += s ;
874
+ need_rebalance_sectors_delta [ 0 ] += s ;
888
875
889
876
if ((flags & BTREE_TRIGGER_transactional ) && need_rebalance_delta ) {
890
877
int ret = bch2_btree_bit_mod_buffered (trans , BTREE_ID_rebalance_work ,
@@ -893,12 +880,9 @@ int bch2_trigger_extent(struct btree_trans *trans,
893
880
return ret ;
894
881
}
895
882
896
- if (need_rebalance_sectors_delta ) {
897
- struct disk_accounting_pos acc = {
898
- .type = BCH_DISK_ACCOUNTING_rebalance_work ,
899
- };
900
- int ret = bch2_disk_accounting_mod (trans , & acc , & need_rebalance_sectors_delta , 1 ,
901
- flags & BTREE_TRIGGER_gc );
883
+ if (need_rebalance_sectors_delta [0 ]) {
884
+ int ret = bch2_disk_accounting_mod2 (trans , flags & BTREE_TRIGGER_gc ,
885
+ need_rebalance_sectors_delta , rebalance_work );
902
886
if (ret )
903
887
return ret ;
904
888
}
@@ -914,17 +898,13 @@ static int __trigger_reservation(struct btree_trans *trans,
914
898
enum btree_iter_update_trigger_flags flags )
915
899
{
916
900
if (flags & (BTREE_TRIGGER_transactional |BTREE_TRIGGER_gc )) {
917
- s64 sectors = k .k -> size ;
901
+ s64 sectors [ 1 ] = { k .k -> size } ;
918
902
919
903
if (flags & BTREE_TRIGGER_overwrite )
920
- sectors = - sectors ;
921
-
922
- struct disk_accounting_pos acc = {
923
- .type = BCH_DISK_ACCOUNTING_persistent_reserved ,
924
- .persistent_reserved .nr_replicas = bkey_s_c_to_reservation (k ).v -> nr_replicas ,
925
- };
904
+ sectors [0 ] = - sectors [0 ];
926
905
927
- return bch2_disk_accounting_mod (trans , & acc , & sectors , 1 , flags & BTREE_TRIGGER_gc );
906
+ return bch2_disk_accounting_mod2 (trans , flags & BTREE_TRIGGER_gc , sectors ,
907
+ persistent_reserved , bkey_s_c_to_reservation (k ).v -> nr_replicas );
928
908
}
929
909
930
910
return 0 ;
0 commit comments