'Get hashes for each suffix dir in a partition.  do_listdir causes it to
mistrust the hash cache for suffix existence at the (unexpectedly high)
cost of a listdir.
:param device: name of target device
:param partition: partition on the device in which the object lives
:param policy: the StoragePolicy instance
:param recalculate: list of suffixes which should be recalculated when
got
:param do_listdir: force existence check for all hashes in the
partition
:returns: tuple of (number of suffix dirs hashed, dictionary of hashes)'

def __get_hashes(self, device, partition, policy, recalculate=None, do_listdir=False):

    hashed = 0
    dev_path = self.get_dev_path(device)
    partition_path = get_part_path(dev_path, policy, partition)
    hashes_file = join(partition_path, HASH_FILE)
    modified = False
    orig_hashes = {'valid': False}
    if (recalculate is None):
        recalculate = []
    try:
        orig_hashes = self.consolidate_hashes(partition_path)
    except Exception:
        self.logger.warning('Unable    to    read    %r', hashes_file, exc_info=True)
    if (not orig_hashes['valid']):
        do_listdir = True
        hashes = {'valid': True}
        orig_hashes = read_hashes(partition_path)
    else:
        hashes = copy.deepcopy(orig_hashes)
    if do_listdir:
        for suff in os.listdir(partition_path):
            if (len(suff) == 3):
                hashes.setdefault(suff, None)
        modified = True
        self.logger.debug('Run    listdir    on    %s', partition_path)
    hashes.update(((suffix, None) for suffix in recalculate))
    for (suffix, hash_) in hashes.items():
        if (not hash_):
            suffix_dir = join(partition_path, suffix)
            try:
                hashes[suffix] = self._hash_suffix(suffix_dir)
                hashed += 1
            except PathNotDir:
                del hashes[suffix]
            except OSError:
                logging.exception(_('Error    hashing    suffix'))
            modified = True
    if modified:
        with lock_path(partition_path):
            if (read_hashes(partition_path) == orig_hashes):
                write_hashes(partition_path, hashes)
                return (hashed, hashes)
        return self.__get_hashes(device, partition, policy, recalculate=recalculate, do_listdir=do_listdir)
    else:
        return (hashed, hashes)
