All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 34/43] block: Move bdrv_commit() to block/commit.c
Date: Tue,  5 Jul 2016 17:50:43 +0200	[thread overview]
Message-ID: <1467733852-27097-35-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1467733852-27097-1-git-send-email-kwolf@redhat.com>

No code changes, just moved from one file to another.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block.c             | 110 ---------------------------------------------------
 block/Makefile.objs |   3 +-
 block/commit.c      | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/block.c b/block.c
index 947df29..7603a0b 100644
--- a/block.c
+++ b/block.c
@@ -2322,116 +2322,6 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix)
     return bs->drv->bdrv_check(bs, res, fix);
 }
 
-#define COMMIT_BUF_SECTORS 2048
-
-/* commit COW file into the raw image */
-int bdrv_commit(BlockDriverState *bs)
-{
-    BlockDriver *drv = bs->drv;
-    int64_t sector, total_sectors, length, backing_length;
-    int n, ro, open_flags;
-    int ret = 0;
-    uint8_t *buf = NULL;
-
-    if (!drv)
-        return -ENOMEDIUM;
-
-    if (!bs->backing) {
-        return -ENOTSUP;
-    }
-
-    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, NULL) ||
-        bdrv_op_is_blocked(bs->backing->bs, BLOCK_OP_TYPE_COMMIT_TARGET, NULL)) {
-        return -EBUSY;
-    }
-
-    ro = bs->backing->bs->read_only;
-    open_flags =  bs->backing->bs->open_flags;
-
-    if (ro) {
-        if (bdrv_reopen(bs->backing->bs, open_flags | BDRV_O_RDWR, NULL)) {
-            return -EACCES;
-        }
-    }
-
-    length = bdrv_getlength(bs);
-    if (length < 0) {
-        ret = length;
-        goto ro_cleanup;
-    }
-
-    backing_length = bdrv_getlength(bs->backing->bs);
-    if (backing_length < 0) {
-        ret = backing_length;
-        goto ro_cleanup;
-    }
-
-    /* If our top snapshot is larger than the backing file image,
-     * grow the backing file image if possible.  If not possible,
-     * we must return an error */
-    if (length > backing_length) {
-        ret = bdrv_truncate(bs->backing->bs, length);
-        if (ret < 0) {
-            goto ro_cleanup;
-        }
-    }
-
-    total_sectors = length >> BDRV_SECTOR_BITS;
-
-    /* qemu_try_blockalign() for bs will choose an alignment that works for
-     * bs->backing->bs as well, so no need to compare the alignment manually. */
-    buf = qemu_try_blockalign(bs, COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
-    if (buf == NULL) {
-        ret = -ENOMEM;
-        goto ro_cleanup;
-    }
-
-    for (sector = 0; sector < total_sectors; sector += n) {
-        ret = bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n);
-        if (ret < 0) {
-            goto ro_cleanup;
-        }
-        if (ret) {
-            ret = bdrv_read(bs, sector, buf, n);
-            if (ret < 0) {
-                goto ro_cleanup;
-            }
-
-            ret = bdrv_write(bs->backing->bs, sector, buf, n);
-            if (ret < 0) {
-                goto ro_cleanup;
-            }
-        }
-    }
-
-    if (drv->bdrv_make_empty) {
-        ret = drv->bdrv_make_empty(bs);
-        if (ret < 0) {
-            goto ro_cleanup;
-        }
-        bdrv_flush(bs);
-    }
-
-    /*
-     * Make sure all data we wrote to the backing device is actually
-     * stable on disk.
-     */
-    if (bs->backing) {
-        bdrv_flush(bs->backing->bs);
-    }
-
-    ret = 0;
-ro_cleanup:
-    qemu_vfree(buf);
-
-    if (ro) {
-        /* ignoring error return here */
-        bdrv_reopen(bs->backing->bs, open_flags & ~BDRV_O_RDWR, NULL);
-    }
-
-    return ret;
-}
-
 /*
  * Return values:
  * 0        - success
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 44a5416..2593a2f 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -9,7 +9,7 @@ block-obj-y += block-backend.o snapshot.o qapi.o
 block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o
 block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
-block-obj-y += null.o mirror.o io.o
+block-obj-y += null.o mirror.o commit.o io.o
 block-obj-y += throttle-groups.o
 
 block-obj-y += nbd.o nbd-client.o sheepdog.o
@@ -26,7 +26,6 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 
 common-obj-y += stream.o
-common-obj-y += commit.o
 common-obj-y += backup.o
 
 iscsi.o-cflags     := $(LIBISCSI_CFLAGS)
diff --git a/block/commit.c b/block/commit.c
index 444333b..4ac3df3 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -282,3 +282,114 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
     trace_commit_start(bs, base, top, s, s->common.co, opaque);
     qemu_coroutine_enter(s->common.co, s);
 }
+
+
+#define COMMIT_BUF_SECTORS 2048
+
+/* commit COW file into the raw image */
+int bdrv_commit(BlockDriverState *bs)
+{
+    BlockDriver *drv = bs->drv;
+    int64_t sector, total_sectors, length, backing_length;
+    int n, ro, open_flags;
+    int ret = 0;
+    uint8_t *buf = NULL;
+
+    if (!drv)
+        return -ENOMEDIUM;
+
+    if (!bs->backing) {
+        return -ENOTSUP;
+    }
+
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, NULL) ||
+        bdrv_op_is_blocked(bs->backing->bs, BLOCK_OP_TYPE_COMMIT_TARGET, NULL)) {
+        return -EBUSY;
+    }
+
+    ro = bs->backing->bs->read_only;
+    open_flags =  bs->backing->bs->open_flags;
+
+    if (ro) {
+        if (bdrv_reopen(bs->backing->bs, open_flags | BDRV_O_RDWR, NULL)) {
+            return -EACCES;
+        }
+    }
+
+    length = bdrv_getlength(bs);
+    if (length < 0) {
+        ret = length;
+        goto ro_cleanup;
+    }
+
+    backing_length = bdrv_getlength(bs->backing->bs);
+    if (backing_length < 0) {
+        ret = backing_length;
+        goto ro_cleanup;
+    }
+
+    /* If our top snapshot is larger than the backing file image,
+     * grow the backing file image if possible.  If not possible,
+     * we must return an error */
+    if (length > backing_length) {
+        ret = bdrv_truncate(bs->backing->bs, length);
+        if (ret < 0) {
+            goto ro_cleanup;
+        }
+    }
+
+    total_sectors = length >> BDRV_SECTOR_BITS;
+
+    /* qemu_try_blockalign() for bs will choose an alignment that works for
+     * bs->backing->bs as well, so no need to compare the alignment manually. */
+    buf = qemu_try_blockalign(bs, COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
+    if (buf == NULL) {
+        ret = -ENOMEM;
+        goto ro_cleanup;
+    }
+
+    for (sector = 0; sector < total_sectors; sector += n) {
+        ret = bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n);
+        if (ret < 0) {
+            goto ro_cleanup;
+        }
+        if (ret) {
+            ret = bdrv_read(bs, sector, buf, n);
+            if (ret < 0) {
+                goto ro_cleanup;
+            }
+
+            ret = bdrv_write(bs->backing->bs, sector, buf, n);
+            if (ret < 0) {
+                goto ro_cleanup;
+            }
+        }
+    }
+
+    if (drv->bdrv_make_empty) {
+        ret = drv->bdrv_make_empty(bs);
+        if (ret < 0) {
+            goto ro_cleanup;
+        }
+        bdrv_flush(bs);
+    }
+
+    /*
+     * Make sure all data we wrote to the backing device is actually
+     * stable on disk.
+     */
+    if (bs->backing) {
+        bdrv_flush(bs->backing->bs);
+    }
+
+    ret = 0;
+ro_cleanup:
+    qemu_vfree(buf);
+
+    if (ro) {
+        /* ignoring error return here */
+        bdrv_reopen(bs->backing->bs, open_flags & ~BDRV_O_RDWR, NULL);
+    }
+
+    return ret;
+}
-- 
1.8.3.1

  parent reply	other threads:[~2016-07-05 15:51 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 15:50 [Qemu-devel] [PULL 00/43] Block layer patches Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 01/43] qemu-img: fix failed autotests Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 02/43] block: Tighter assertions on bdrv_aligned_pwritev() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 03/43] block: Document supported flags during bdrv_aligned_preadv() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 04/43] block: Fix harmless off-by-one in bdrv_aligned_preadv() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 05/43] nbd: Allow larger requests Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 06/43] nbd: Advertise realistic limits to block layer Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 07/43] iscsi: " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 08/43] scsi: Advertise limits by blocksize, not 512 Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 09/43] block: Give nonzero result to blk_get_max_transfer_length() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 10/43] blkdebug: Set request_alignment during .bdrv_refresh_limits() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 11/43] iscsi: " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 12/43] qcow2: " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 13/43] raw-win32: " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 14/43] block: " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 15/43] block: Set default request_alignment during bdrv_refresh_limits() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 16/43] block: Switch transfer length bounds to byte-based Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 17/43] block: Wording tweaks to write zeroes limits Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 18/43] block: Switch discard length bounds to byte-based Kevin Wolf
2016-07-06  2:14   ` Eric Blake
2016-07-06  8:27     ` Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 19/43] block: Drop raw_refresh_limits() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 20/43] block: Split bdrv_merge_limits() from bdrv_refresh_limits() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 21/43] block: Move request_alignment into BlockLimit Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 22/43] block: Fix error message style Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 23/43] block: Use bool as appropriate for BDS members Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 24/43] block: fix return code for partial write for Linux AIO Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 25/43] block/qdev: Fix NULL access when using BB twice Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 26/43] vvfat: Use BdrvChild for s->qcow Kevin Wolf
2016-07-11 14:02   ` Paolo Bonzini
2016-07-05 15:50 ` [Qemu-devel] [PULL 27/43] blkreplay: Convert to byte-based I/O Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 28/43] vhdx: Some more BlockBackend use in vhdx_create() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 29/43] block: Convert bdrv_co_readv() to BdrvChild Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 30/43] block: Convert bdrv_co_writev() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 31/43] block: Convert bdrv_aio_readv() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 32/43] block: Convert bdrv_aio_writev() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 33/43] block: Convert bdrv_co_do_readv/writev " Kevin Wolf
2016-07-05 15:50 ` Kevin Wolf [this message]
2016-07-05 15:50 ` [Qemu-devel] [PULL 35/43] block: Use BlockBackend for I/O in bdrv_commit() Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 36/43] block: Convert bdrv_read() to BdrvChild Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 37/43] block: Convert bdrv_write() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 38/43] block: Convert bdrv_pread(v) " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 39/43] block: Convert bdrv_pwrite(v/_sync) " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 40/43] block: Convert bdrv_pwrite_zeroes() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 41/43] block: Convert bdrv_prwv_co() " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 42/43] block: Convert bdrv_co_preadv/pwritev " Kevin Wolf
2016-07-05 15:50 ` [Qemu-devel] [PULL 43/43] block/qcow2: Don't use cpu_to_*w() Kevin Wolf
2016-07-06  9:23 ` [Qemu-devel] [PULL 00/43] Block layer patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467733852-27097-35-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.