[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/18] fuse: Allow growable exports
From: |
Max Reitz |
Subject: |
[PATCH 05/18] fuse: Allow growable exports |
Date: |
Thu, 19 Dec 2019 15:38:05 +0100 |
These will behave more like normal files in that writes beyond the EOF
will automatically grow the export size.
Signed-off-by: Max Reitz <address@hidden>
---
block/fuse.c | 16 +++++++++++++++-
qapi/block.json | 6 +++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/block/fuse.c b/block/fuse.c
index 4e662e6dfb..d7c7824815 100644
--- a/block/fuse.c
+++ b/block/fuse.c
@@ -42,6 +42,7 @@ typedef struct BdrvFuseSession {
uint64_t perm, shared_perm;
bool mounted, fd_handler_set_up;
bool writable;
+ bool growable;
} BdrvFuseSession;
static GHashTable *sessions;
@@ -59,6 +60,7 @@ static bool is_regular_file(const char *path, Error **errp);
void qmp_fuse_export_add(const char *node_name, const char *mountpoint,
bool has_writable, bool writable,
+ bool has_growable, bool growable,
Error **errp)
{
BlockDriverState *bs;
@@ -67,6 +69,9 @@ void qmp_fuse_export_add(const char *node_name, const char
*mountpoint,
if (!has_writable) {
writable = false;
}
+ if (!has_growable) {
+ growable = false;
+ }
init_fuse();
@@ -98,6 +103,7 @@ void qmp_fuse_export_add(const char *node_name, const char
*mountpoint,
},
.writable = writable,
+ .growable = growable,
};
session->perm = BLK_PERM_CONSISTENT_READ;
@@ -463,7 +469,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 (session->growable) {
+ ret = fuse_do_truncate(session, offset + size, PREALLOC_MODE_OFF);
+ if (ret < 0) {
+ fuse_reply_err(req, -ret);
+ return;
+ }
+ } else {
+ size = length - offset;
+ }
}
ret = blk_pwrite(session->blk, offset, buf, size, 0);
diff --git a/qapi/block.json b/qapi/block.json
index 26768dc8ef..039cbc6773 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -330,13 +330,17 @@
# @writable: Whether clients should be able to write to the block
# device via the FUSE export. (default: false)
#
+# @growable: Whether writes beyond the EOF should grow the block node
+# fit. (default: false)
+#
# Since: 5.0
##
{ 'command': 'fuse-export-add',
'data': {
'node-name': 'str',
'mountpoint': 'str',
- '*writable': 'bool'
+ '*writable': 'bool',
+ '*growable': 'bool'
},
'if': 'defined(CONFIG_FUSE)' }
--
2.23.0
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, (continued)
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Max Reitz, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Markus Armbruster, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Kevin Wolf, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Markus Armbruster, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Eric Blake, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Markus Armbruster, 2019/12/20
- Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Kevin Wolf, 2019/12/20
Re: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE, Eric Blake, 2019/12/20
[PATCH 03/18] fuse: Implement standard FUSE operations, Max Reitz, 2019/12/19
[PATCH 04/18] fuse: Add fuse-export-remove, Max Reitz, 2019/12/19
[PATCH 05/18] fuse: Allow growable exports,
Max Reitz <=
[PATCH 06/18] fuse: (Partially) implement fallocate(), Max Reitz, 2019/12/19
[PATCH 07/18] fuse: Implement hole detection through lseek, Max Reitz, 2019/12/19
[PATCH 08/18] iotests: Do not needlessly filter _make_test_img, Max Reitz, 2019/12/19
[PATCH 09/18] iotests: Do not pipe _make_test_img, Max Reitz, 2019/12/19
[PATCH 10/18] iotests: Use convert -n in some cases, Max Reitz, 2019/12/19
[PATCH 11/18] iotests: Avoid renaming images, Max Reitz, 2019/12/19
[PATCH 12/18] iotests: Derive image names from $TEST_IMG, Max Reitz, 2019/12/19
[PATCH 13/18] iotests/091: Use _cleanup_qemu instad of "wait", Max Reitz, 2019/12/19
[PATCH 14/18] iotests: Restrict some Python tests to file, Max Reitz, 2019/12/19
[PATCH 15/18] iotests: Let _make_test_img guess $TEST_IMG_FILE, Max Reitz, 2019/12/19