From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [RFC 3/5] block: Fall back to fallback truncate function
Date: Thu, 11 Jul 2019 21:58:02 +0200 [thread overview]
Message-ID: <20190711195804.30703-4-mreitz@redhat.com> (raw)
In-Reply-To: <20190711195804.30703-1-mreitz@redhat.com>
file-posix does not need to basically duplicate our fallback truncate
implementation; and sheepdog can fall back to it for "shrinking" files.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/file-posix.c | 21 +--------------------
block/sheepdog.c | 2 +-
2 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index ab05b51a66..bcddfc7fbe 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2031,23 +2031,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset,
return raw_regular_truncate(bs, s->fd, offset, prealloc, errp);
}
- if (prealloc != PREALLOC_MODE_OFF) {
- error_setg(errp, "Preallocation mode '%s' unsupported for this "
- "non-regular file", PreallocMode_str(prealloc));
- return -ENOTSUP;
- }
-
- if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
- if (offset > raw_getlength(bs)) {
- error_setg(errp, "Cannot grow device files");
- return -EINVAL;
- }
- } else {
- error_setg(errp, "Resizing this file is not supported");
- return -ENOTSUP;
- }
-
- return 0;
+ return -ENOTSUP;
}
#ifdef __OpenBSD__
@@ -3413,7 +3397,6 @@ static BlockDriver bdrv_host_device = {
.bdrv_io_unplug = raw_aio_unplug,
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
- .bdrv_co_truncate = raw_co_truncate,
.bdrv_getlength = raw_getlength,
.bdrv_get_info = raw_get_info,
.bdrv_get_allocated_file_size
@@ -3537,7 +3520,6 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_io_unplug = raw_aio_unplug,
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
- .bdrv_co_truncate = raw_co_truncate,
.bdrv_getlength = raw_getlength,
.has_variable_length = true,
.bdrv_get_allocated_file_size
@@ -3669,7 +3651,6 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_io_unplug = raw_aio_unplug,
.bdrv_attach_aio_context = raw_aio_attach_aio_context,
- .bdrv_co_truncate = raw_co_truncate,
.bdrv_getlength = raw_getlength,
.has_variable_length = true,
.bdrv_get_allocated_file_size
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 6f402e5d4d..4af4961cb7 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2301,7 +2301,7 @@ static int coroutine_fn sd_co_truncate(BlockDriverState *bs, int64_t offset,
max_vdi_size = (UINT64_C(1) << s->inode.block_size_shift) * MAX_DATA_OBJS;
if (offset < old_size) {
error_setg(errp, "shrinking is not supported");
- return -EINVAL;
+ return -ENOTSUP;
} else if (offset > max_vdi_size) {
error_setg(errp, "too big image size");
return -EINVAL;
--
2.21.0
next prev parent reply other threads:[~2019-07-11 19:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 19:57 [Qemu-devel] [RFC 0/5] block: Generic file truncation/creation fallbacks Max Reitz
2019-07-11 19:58 ` [Qemu-devel] [RFC 1/5] block/nbd: Fix hang in .bdrv_close() Max Reitz
2019-07-12 9:24 ` Kevin Wolf
2019-07-12 10:47 ` Max Reitz
2019-07-12 11:01 ` Kevin Wolf
2019-07-12 11:09 ` Max Reitz
2019-07-12 11:23 ` Kevin Wolf
2019-07-12 11:44 ` Max Reitz
2019-07-12 12:30 ` Kevin Wolf
2019-07-11 19:58 ` [Qemu-devel] [RFC 2/5] block: Generic truncation fallback Max Reitz
2019-07-12 9:49 ` Kevin Wolf
2019-07-12 10:58 ` Max Reitz
2019-07-12 11:17 ` Kevin Wolf
2019-07-12 11:48 ` Max Reitz
2019-07-12 13:48 ` Max Reitz
2019-07-11 19:58 ` Max Reitz [this message]
2019-07-12 10:04 ` [Qemu-devel] [RFC 3/5] block: Fall back to fallback truncate function Kevin Wolf
2019-07-12 11:05 ` Max Reitz
2019-07-11 19:58 ` [Qemu-devel] [RFC 4/5] block: Generic file creation fallback Max Reitz
2019-07-11 19:58 ` [Qemu-devel] [RFC 5/5] iotests: Add test for fallback truncate/create Max 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=20190711195804.30703-4-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).