From: Max Reitz <mreitz@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] block/file-posix: consider file size when fallback to max_align
Date: Wed, 11 Mar 2020 11:46:24 +0100 [thread overview]
Message-ID: <1924575b-22d6-8ab7-c38b-4bb8dd10181f@redhat.com> (raw)
In-Reply-To: <20200130152218.7600-3-vsementsov@virtuozzo.com>
[-- Attachment #1.1: Type: text/plain, Size: 1881 bytes --]
On 30.01.20 16:22, Vladimir Sementsov-Ogievskiy wrote:
> If we failed to probe request_align, we fallback to max_align. But
> this is wrong, if file size is not aligned to our max_align. Let's
> instead chose alignment so that file size is a multiple of it.
It’s entirely possible that the file size is not aligned to the request
alignment, though. If so, this patch will make the whole file inaccessible.
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/file-posix.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 7f366046c2..e9c4e509f6 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -385,11 +385,25 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
> align = alignments[i];
> if (raw_is_io_aligned(fd, buf, align)) {
> /* Fallback to safe value. */
> - bs->bl.request_alignment = (align != 1) ? align : max_align;
> + bs->bl.request_alignment = align;
The comment above is now outdated.
Max
> break;
> }
> }
> qemu_vfree(buf);
> +
> + if (bs->bl.request_alignment == 1) {
> + /*
> + * Succeed to read with alignment = 1. But it may be unallocated
> + * area on XFS, and we'll fail later if keep request_alignment = 1.
> + *
> + * Chose safer alignment, keeping in mind file size if possible.
> + */
> +
> + int64_t len = raw_getlength_fd(bs, fd);
> +
> + bs->bl.request_alignment =
> + len <= 0 ? max_align : MIN(max_align, len & ~(len - 1));
> + }
> }
>
> if (!s->buf_align) {
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-03-11 10:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 15:22 [PATCH 0/3] request_alignment vs file size Vladimir Sementsov-Ogievskiy
2020-01-30 15:22 ` [PATCH 1/3] block/file-posix: add raw_getlength_fd Vladimir Sementsov-Ogievskiy
2020-03-11 10:21 ` Max Reitz
2020-01-30 15:22 ` [PATCH 2/3] block/file-posix: consider file size when fallback to max_align Vladimir Sementsov-Ogievskiy
2020-03-11 10:46 ` Max Reitz [this message]
2020-01-30 15:22 ` [PATCH 3/3] block: fail on open when file size is unaligned to request_alignment Vladimir Sementsov-Ogievskiy
2020-03-11 11:06 ` Max Reitz
2020-03-11 12:29 ` Eric Blake
2020-03-12 9:06 ` Vladimir Sementsov-Ogievskiy
2020-03-12 11:31 ` Eric Blake
2020-03-12 11:59 ` Vladimir Sementsov-Ogievskiy
2020-03-12 12:06 ` Vladimir Sementsov-Ogievskiy
2020-03-23 13:00 ` Max Reitz
2020-01-30 15:52 ` [PATCH 0/3] request_alignment vs file size no-reply
2020-01-30 16:06 ` Vladimir Sementsov-Ogievskiy
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=1924575b-22d6-8ab7-c38b-4bb8dd10181f@redhat.com \
--to=mreitz@redhat.com \
--cc=den@openvz.org \
--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).