Message ID | 20210209190224.62827-14-dgilbert@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | virtiofs dax patches | expand |
On Tue, Feb 09, 2021 at 07:02:13PM +0000, Dr. David Alan Gilbert (git) wrote: > 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> > --- > tools/virtiofsd/passthrough_ll.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c index 0493f00756..971ff2b2ea 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -3023,8 +3023,30 @@ 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 = { 0 }; + int ret = 0; + + for (int i = 0; num > 0; i++, argp++) { + msg.len[i] = argp->len; + msg.c_offset[i] = argp->moffset; + + if (--num == 0 || i == VHOST_USER_FS_SLAVE_ENTRIES - 1) { + ret = fuse_virtio_unmap(se, &msg); + if (ret < 0) { + fuse_log(FUSE_LOG_ERR, + "%s: unmap over virtio failed " + "(offset=0x%lx, len=0x%lx). err=%d\n", + __func__, argp->moffset, argp->len, ret); + break; + } + if (num > 0) { + i = 0; + memset(&msg, 0, sizeof(msg)); + } + } + } + + fuse_reply_err(req, -ret); } static struct fuse_lowlevel_ops lo_oper = {