From 05f409e747477a12bc701d304bc6dabe6939a3a4 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 11 Jun 2013 17:50:37 -0700 Subject: [PATCH] Fix the after subscription size checks. It seems like the calculation was incorrect previously. Fixes bug: #1190094 Change-Id: Iaec3c2ece6fc80e6bb87fde0a408608825212b49 --- cinder/volume/drivers/nfs.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index 96d18874e..e018b28c5 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -350,6 +350,8 @@ class NfsDriver(RemoteFsDriver): for nfs_share in self._mounted_shares: total_size, total_available, total_allocated = \ self._get_capacity_info(nfs_share) + apparent_size = max(0, total_size * oversub_ratio) + apparent_available = max(0, apparent_size - total_allocated) used = (total_size - total_available) / total_size if used > used_ratio: # NOTE(morganfainberg): We check the used_ratio first since @@ -359,17 +361,9 @@ class NfsDriver(RemoteFsDriver): # target. LOG.debug(_('%s is above nfs_used_ratio'), nfs_share) continue - if oversub_ratio >= 1.0: - # NOTE(morganfainberg): If we are setup for oversubscription - # we need to calculate the apparent available space instead - # of just using the _actual_ available space. - if (total_allocated * oversub_ratio) < requested_volume_size: - LOG.debug(_('%s is above nfs_oversub_ratio'), nfs_share) - continue - elif total_allocated <= requested_volume_size: + if apparent_available <= requested_volume_size: LOG.debug(_('%s is above nfs_oversub_ratio'), nfs_share) continue - if total_allocated / total_size >= oversub_ratio: LOG.debug(_('%s reserved space is above nfs_oversub_ratio'), nfs_share) -- 2.45.2