From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UttfL-0007xP-Hi for qemu-devel@nongnu.org; Tue, 02 Jul 2013 02:02:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UttfI-0000ei-RM for qemu-devel@nongnu.org; Tue, 02 Jul 2013 02:02:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UttfI-0000ec-Km for qemu-devel@nongnu.org; Tue, 02 Jul 2013 02:02:12 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6262BhU027711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Jul 2013 02:02:12 -0400 From: Fam Zheng Date: Tue, 2 Jul 2013 13:59:47 +0800 Message-Id: <1372744789-997-6-git-send-email-famz@redhat.com> In-Reply-To: <1372744789-997-1-git-send-email-famz@redhat.com> References: <1372744789-997-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH 5/7] block: rename bdrv_in_use to bdrv_is_shared List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, obarenbo@redhat.com, roliveri@redhat.com, hbrock@redhat.com, rjones@redhat.com, armbru@redhat.com, pmyers@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com The patch only does a rename: bdrv_in_use is obsecure literally (any BDS is certain to be used somewhere). Rename it to bdrv_is_shared since we have reference count now and the user number of the BDS is reflected there. Signed-off-by: Fam Zheng --- block.c | 16 ++++++++++------ blockdev.c | 10 +++++----- blockjob.c | 2 +- include/block/block.h | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index ae5de17..85dc76f 100644 --- a/block.c +++ b/block.c @@ -1775,7 +1775,7 @@ int bdrv_commit(BlockDriverState *bs) return -ENOTSUP; } - if (bdrv_in_use(bs) || bdrv_in_use(bs->backing_hd)) { + if (bdrv_is_shared(bs) || bdrv_is_shared(bs->backing_hd)) { return -EBUSY; } @@ -2621,14 +2621,18 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset) { BlockDriver *drv = bs->drv; int ret; - if (!drv) + if (!drv) { return -ENOMEDIUM; - if (!drv->bdrv_truncate) + } + if (!drv->bdrv_truncate) { return -ENOTSUP; - if (bs->read_only) + } + if (bs->read_only) { return -EACCES; - if (bdrv_in_use(bs)) + } + if (bdrv_is_shared(bs)) { return -EBUSY; + } ret = drv->bdrv_truncate(bs, offset); if (ret == 0) { ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); @@ -4333,7 +4337,7 @@ void bdrv_get_ref(BlockDriverState *bs) bs->refcount++; } -int bdrv_in_use(BlockDriverState *bs) +int bdrv_is_shared(BlockDriverState *bs) { return bs->refcount > 1; } diff --git a/blockdev.c b/blockdev.c index 2c2ea59..d02d99a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -858,7 +858,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - if (bdrv_in_use(state->old_bs)) { + if (bdrv_is_shared(state->old_bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; } @@ -1064,7 +1064,7 @@ exit: static void eject_device(BlockDriverState *bs, int force, Error **errp) { - if (bdrv_in_use(bs)) { + if (bdrv_is_shared(bs)) { error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); return; } @@ -1226,7 +1226,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) qerror_report(QERR_DEVICE_NOT_FOUND, id); return -1; } - if (bdrv_in_use(bs)) { + if (bdrv_is_shared(bs)) { qerror_report(QERR_DEVICE_IN_USE, id); return -1; } @@ -1471,7 +1471,7 @@ void qmp_drive_backup(const char *device, const char *target, } } - if (bdrv_in_use(bs)) { + if (bdrv_is_shared(bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; } @@ -1588,7 +1588,7 @@ void qmp_drive_mirror(const char *device, const char *target, } } - if (bdrv_in_use(bs)) { + if (bdrv_is_shared(bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; } diff --git a/blockjob.c b/blockjob.c index a841a66..3e9b9a8 100644 --- a/blockjob.c +++ b/blockjob.c @@ -41,7 +41,7 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, { BlockJob *job; - if (bs->job || bdrv_in_use(bs)) { + if (bs->job || bdrv_is_shared(bs)) { error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); return NULL; } diff --git a/include/block/block.h b/include/block/block.h index 77f0f0d..6b33f5a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -355,7 +355,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_put_ref(BlockDriverState *bs); void bdrv_get_ref(BlockDriverState *bs); -int bdrv_in_use(BlockDriverState *bs); +int bdrv_is_shared(BlockDriverState *bs); #ifdef CONFIG_LINUX_AIO int raw_get_aio_fd(BlockDriverState *bs); -- 1.8.3.1