From: Anton Nefedov <anton.nefedov@virtuozzo.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"kwolf@redhat.com" <kwolf@redhat.com>,
"mreitz@redhat.com" <mreitz@redhat.com>,
"armbru@redhat.com" <armbru@redhat.com>,
"jsnow@redhat.com" <jsnow@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"famz@redhat.com" <famz@redhat.com>,
"eblake@redhat.com" <eblake@redhat.com>,
Denis Lunev <den@virtuozzo.com>,
"berto@igalia.com" <berto@igalia.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Anton Nefedov <anton.nefedov@virtuozzo.com>
Subject: [Qemu-devel] [PATCH v5 8/9] file-posix: account discard operations
Date: Wed, 31 Oct 2018 11:35:02 +0000 [thread overview]
Message-ID: <20181031113418.29796-9-anton.nefedov@virtuozzo.com> (raw)
In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com>
This will help to identify how many of the user-issued discard operations
(accounted on a device level) have actually suceeded down on the host file
(even though the numbers will not be exactly the same if non-raw format
driver is used (e.g. qcow2 sending metadata discards)).
Note that these numbers will not include discards triggered by
write-zeroes + MAY_UNMAP calls.
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
---
block/file-posix.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 2da3a76355..1a7126046c 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -163,6 +163,11 @@ typedef struct BDRVRawState {
bool has_fallocate;
bool needs_alignment;
bool check_cache_dropped;
+ struct {
+ int64_t discard_nb_ok;
+ int64_t discard_nb_failed;
+ int64_t discard_bytes_ok;
+ } stats;
PRManager *pr_mgr;
} BDRVRawState;
@@ -2582,12 +2587,25 @@ static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
#endif /* !__linux__ */
}
+static void raw_account_discard(BDRVRawState *s, uint64_t nbytes, int ret)
+{
+ if (ret) {
+ s->stats.discard_nb_failed++;
+ } else {
+ s->stats.discard_nb_ok++;
+ s->stats.discard_bytes_ok += nbytes;
+ }
+}
+
static coroutine_fn int
raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
{
BDRVRawState *s = bs->opaque;
+ int ret;
- return paio_submit_co(bs, s->fd, offset, NULL, bytes, QEMU_AIO_DISCARD);
+ ret = paio_submit_co(bs, s->fd, offset, NULL, bytes, QEMU_AIO_DISCARD);
+ raw_account_discard(s, bytes, ret);
+ return ret;
}
static int coroutine_fn raw_co_pwrite_zeroes(
@@ -3084,10 +3102,14 @@ hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
ret = fd_open(bs);
if (ret < 0) {
+ raw_account_discard(s, bytes, ret);
return ret;
}
- return paio_submit_co(bs, s->fd, offset, NULL, bytes,
- QEMU_AIO_DISCARD | QEMU_AIO_BLKDEV);
+
+ ret = paio_submit_co(bs, s->fd, offset, NULL, bytes,
+ QEMU_AIO_DISCARD | QEMU_AIO_BLKDEV);
+ raw_account_discard(s, bytes, ret);
+ return ret;
}
static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs,
--
2.17.1
next prev parent reply other threads:[~2018-10-31 11:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 11:34 [Qemu-devel] [PATCH v5 0/9] discard blockstats Anton Nefedov
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 1/9] qapi: group BlockDeviceStats fields Anton Nefedov
2018-11-12 15:40 ` Alberto Garcia
2018-11-23 17:18 ` Vladimir Sementsov-Ogievskiy
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 2/9] qapi: add unmap to BlockDeviceStats Anton Nefedov
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 3/9] block: add empty account cookie type Anton Nefedov
2018-11-23 16:04 ` Vladimir Sementsov-Ogievskiy
2018-11-26 12:18 ` Anton Nefedov
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 4/9] ide: account UNMAP (TRIM) operations Anton Nefedov
2018-11-23 17:46 ` Vladimir Sementsov-Ogievskiy
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 5/9] scsi: store unmap offset and nb_sectors in request struct Anton Nefedov
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 6/9] scsi: move unmap error checking to the complete callback Anton Nefedov
2018-10-31 11:34 ` [Qemu-devel] [PATCH v5 7/9] scsi: account unmap operations Anton Nefedov
2018-11-23 18:25 ` Vladimir Sementsov-Ogievskiy
2018-11-26 12:20 ` Anton Nefedov
2018-10-31 11:35 ` Anton Nefedov [this message]
2018-11-23 18:34 ` [Qemu-devel] [PATCH v5 8/9] file-posix: account discard operations Vladimir Sementsov-Ogievskiy
2018-10-31 11:35 ` [Qemu-devel] [PATCH v5 9/9] qapi: query-blockstat: add driver specific file-posix stats Anton Nefedov
2018-11-23 19:21 ` Vladimir Sementsov-Ogievskiy
2018-11-26 12:55 ` Anton Nefedov
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=20181031113418.29796-9-anton.nefedov@virtuozzo.com \
--to=anton.nefedov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=den@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).