HDFS-5215. dfs.datanode.du.reserved is not considered while computing

available space ( Brahma Reddy Battula via Yongjun Zhang)

(cherry picked from commit 66763bb06f)
This commit is contained in:
Yongjun Zhang 2015-04-07 19:31:58 -07:00
parent 8d3657a577
commit b76c321e94
3 changed files with 18 additions and 7 deletions

View File

@ -106,6 +106,9 @@ Release 2.8.0 - UNRELEASED
HDFS-7916. 'reportBadBlocks' from datanodes to standby Node BPServiceActor HDFS-7916. 'reportBadBlocks' from datanodes to standby Node BPServiceActor
goes for infinite loop (vinayakumarb) goes for infinite loop (vinayakumarb)
HDFS-5215. dfs.datanode.du.reserved is not considered while computing
available space ( Brahma Reddy Battula via Yongjun Zhang)
Release 2.7.0 - UNRELEASED Release 2.7.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -2494,9 +2494,9 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
*/ */
private static class VolumeInfo { private static class VolumeInfo {
final String directory; final String directory;
final long usedSpace; final long usedSpace; // size of space used by HDFS
final long freeSpace; final long freeSpace; // size of free space excluding reserved space
final long reservedSpace; final long reservedSpace; // size of space reserved for non-HDFS and RBW
VolumeInfo(FsVolumeImpl v, long usedSpace, long freeSpace) { VolumeInfo(FsVolumeImpl v, long usedSpace, long freeSpace) {
this.directory = v.toString(); this.directory = v.toString();

View File

@ -305,9 +305,11 @@ public class FsVolumeImpl implements FsVolumeSpi {
} }
/** /**
* Calculate the capacity of the filesystem, after removing any * Return either the configured capacity of the file system if configured; or
* reserved capacity. * the capacity of the file system excluding space reserved for non-HDFS.
* @return the unreserved number of bytes left in this filesystem. May be zero. *
* @return the unreserved number of bytes left in this filesystem. May be
* zero.
*/ */
@VisibleForTesting @VisibleForTesting
public long getCapacity() { public long getCapacity() {
@ -329,10 +331,16 @@ public class FsVolumeImpl implements FsVolumeSpi {
this.configuredCapacity = capacity; this.configuredCapacity = capacity;
} }
/*
* Calculate the available space of the filesystem, excluding space reserved
* for non-HDFS and space reserved for RBW
*
* @return the available number of bytes left in this filesystem. May be zero.
*/
@Override @Override
public long getAvailable() throws IOException { public long getAvailable() throws IOException {
long remaining = getCapacity() - getDfsUsed() - reservedForRbw.get(); long remaining = getCapacity() - getDfsUsed() - reservedForRbw.get();
long available = usage.getAvailable(); long available = usage.getAvailable() - reserved - reservedForRbw.get();
if (remaining > available) { if (remaining > available) {
remaining = available; remaining = available;
} }