[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 15/26] DAX: virtiofsd: Make lo_removemapping() work
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH v3 15/26] DAX: virtiofsd: Make lo_removemapping() work |
Date: |
Wed, 28 Apr 2021 12:00:49 +0100 |
From: Vivek Goyal <vgoyal@redhat.com>
Let guest pass in the offset in dax window a mapping is currently
mapped at and needs to be removed.
Vivek added the initial support to remove single mapping and later Peng
added patch to support removing multiple mappings in single command.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Peng Tao <tao.peng@linux.alibaba.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tools/virtiofsd/passthrough_ll.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 6981737389..1a86378172 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -3210,8 +3210,36 @@ static void lo_removemapping(fuse_req_t req, struct
fuse_session *se,
fuse_ino_t ino, unsigned num,
struct fuse_removemapping_one *argp)
{
- /* TODO */
- fuse_reply_err(req, ENOSYS);
+ VhostUserFSSlaveMsg *msg;
+ size_t alloc_count = (num > VHOST_USER_FS_SLAVE_MAX_ENTRIES) ?
+ VHOST_USER_FS_SLAVE_MAX_ENTRIES : num;
+ int ret = 0;
+ msg = g_malloc0(sizeof(VhostUserFSSlaveMsg) +
+ alloc_count * sizeof(VhostUserFSSlaveMsgEntry));
+
+ for (int i = 0, o = 0; num > 0; i++, argp++) {
+ VhostUserFSSlaveMsgEntry *e = &msg->entries[o];
+
+ e->len = argp->len;
+ e->c_offset = argp->moffset;
+
+ o++;
+ if (--num == 0 || o == VHOST_USER_FS_SLAVE_MAX_ENTRIES) {
+ msg->count = o;
+ ret = fuse_virtio_unmap(se, msg);
+ if (ret < 0) {
+ fuse_log(FUSE_LOG_ERR,
+ "%s: unmap over virtio failed "
+ "(offset=0x%" PRIx64 ", len=0x%" PRIx64 "). err=%d\n",
+ __func__, argp->moffset, argp->len, ret);
+ break;
+ }
+ o = 0;
+ }
+ }
+
+ fuse_reply_err(req, -ret);
+ g_free(msg);
}
static struct fuse_lowlevel_ops lo_oper = {
--
2.31.1
- [PATCH v3 06/26] DAX subprojects/libvhost-user: Add virtio-fs slave types, (continued)
- [PATCH v3 06/26] DAX subprojects/libvhost-user: Add virtio-fs slave types, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 08/26] DAX: virtio-fs: Add cache BAR, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 07/26] DAX: virtio: Add shared memory capability, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 09/26] DAX: virtio-fs: Add vhost-user slave commands for mapping, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 05/26] DAX: libvhost-user: Allow popping a queue element with bad pointers, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 10/26] DAX: virtio-fs: Fill in slave commands for mapping, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 11/26] DAX: virtiofsd Add cache accessor functions, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 12/26] DAX: virtiofsd: Add setup/remove mappings fuse commands, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 14/26] DAX: virtiofsd: Wire up passthrough_ll's lo_setupmapping, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 13/26] DAX: virtiofsd: Add setup/remove mapping handlers to passthrough_ll, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 15/26] DAX: virtiofsd: Make lo_removemapping() work,
Dr. David Alan Gilbert (git) <=
- [PATCH v3 16/26] DAX: virtiofsd: route se down to destroy method, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 17/26] DAX: virtiofsd: Perform an unmap on destroy, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 18/26] DAX/unmap: virtiofsd: Add VHOST_USER_SLAVE_FS_IO, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 19/26] DAX/unmap virtiofsd: Add wrappers for VHOST_USER_SLAVE_FS_IO, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 21/26] DAX/unmap virtiofsd: Route unmappable reads, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 23/26] DAX:virtiofsd: implement FUSE_INIT map_alignment field, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 20/26] DAX/unmap virtiofsd: Parse unmappable elements, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 22/26] DAX/unmap virtiofsd: route unmappable write to slave command, Dr. David Alan Gilbert (git), 2021/04/28
- [PATCH v3 24/26] vhost-user-fs: Extend VhostUserFSSlaveMsg to pass additional info, Dr. David Alan Gilbert (git), 2021/04/28