[RFC] JDK-8162520: (fs) FileStore should support file stores with > Long.MAX_VALUE capacity
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Sep 27 21:02:41 UTC 2019
Hello,
There appear to be several ways to approach this problem and I would like to solicit comments and suggestions. In all cases, as suggested in a comment on the issue [1], the extant FileStore.get*Space() methods should probably return a specific value to indicate overflow, e.g., Long.MAX_VALUE, Long.MIN_VALUE, or simply any negative value.
Here are some possibilities for APIs:
1. Return the number of blocks of each type
long getTotalBlocks();
long getUnallocatedBlocks();
long getUsableBlocks();
The respective sizes in whichever units can then be computed by the caller using the value returned by getBlockSize().
2. Return size in specified units
An enum or something:
SizeUnit {BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES}
// return value: long[] ret = new long[2]
// unitSize = number of bytes per unit
// ret[0] = count of the number of units: bytes / unitSize
// ret[1] = remainder: size % unitSize
// exception: size / unitSize > Long.MAX_VALUE
long[] getTotalSpace(SizeUnit);
long[] getUnallocatedSpace(SizeUnit);
long[] getUsableSpace(SizeUnit);
3. Return the size in bytes as a split 128-bit integer
// return value: long[] ret = new long[2]
// ret[0] = Math.multiplyHigh(f_bsize, n_blocks)
// ret[1] = f_bsize * n_blocks
// n_blocks in {f_blocks, f_bfree, f_bavail}
long[] getTotalBytes();
long[] getFreeBytes();
long[] getAvailableBytes();
4. Return the size as bytes via a BigInteger
// returns f_bsize * f_blocks
BigInteger getTotalBytes();
// returns f_bsize * f_bfree
BigInteger getFreeBytes();
// returns f_bsize * f_bavail
BigInteger getAvailableBytes();
Also, I did not find any native APIs for obtaining sizes which specifically addressed large capacity volumes.
Thanks,
Brian
[1] https://bugs.openjdk.java.net/browse/JDK-8162520
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190927/fb36b6bb/attachment.html>
More information about the nio-dev
mailing list