Patchwork [RFC,V1,06/12] block: Add bdrv_pause_dedup.

login
register
mail settings
Submitter Benoît Canet
Date Jan. 16, 2013, 4:25 p.m.
Message ID <1358353518-5421-7-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/212865/
State New
Headers show

Comments

Benoît Canet - Jan. 16, 2013, 4:25 p.m.
---
 block.c               |   19 +++++++++++++++++++
 include/block/block.h |    1 +
 2 files changed, 20 insertions(+)

Patch

diff --git a/block.c b/block.c
index 4e80da8..8c527b6 100644
--- a/block.c
+++ b/block.c
@@ -4380,6 +4380,25 @@  int bdrv_resume_dedup(BlockDriverState *bs)
     return 0;
 }
 
+int bdrv_pause_dedup(BlockDriverState *bs)
+{
+    BlockDriver *drv = bs->drv;
+
+    if (!bdrv_has_dedup(bs)) {
+        return -EINVAL;
+    }
+
+    if (!bdrv_is_dedup_running(bs)) {
+        return 0;
+    }
+
+    if (drv && drv->bdrv_pause_dedup) {
+        drv->bdrv_pause_dedup(bs);
+    }
+
+    return 0;
+}
+
 /* needed for generic scsi interface */
 
 int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
diff --git a/include/block/block.h b/include/block/block.h
index 94ac50a..1328a27 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -309,6 +309,7 @@  void bdrv_lock_medium(BlockDriverState *bs, bool locked);
 bool bdrv_has_dedup(BlockDriverState *bs);
 bool bdrv_is_dedup_running(BlockDriverState *bs);
 int bdrv_resume_dedup(BlockDriverState *bs);
+int bdrv_pause_dedup(BlockDriverState *bs);
 void bdrv_eject(BlockDriverState *bs, bool eject_flag);
 const char *bdrv_get_format_name(BlockDriverState *bs);
 BlockDriverState *bdrv_find(const char *name);