From: Eric Blake <eblake@redhat.com>
To: Hanna Reitz <hreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v3 2/6] block: block-status cache for data regions
Date: Mon, 16 Aug 2021 16:38:23 -0500 [thread overview]
Message-ID: <20210816213823.uocknsk4zgulrk3v@redhat.com> (raw)
In-Reply-To: <20210812084148.14458-3-hreitz@redhat.com>
On Thu, Aug 12, 2021 at 10:41:44AM +0200, Hanna Reitz wrote:
> As we have attempted before
> (https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg06451.html,
> "file-posix: Cache lseek result for data regions";
> https://lists.nongnu.org/archive/html/qemu-block/2021-02/msg00934.html,
> "file-posix: Cache next hole"), this patch seeks to reduce the number of
> SEEK_DATA/HOLE operations the file-posix driver has to perform. The
> main difference is that this time it is implemented as part of the
> general block layer code.
>
> We only use the cache for nodes without children (i.e. protocol nodes),
> because that is where the problem is: Drivers that rely on block-status
> implementations outside of qemu (e.g. SEEK_DATA/HOLE).
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/307
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
> +++ b/block.c
> +/**
> + * Check whether [offset, offset + bytes) overlaps with the cached
> + * block-status data region.
> + *
> + * If so, and @pnum is not NULL, set *pnum to `bsc.data_end - offset`,
> + * which is what bdrv_bsc_is_data()'s interface needs.
> + * Otherwise, *pnum is not touched.
Why duplicate this comment,...
> + */
> +static bool bdrv_bsc_range_overlaps_locked(BlockDriverState *bs,
> + int64_t offset, int64_t bytes,
> + int64_t *pnum)
> +{
> + BdrvBlockStatusCache *bsc = qatomic_rcu_read(&bs->block_status_cache);
> + bool overlaps;
> +
> + overlaps =
> + qatomic_read(&bsc->valid) &&
> + ranges_overlap(offset, bytes, bsc->data_start,
> + bsc->data_end - bsc->data_start);
> +
> + if (overlaps && pnum) {
> + *pnum = bsc->data_end - offset;
> + }
> +
> + return overlaps;
> +}
> +
> +/**
> + * See block_int.h for this function's documentation.
> + */
> +bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum)
> +{
> + RCU_READ_LOCK_GUARD();
> +
> + return bdrv_bsc_range_overlaps_locked(bs, offset, 1, pnum);
> +}
> +
> +/**
> + * See block_int.h for this function's documentation.
...but not these?
But that's minor.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2021-08-16 21:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 8:41 [PATCH v3 0/6] block-status cache for data regions Hanna Reitz
2021-08-12 8:41 ` [PATCH v3 1/6] block: Drop BDS comment regarding bdrv_append() Hanna Reitz
2021-08-12 8:41 ` [PATCH v3 2/6] block: block-status cache for data regions Hanna Reitz
2021-08-16 21:38 ` Eric Blake [this message]
2021-08-17 6:19 ` Hanna Reitz
2021-08-25 9:54 ` Vladimir Sementsov-Ogievskiy
2021-08-12 8:41 ` [PATCH v3 3/6] block: Clarify that @bytes is no limit on *pnum Hanna Reitz
2021-08-17 15:03 ` Eric Blake
2021-08-12 8:41 ` [PATCH v3 4/6] block/file-posix: Do not force-cap *pnum Hanna Reitz
2021-08-12 8:41 ` [PATCH v3 5/6] block/gluster: " Hanna Reitz
2021-08-12 8:41 ` [PATCH v3 6/6] block/iscsi: " Hanna Reitz
2021-09-07 9:23 ` [PATCH v3 0/6] block-status cache for data regions Hanna Reitz
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=20210816213823.uocknsk4zgulrk3v@redhat.com \
--to=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@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).