|
@@ -873,8 +873,18 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
counts.addContent(Content.FILE, 1);
|
|
|
final long fileLen = computeFileSize(snapshotId);
|
|
|
counts.addContent(Content.LENGTH, fileLen);
|
|
|
- counts.addContent(Content.DISKSPACE, storagespaceConsumed(null)
|
|
|
- .getStorageSpace());
|
|
|
+
|
|
|
+ FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
|
|
|
+ if (sf == null) {
|
|
|
+ counts.addContent(Content.DISKSPACE,
|
|
|
+ storagespaceConsumed(null).getStorageSpace());
|
|
|
+ } else if (isStriped()) {
|
|
|
+ counts.addContent(Content.DISKSPACE,
|
|
|
+ storagespaceConsumedStriped().getStorageSpace());
|
|
|
+ } else {
|
|
|
+ long diskSpaceQuota = getDiskSpaceQuota(counts, sf, snapshotId);
|
|
|
+ counts.addContent(Content.DISKSPACE, diskSpaceQuota);
|
|
|
+ }
|
|
|
|
|
|
if (getStoragePolicyID() != BLOCK_STORAGE_POLICY_ID_UNSPECIFIED){
|
|
|
BlockStoragePolicy bsp = summary.getBlockStoragePolicySuite().
|
|
@@ -890,6 +900,34 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
return summary;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Compute disk space consumed by all the blocks in snapshots.
|
|
|
+ */
|
|
|
+ private long getDiskSpaceQuota(ContentCounts counts,
|
|
|
+ FileWithSnapshotFeature sf, int lastSnapshotId) {
|
|
|
+ FileDiffList fileDiffList = sf.getDiffs();
|
|
|
+ int last = fileDiffList.getLastSnapshotId();
|
|
|
+
|
|
|
+ if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
|
|
|
+ || last == Snapshot.CURRENT_STATE_ID) {
|
|
|
+ return storagespaceConsumed(null).getStorageSpace();
|
|
|
+ }
|
|
|
+
|
|
|
+ final long ssDeltaNoReplication;
|
|
|
+ short replication;
|
|
|
+
|
|
|
+ if (last < lastSnapshotId) {
|
|
|
+ ssDeltaNoReplication = computeFileSize(true, false);
|
|
|
+ replication = getFileReplication();
|
|
|
+ } else {
|
|
|
+ int sid = fileDiffList.getSnapshotById(lastSnapshotId);
|
|
|
+ ssDeltaNoReplication = computeFileSize(sid);
|
|
|
+ replication = getFileReplication(sid);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ssDeltaNoReplication * replication;
|
|
|
+ }
|
|
|
+
|
|
|
/** The same as computeFileSize(null). */
|
|
|
public final long computeFileSize() {
|
|
|
return computeFileSize(CURRENT_STATE_ID);
|