From: Artem Bityutskiy Date: Mon, 14 Jan 2013 14:35:13 +0000 (+0200) Subject: BmapCopy: fail if an optimization did not work X-Git-Tag: v2.0~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34c0521a56c52c9f131a084b2cf7877eeb28639d;p=tools%2Fbmap-tools.git BmapCopy: fail if an optimization did not work Instead of hiding failures when we are enabling optimizations - fail. This way we'll at least notice them. Change-Id: I683b14188b3181ee4d8bfcf8fca137cd0984e4b2 Signed-off-by: Artem Bityutskiy --- diff --git a/TODO b/TODO index 9431ab9..14d6556 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,2 @@ 4. Add a real man page to the project. -5. In block device optimizations - print a warning when something cannot be - done. Currently we ignore any kind of error and do not print anything. It is - better to know if something is not exactly as expected. 7. Add locking to all classes diff --git a/bmaptools/BmapCopy.py b/bmaptools/BmapCopy.py index e98a594..dbd2a07 100644 --- a/bmaptools/BmapCopy.py +++ b/bmaptools/BmapCopy.py @@ -521,9 +521,9 @@ class BmapBdevCopy(BmapCopy): contents = f_scheduler.read() f_scheduler.seek(0) f_scheduler.write("noop") - except IOError: - # No problem, this is just an optimization. - return + except IOError as err: + # No problem, this is just an optimization + raise Error("cannot enable the 'noop' I/O scheduler: %s" % err) # The file contains a list of scheduler with the current # scheduler in square brackets, e.g., "noop deadline [cfq]". @@ -539,8 +539,8 @@ class BmapBdevCopy(BmapCopy): self._old_max_ratio_value = f_ratio.read() f_ratio.seek(0) f_ratio.write("1") - except IOError: - return + except IOError as err: + raise Error("cannot set max. I/O ratio to '1': %s" % err) def _restore_bdev_settings(self): """ Restore old block device settings which we changed in @@ -550,16 +550,17 @@ class BmapBdevCopy(BmapCopy): try: with open(self._sysfs_scheduler_path, "w") as f_scheduler: f_scheduler.write(self._old_scheduler_value) - except IOError: - # No problem, this is just an optimization. - return + except IOError as err: + raise Error("cannot restore the '%s' I/O scheduler: %s" \ + % (self._old_scheduler_value, err)) if self._old_max_ratio_value is not None: try: with open(self._sysfs_max_ratio_path, "w") as f_ratio: f_ratio.write(self._old_max_ratio_value) - except IOError: - return + except IOError as err: + raise Error("cannot set the max. I/O ratio back to '%s': %s" \ + % (self._old_max_ratio_value, err)) def copy(self, sync = True, verify = True): """ The same as in the base class but tunes the block device for better