BmapCopy: add a couple of debug messages
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 24 Sep 2013 10:17:30 +0000 (13:17 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 30 Sep 2013 07:10:04 +0000 (10:10 +0300)
Add a couple of useful debug messages to BmapCopy.

Also, do not print the progress indicator when debugging is on.

Change-Id: I38aca82e3f7f9704f827f72e6d702b0c65d26b24
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptool
bmaptools/BmapCopy.py

index 73c226e9f00aef1542a988b6d62ec1f67005c250..e4df75e65872c8a6859f8a9f0a8609b7eab0f239 100755 (executable)
--- a/bmaptool
+++ b/bmaptool
@@ -443,7 +443,7 @@ def copy_command(args, log):
         raise SystemExit(1)
 
     # Print the progress indicator while copying
-    if not args.quiet:
+    if not args.quiet and not args.debug:
         writer.set_progress_indicator(sys.stderr, "bmaptool: info: %d%% copied")
 
     start_time = time.time()
index 88bdeca34f9fc9de1519b2d83c081fca97ec3c97..fe8897c552e4a60318baf66312b4abe3470a6e45 100644 (file)
@@ -347,12 +347,18 @@ class BmapCopy:
         the 'progress_file' attribute.
         """
 
+        if self.mapped_cnt:
+            assert blocks_written <= self.mapped_cnt
+            percent = int((float(blocks_written) / self.mapped_cnt) * 100)
+            self._log.debug("wrote %d blocks out of %d (%d%%)" %
+                            (blocks_written, self.mapped_cnt, percent))
+        else:
+            self._log.debug("wrote %d blocks" % blocks_written)
+
         if not self._progress_file:
             return
 
         if self.mapped_cnt:
-            assert blocks_written <= self.mapped_cnt
-            percent = int((float(blocks_written) / self.mapped_cnt) * 100)
             progress = '\r' + self._progress_format % percent + '\n'
         else:
             # Do not rotate the wheel too fast
@@ -491,6 +497,9 @@ class BmapCopy:
                         hash_obj.update(buf)
 
                     blocks = (len(buf) + self.block_size - 1) / self.block_size
+                    self._log.debug("queueing %d blocks, queue length is %d" %
+                                    (blocks, self._batch_queue.qsize()))
+
                     self._batch_queue.put(("range", start, start + blocks - 1,
                                            buf))