From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v2 04/20] fuse: Allow growable exports
Date: Thu, 15 Oct 2020 12:41:52 +0200 [thread overview]
Message-ID: <20201015104152.GD4610@merkur.fritz.box> (raw)
In-Reply-To: <20200922104932.46384-5-mreitz@redhat.com>
Am 22.09.2020 um 12:49 hat Max Reitz geschrieben:
> These will behave more like normal files in that writes beyond the EOF
> will automatically grow the export size.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> qapi/block-export.json | 6 +++++-
> block/export/fuse.c | 12 +++++++++++-
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/qapi/block-export.json b/qapi/block-export.json
> index cb5bd54cbf..cb26daa98b 100644
> --- a/qapi/block-export.json
> +++ b/qapi/block-export.json
> @@ -183,10 +183,14 @@
> # @mountpoint: Path on which to export the block device via FUSE.
> # This must point to an existing regular file.
> #
> +# @growable: Whether writes beyond the EOF should grow the block node
> +# accordingly. (default: false)
> +#
> # Since: 5.2
> ##
> { 'struct': 'BlockExportOptionsFuse',
> - 'data': { 'mountpoint': 'str' },
> + 'data': { 'mountpoint': 'str',
> + '*growable': 'bool' },
> 'if': 'defined(CONFIG_FUSE)' }
>
> ##
> diff --git a/block/export/fuse.c b/block/export/fuse.c
> index 8fc667231d..f3a84579ba 100644
> --- a/block/export/fuse.c
> +++ b/block/export/fuse.c
> @@ -45,6 +45,7 @@ typedef struct FuseExport {
>
> char *mountpoint;
> bool writable;
> + bool growable;
> } FuseExport;
>
> static GHashTable *exports;
> @@ -101,6 +102,7 @@ static int fuse_export_create(BlockExport *blk_exp,
>
> exp->mountpoint = g_strdup(args->mountpoint);
> exp->writable = blk_exp_args->writable;
> + exp->growable = args->growable;
>
> ret = setup_fuse_export(exp, args->mountpoint, errp);
> if (ret < 0) {
> @@ -436,7 +438,15 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inode, const char *buf,
>
> size = MIN(size, BDRV_REQUEST_MAX_BYTES);
> if (offset + size > length) {
> - size = length - offset;
> + if (exp->growable) {
> + ret = fuse_do_truncate(exp, offset + size, PREALLOC_MODE_OFF);
Do we need BDRV_REQ_ZERO_WRITE for blk_truncate() in this case?
Actually, since we export a regular file, it would probably be good for
the setattr case, too.
If someone actually uses this to sequentially write past the end of the
file, it will be quite inefficient because fuse_do_truncate() temporarily
acquires locks for each write request. It might be a good idea to
acquire BLK_PERM_RESIZE from the start for growable exports (like image
formats do for bs->file).
> + if (ret < 0) {
> + fuse_reply_err(req, -ret);
> + return;
> + }
> + } else {
> + size = length - offset;
> + }
> }
Kevin
next prev parent reply other threads:[~2020-10-15 10:42 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 10:49 [PATCH v2 00/20] block/export: Allow exporting BDSs via FUSE Max Reitz
2020-09-22 10:49 ` [PATCH v2 01/20] configure: Detect libfuse Max Reitz
2020-09-22 11:14 ` Thomas Huth
2020-09-22 11:21 ` Paolo Bonzini
2020-09-22 11:46 ` Max Reitz
2020-09-22 15:37 ` Max Reitz
2020-09-22 15:45 ` Paolo Bonzini
2020-09-22 10:49 ` [PATCH v2 02/20] fuse: Allow exporting BDSs via FUSE Max Reitz
2020-10-15 8:57 ` Kevin Wolf
2020-10-15 14:46 ` Max Reitz
2020-10-15 15:41 ` Kevin Wolf
2020-10-15 15:59 ` Max Reitz
2020-10-15 17:01 ` Kevin Wolf
2020-09-22 10:49 ` [PATCH v2 03/20] fuse: Implement standard FUSE operations Max Reitz
2020-10-15 9:46 ` Kevin Wolf
2020-10-15 15:18 ` Max Reitz
2020-10-15 15:58 ` Kevin Wolf
2020-10-15 16:04 ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 04/20] fuse: Allow growable exports Max Reitz
2020-10-15 10:41 ` Kevin Wolf [this message]
2020-10-15 15:20 ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 05/20] fuse: (Partially) implement fallocate() Max Reitz
2020-09-22 10:49 ` [PATCH v2 06/20] fuse: Implement hole detection through lseek Max Reitz
2020-09-22 10:49 ` [PATCH v2 07/20] iotests: Do not needlessly filter _make_test_img Max Reitz
2020-09-22 10:49 ` [PATCH v2 08/20] iotests: Do not pipe _make_test_img Max Reitz
2020-09-22 10:49 ` [PATCH v2 09/20] iotests: Use convert -n in some cases Max Reitz
2020-09-22 10:49 ` [PATCH v2 10/20] iotests/046: Avoid renaming images Max Reitz
2020-09-22 10:49 ` [PATCH v2 11/20] iotests: Derive image names from $TEST_IMG Max Reitz
2020-09-22 10:49 ` [PATCH v2 12/20] iotests/091: Use _cleanup_qemu instad of "wait" Max Reitz
2020-09-22 10:49 ` [PATCH v2 13/20] iotests: Restrict some Python tests to file Max Reitz
2020-09-22 10:49 ` [PATCH v2 14/20] iotests: Let _make_test_img guess $TEST_IMG_FILE Max Reitz
2020-09-22 10:49 ` [PATCH v2 15/20] iotests/287: Clean up subshell test image Max Reitz
2020-09-22 10:49 ` [PATCH v2 16/20] storage-daemon: Call bdrv_close_all() on exit Max Reitz
2020-09-22 10:49 ` [PATCH v2 17/20] iotests: Give access to the qemu-storage-daemon Max Reitz
2020-10-15 11:27 ` Kevin Wolf
2020-10-15 15:22 ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 18/20] iotests: Allow testing FUSE exports Max Reitz
2020-10-15 11:43 ` Kevin Wolf
2020-10-15 15:27 ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 19/20] iotests: Enable fuse for many tests Max Reitz
2020-09-22 10:49 ` [PATCH v2 20/20] iotests/308: Add test for FUSE exports Max Reitz
2020-09-22 15:58 ` [PATCH v2 00/20] block/export: Allow exporting BDSs via FUSE Daniel P. Berrangé
2020-09-23 7:21 ` Max Reitz
2020-09-23 9:08 ` Stefan Hajnoczi
2020-10-15 12:01 ` Kevin Wolf
2020-10-15 16:47 ` 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=20201015104152.GD4610@merkur.fritz.box \
--to=kwolf@redhat.com \
--cc=mreitz@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).