]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix the after subscription size checks.
authorJoshua Harlow <harlowja@yahoo-inc.com>
Wed, 12 Jun 2013 00:50:37 +0000 (17:50 -0700)
committerJoshua Harlow <harlowja@yahoo-inc.com>
Wed, 12 Jun 2013 01:12:57 +0000 (18:12 -0700)
It seems like the calculation was incorrect previously.

Fixes bug: #1190094

Change-Id: Iaec3c2ece6fc80e6bb87fde0a408608825212b49

cinder/volume/drivers/nfs.py

index 96d18874e879c6fe87183997f739a82ae858df5f..e018b28c5e0809df2a6216e0244ca8ca0f9d01b2 100644 (file)
@@ -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)