@@ -873,8 +873,18 @@ public final ContentSummaryComputationContext computeContentSummary(
873
873
counts .addContent (Content .FILE , 1 );
874
874
final long fileLen = computeFileSize (snapshotId );
875
875
counts .addContent (Content .LENGTH , fileLen );
876
- counts .addContent (Content .DISKSPACE , storagespaceConsumed (null )
877
- .getStorageSpace ());
876
+
877
+ FileWithSnapshotFeature sf = getFileWithSnapshotFeature ();
878
+ if (sf == null ) {
879
+ counts .addContent (Content .DISKSPACE ,
880
+ storagespaceConsumed (null ).getStorageSpace ());
881
+ } else if (isStriped ()) {
882
+ counts .addContent (Content .DISKSPACE ,
883
+ storagespaceConsumedStriped ().getStorageSpace ());
884
+ } else {
885
+ long diskSpaceQuota = getDiskSpaceQuota (counts , sf , snapshotId );
886
+ counts .addContent (Content .DISKSPACE , diskSpaceQuota );
887
+ }
878
888
879
889
if (getStoragePolicyID () != BLOCK_STORAGE_POLICY_ID_UNSPECIFIED ){
880
890
BlockStoragePolicy bsp = summary .getBlockStoragePolicySuite ().
@@ -890,6 +900,34 @@ public final ContentSummaryComputationContext computeContentSummary(
890
900
return summary ;
891
901
}
892
902
903
+ /**
904
+ * Compute disk space consumed by all the blocks in snapshots.
905
+ */
906
+ private long getDiskSpaceQuota (ContentCounts counts ,
907
+ FileWithSnapshotFeature sf , int lastSnapshotId ) {
908
+ FileDiffList fileDiffList = sf .getDiffs ();
909
+ int last = fileDiffList .getLastSnapshotId ();
910
+
911
+ if (lastSnapshotId == Snapshot .CURRENT_STATE_ID
912
+ || last == Snapshot .CURRENT_STATE_ID ) {
913
+ return storagespaceConsumed (null ).getStorageSpace ();
914
+ }
915
+
916
+ final long ssDeltaNoReplication ;
917
+ short replication ;
918
+
919
+ if (last < lastSnapshotId ) {
920
+ ssDeltaNoReplication = computeFileSize (true , false );
921
+ replication = getFileReplication ();
922
+ } else {
923
+ int sid = fileDiffList .getSnapshotById (lastSnapshotId );
924
+ ssDeltaNoReplication = computeFileSize (sid );
925
+ replication = getFileReplication (sid );
926
+ }
927
+
928
+ return ssDeltaNoReplication * replication ;
929
+ }
930
+
893
931
/** The same as computeFileSize(null). */
894
932
public final long computeFileSize () {
895
933
return computeFileSize (CURRENT_STATE_ID );
0 commit comments