def limit_es(expected_mb):
    """Protection against creating too small or too large chunks."""

    if expected_mb < 1:        # < 1 MB
        expected_mb = 1
    elif expected_mb > 10**7:  # > 10 TB
        expected_mb = 10**7
    return expected_mb