From: Hanna Reitz <hreitz@redhat.com>
To: qemu-devel@nongnu.org, virtio-fs@redhat.com
Cc: Hanna Reitz <hreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Vivek Goyal <vgoyal@redhat.com>
Subject: [PATCH v4 08/12] virtiofsd: Pass lo_data to lo_inode_{fd,open}()
Date: Thu, 16 Sep 2021 10:40:41 +0200 [thread overview]
Message-ID: <20210916084045.31684-9-hreitz@redhat.com> (raw)
In-Reply-To: <20210916084045.31684-1-hreitz@redhat.com>
In order to be able to use file handles for identifying lo_inode
objects, we will add some global state to lo_data, which we will need in
a future function to be called from lo_inode_fd() and lo_inode_open().
To prepare for this, pass a (non-const) lo_data pointer to lo_inode_fd()
and lo_inode_open().
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
tools/virtiofsd/passthrough_ll.c | 34 +++++++++++++++++---------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index d257eda129..bc3b803d46 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -647,7 +647,8 @@ static struct lo_inode *lo_inode(fuse_req_t req, fuse_ino_t ino)
return elem->inode;
}
-static int lo_inode_fd(const struct lo_inode *inode, TempFd *tfd)
+static int lo_inode_fd(struct lo_data *lo, const struct lo_inode *inode,
+ TempFd *tfd)
{
*tfd = (TempFd) {
.fd = inode->fd,
@@ -665,15 +666,16 @@ static int lo_inode_fd(const struct lo_inode *inode, TempFd *tfd)
static int lo_fd(fuse_req_t req, fuse_ino_t ino, TempFd *tfd)
{
struct lo_inode *inode = lo_inode(req, ino);
+ struct lo_data *lo = lo_data(req);
int res;
if (!inode) {
return -EBADF;
}
- res = lo_inode_fd(inode, tfd);
+ res = lo_inode_fd(lo, inode, tfd);
- lo_inode_put(lo_data(req), &inode);
+ lo_inode_put(lo, &inode);
return res;
}
@@ -881,7 +883,7 @@ static void lo_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
temp_fd_copy(&rw_fd, &path_fd);
}
} else {
- res = lo_inode_fd(inode, &path_fd);
+ res = lo_inode_fd(lo, inode, &path_fd);
}
if (res < 0) {
saverr = -res;
@@ -1128,7 +1130,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
name = ".";
}
- res = lo_inode_fd(dir, &dir_path_fd);
+ res = lo_inode_fd(lo, dir, &dir_path_fd);
if (res < 0) {
saverr = -res;
goto out;
@@ -1383,7 +1385,7 @@ static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent,
return;
}
- res = lo_inode_fd(dir, &dir_path_fd);
+ res = lo_inode_fd(lo, dir, &dir_path_fd);
if (res < 0) {
saverr = -res;
goto out;
@@ -1469,13 +1471,13 @@ static void lo_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t parent,
goto out;
}
- res = lo_inode_fd(inode, &path_fd);
+ res = lo_inode_fd(lo, inode, &path_fd);
if (res < 0) {
saverr = -res;
goto out;
}
- res = lo_inode_fd(parent_inode, &parent_path_fd);
+ res = lo_inode_fd(lo, parent_inode, &parent_path_fd);
if (res < 0) {
saverr = -res;
goto out;
@@ -1535,7 +1537,7 @@ static struct lo_inode *lookup_name(fuse_req_t req, fuse_ino_t parent,
goto out;
}
- res = lo_inode_fd(dir, &dir_path_fd);
+ res = lo_inode_fd(lo, dir, &dir_path_fd);
if (res < 0) {
goto out;
}
@@ -1627,13 +1629,13 @@ static void lo_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
goto out;
}
- res = lo_inode_fd(parent_inode, &parent_path_fd);
+ res = lo_inode_fd(lo, parent_inode, &parent_path_fd);
if (res < 0) {
fuse_reply_err(req, -res);
goto out;
}
- res = lo_inode_fd(newparent_inode, &newparent_path_fd);
+ res = lo_inode_fd(lo, newparent_inode, &newparent_path_fd);
if (res < 0) {
fuse_reply_err(req, -res);
goto out;
@@ -2181,7 +2183,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
return;
}
- err = lo_inode_fd(parent_inode, &parent_path_fd);
+ err = lo_inode_fd(lo, parent_inode, &parent_path_fd);
if (err < 0) {
err = -err;
goto out;
@@ -3135,7 +3137,7 @@ static void lo_getxattr(fuse_req_t req, fuse_ino_t ino, const char *in_name,
} else {
g_auto(TempFd) path_fd = TEMP_FD_INIT;
- ret = lo_inode_fd(inode, &path_fd);
+ ret = lo_inode_fd(lo, inode, &path_fd);
if (ret < 0) {
saverr = -ret;
goto out;
@@ -3215,7 +3217,7 @@ static void lo_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
} else {
g_auto(TempFd) path_fd = TEMP_FD_INIT;
- ret = lo_inode_fd(inode, &path_fd);
+ ret = lo_inode_fd(lo, inode, &path_fd);
if (ret < 0) {
saverr = -ret;
goto out;
@@ -3371,7 +3373,7 @@ static void lo_setxattr(fuse_req_t req, fuse_ino_t ino, const char *in_name,
goto out;
}
} else {
- ret = lo_inode_fd(inode, &path_fd);
+ ret = lo_inode_fd(lo, inode, &path_fd);
if (ret < 0) {
saverr = -ret;
goto out;
@@ -3486,7 +3488,7 @@ static void lo_removexattr(fuse_req_t req, fuse_ino_t ino, const char *in_name)
} else {
g_auto(TempFd) path_fd = TEMP_FD_INIT;
- ret = lo_inode_fd(inode, &path_fd);
+ ret = lo_inode_fd(lo, inode, &path_fd);
if (ret < 0) {
saverr = -ret;
goto out;
--
2.31.1
next prev parent reply other threads:[~2021-09-16 8:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 8:40 [PATCH v4 00/12] virtiofsd: Allow using file handles instead of O_PATH FDs Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 01/12] virtiofsd: Keep /proc/self/mountinfo open Hanna Reitz
2021-10-18 17:07 ` Vivek Goyal
2021-10-20 9:04 ` Hanna Reitz
2021-10-20 18:25 ` Vivek Goyal
2021-09-16 8:40 ` [PATCH v4 02/12] virtiofsd: Limit setxattr()'s creds-dropped region Hanna Reitz
2021-10-18 17:20 ` Vivek Goyal
2021-10-20 9:11 ` Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 03/12] virtiofsd: Add TempFd structure Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 04/12] virtiofsd: Use lo_inode_open() instead of openat() Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 05/12] virtiofsd: Add lo_inode_fd() helper Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 06/12] virtiofsd: Let lo_fd() return a TempFd Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 07/12] virtiofsd: Let lo_inode_open() " Hanna Reitz
2021-10-18 19:18 ` Vivek Goyal
2021-10-20 9:15 ` Hanna Reitz
2021-09-16 8:40 ` Hanna Reitz [this message]
2021-09-16 8:40 ` [PATCH v4 09/12] virtiofsd: Add lo_inode.fhandle Hanna Reitz
2021-09-16 8:40 ` [PATCH v4 10/12] virtiofsd: Add inodes_by_handle hash table Hanna Reitz
2021-10-19 20:02 ` Vivek Goyal
2021-10-20 10:02 ` Hanna Reitz
2021-10-20 12:29 ` Vivek Goyal
2021-10-20 14:10 ` Hanna Reitz
2021-10-20 18:06 ` Vivek Goyal
2021-10-20 12:53 ` Vivek Goyal
2021-09-16 8:40 ` [PATCH v4 11/12] virtiofsd: Optionally fill lo_inode.fhandle Hanna Reitz
2021-10-19 18:57 ` Vivek Goyal
2021-10-20 10:00 ` Hanna Reitz
2021-10-20 18:53 ` Vivek Goyal
2021-09-16 8:40 ` [PATCH v4 12/12] virtiofsd: Add lazy lo_do_find() Hanna Reitz
2021-10-18 18:08 ` [PATCH v4 00/12] virtiofsd: Allow using file handles instead of O_PATH FDs Vivek Goyal
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=20210916084045.31684-9-hreitz@redhat.com \
--to=hreitz@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vgoyal@redhat.com \
--cc=virtio-fs@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).