A new approach for calculating FileStore::size is needed because this method is prone to lock contention and should not be called too often.
The steps to implement the approach are:
- reduce the lock surface of the size() method. This should be simple enough by creating a copy of the readers / writer inside the lock and do the actual size calculation on that snapshot but outside of the lock.
- lower size() visibility to package to avoid misuse (from monitoring tools)
- remove approximateSize and associated logic and replace it with size().