From 0caf64850b93a82f06124a9af90a8afd83932262 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 24 Oct 2007 13:24:02 +0000 Subject: [PATCH] Improve out-of-minors handling Currently, the out-of-minors handling is not very good: though both MD and DRBD functions for finding an unused minor can return None, only the DRBD code checks for this case. This patch improves this by making the functions _FindUnusedMinor raise an error instead of None, and gets rid of the one manual check for the return value. Reviewed-by: imsnah --- lib/bdev.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/bdev.py b/lib/bdev.py index 7578d09ec..e706772c2 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -595,7 +595,7 @@ class MDRaid1(BlockDev): i += 1 if i == 256: logger.Error("Critical: Out of md minor numbers.") - return None + raise errors.BlockDeviceError("Can't find a free MD minor") return i @@ -1022,8 +1022,7 @@ class DRBDev(BaseDRBD): if match: return int(match.group(1)) logger.Error("Error: no free drbd minors!") - return None - + raise errors.BlockDeviceError("Can't find a free DRBD minor") @classmethod def _GetDevInfo(cls, minor): @@ -1296,8 +1295,6 @@ class DRBDev(BaseDRBD): return result minor = self._FindUnusedMinor() - if minor is None: - raise errors.BlockDeviceError("Not enough free minors for DRBD!") need_localdev_teardown = False if self._children[0]: result = self._AssembleLocal(minor, self._children[0].dev_path, -- GitLab