Jelajahi Sumber

block/qcow2-refcount: add trace-point to qcow2_process_discards

Let's at least trace ignored failure.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Vladimir Sementsov-Ogievskiy 6 tahun lalu
induk
melakukan
1477b6c803
2 mengubah file dengan 9 tambahan dan 1 penghapusan
  1. 6 1
      block/qcow2-refcount.c
  2. 3 0
      block/trace-events

+ 6 - 1
block/qcow2-refcount.c

@@ -29,6 +29,7 @@
 #include "qemu/range.h"
 #include "qemu/range.h"
 #include "qemu/bswap.h"
 #include "qemu/bswap.h"
 #include "qemu/cutils.h"
 #include "qemu/cutils.h"
+#include "trace.h"
 
 
 static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size,
 static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size,
                                     uint64_t max);
                                     uint64_t max);
@@ -737,7 +738,11 @@ void qcow2_process_discards(BlockDriverState *bs, int ret)
 
 
         /* Discard is optional, ignore the return value */
         /* Discard is optional, ignore the return value */
         if (ret >= 0) {
         if (ret >= 0) {
-            bdrv_pdiscard(bs->file, d->offset, d->bytes);
+            int r2 = bdrv_pdiscard(bs->file, d->offset, d->bytes);
+            if (r2 < 0) {
+                trace_qcow2_process_discards_failed_region(d->offset, d->bytes,
+                                                           r2);
+            }
         }
         }
 
 
         g_free(d);
         g_free(d);

+ 3 - 0
block/trace-events

@@ -92,6 +92,9 @@ qcow2_cache_get_done(void *co, int c, int i) "co %p is_l2_cache %d index %d"
 qcow2_cache_flush(void *co, int c) "co %p is_l2_cache %d"
 qcow2_cache_flush(void *co, int c) "co %p is_l2_cache %d"
 qcow2_cache_entry_flush(void *co, int c, int i) "co %p is_l2_cache %d index %d"
 qcow2_cache_entry_flush(void *co, int c, int i) "co %p is_l2_cache %d index %d"
 
 
+# qcow2-refcount.c
+qcow2_process_discards_failed_region(uint64_t offset, uint64_t bytes, int ret) "offset 0x%" PRIx64 " bytes 0x%" PRIx64 " ret %d"
+
 # qed-l2-cache.c
 # qed-l2-cache.c
 qed_alloc_l2_cache_entry(void *l2_cache, void *entry) "l2_cache %p entry %p"
 qed_alloc_l2_cache_entry(void *l2_cache, void *entry) "l2_cache %p entry %p"
 qed_unref_l2_cache_entry(void *entry, int ref) "entry %p ref %d"
 qed_unref_l2_cache_entry(void *entry, int ref) "entry %p ref %d"