BmapCopy: fail if an optimization did not work
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 14 Jan 2013 14:35:13 +0000 (16:35 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 14 Jan 2013 14:42:24 +0000 (16:42 +0200)
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 <artem.bityutskiy@intel.com>
TODO
bmaptools/BmapCopy.py

diff --git a/TODO b/TODO
index 9431ab9..14d6556 100644 (file)
--- 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
index e98a594..dbd2a07 100644 (file)
@@ -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