From 33dc9914eac581dea9bdea35dcda4d542531d66a Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Tue, 27 Oct 2020 20:13:28 -0600 Subject: Revert series: virtiofsd: Announce submounts to the guest This reverts the following commits due to their basis on a bogus linux kernel header update: c93a656f7b65 ("tests/acceptance: Add virtiofs_submounts.py") 45ced7ca2f27 ("tests/acceptance/boot_linux: Accept SSH pubkey") 08dce386e77e ("virtiofsd: Announce sub-mount points") eba8b096c17c ("virtiofsd: Store every lo_inode's parent_dev") ede24b6be798 ("virtiofsd: Add fuse_reply_attr_with_flags()") e2577435d343 ("virtiofsd: Add attr_flags to fuse_entry_param") 2f10415abfc5 ("virtiofsd: Announce FUSE_ATTR_FLAGS") 97d741cc96dd ("linux/fuse.h: Pull in from Linux") Cc: Max Reitz Cc: Stefan Hajnoczi Cc: Dr. David Alan Gilbert Signed-off-by: Alex Williamson Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Max Reitz Message-id: 160385090886.20017.13382256442750027666.stgit@gimli.home Signed-off-by: Peter Maydell --- tools/virtiofsd/fuse_common.h | 8 ---- tools/virtiofsd/fuse_lowlevel.c | 34 +++------------- tools/virtiofsd/fuse_lowlevel.h | 20 ---------- tools/virtiofsd/helper.c | 1 - tools/virtiofsd/passthrough_ll.c | 84 ++++------------------------------------ 5 files changed, 14 insertions(+), 133 deletions(-) (limited to 'tools') diff --git a/tools/virtiofsd/fuse_common.h b/tools/virtiofsd/fuse_common.h index 870544f..686c42c 100644 --- a/tools/virtiofsd/fuse_common.h +++ b/tools/virtiofsd/fuse_common.h @@ -353,14 +353,6 @@ struct fuse_file_info { #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24) /** - * Indicates that the client will provide fuse_attr.flags, and the kernel will - * interpret it. - * - * This feature is enabled by default when supported by the kernel. - */ -#define FUSE_CAP_ATTR_FLAGS (1 << 27) - -/** * Ioctl flags * * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c index 5198f62..4d1ba29 100644 --- a/tools/virtiofsd/fuse_lowlevel.c +++ b/tools/virtiofsd/fuse_lowlevel.c @@ -329,8 +329,7 @@ static unsigned int calc_timeout_nsec(double t) } } -static void fill_entry(struct fuse_session *se, - struct fuse_entry_out *arg, +static void fill_entry(struct fuse_entry_out *arg, const struct fuse_entry_param *e) { *arg = (struct fuse_entry_out){ @@ -342,10 +341,6 @@ static void fill_entry(struct fuse_session *se, .attr_valid_nsec = calc_timeout_nsec(e->attr_timeout), }; convert_stat(&e->attr, &arg->attr); - - if (se->conn.capable & FUSE_CAP_ATTR_FLAGS) { - arg->attr.flags = e->attr_flags; - } } /* @@ -370,7 +365,7 @@ size_t fuse_add_direntry_plus(fuse_req_t req, char *buf, size_t bufsize, struct fuse_direntplus *dp = (struct fuse_direntplus *)buf; memset(&dp->entry_out, 0, sizeof(dp->entry_out)); - fill_entry(req->se, &dp->entry_out, e); + fill_entry(&dp->entry_out, e); struct fuse_dirent *dirent = &dp->dirent; *dirent = (struct fuse_dirent){ @@ -408,7 +403,7 @@ int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e) size_t size = sizeof(arg); memset(&arg, 0, sizeof(arg)); - fill_entry(req->se, &arg, e); + fill_entry(&arg, e); return send_reply_ok(req, &arg, size); } @@ -421,13 +416,13 @@ int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e, struct fuse_open_out *oarg = (struct fuse_open_out *)(buf + entrysize); memset(buf, 0, sizeof(buf)); - fill_entry(req->se, earg, e); + fill_entry(earg, e); fill_open(oarg, f); return send_reply_ok(req, buf, entrysize + sizeof(struct fuse_open_out)); } -int fuse_reply_attr_with_flags(fuse_req_t req, const struct stat *attr, - double attr_timeout, uint32_t attr_flags) +int fuse_reply_attr(fuse_req_t req, const struct stat *attr, + double attr_timeout) { struct fuse_attr_out arg; size_t size = sizeof(arg); @@ -437,19 +432,9 @@ int fuse_reply_attr_with_flags(fuse_req_t req, const struct stat *attr, arg.attr_valid_nsec = calc_timeout_nsec(attr_timeout); convert_stat(attr, &arg.attr); - if (req->se->conn.capable & FUSE_CAP_ATTR_FLAGS) { - arg.attr.flags = attr_flags; - } - return send_reply_ok(req, &arg, size); } -int fuse_reply_attr(fuse_req_t req, const struct stat *attr, - double attr_timeout) -{ - return fuse_reply_attr_with_flags(req, attr, attr_timeout, 0); -} - int fuse_reply_readlink(fuse_req_t req, const char *linkname) { return send_reply_ok(req, linkname, strlen(linkname)); @@ -2003,9 +1988,6 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, bufsize = max_bufsize; } } - if (arg->flags & FUSE_ATTR_FLAGS) { - se->conn.capable |= FUSE_CAP_ATTR_FLAGS; - } #ifdef HAVE_SPLICE #ifdef HAVE_VMSPLICE se->conn.capable |= FUSE_CAP_SPLICE_WRITE | FUSE_CAP_SPLICE_MOVE; @@ -2032,7 +2014,6 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, LL_SET_DEFAULT(1, FUSE_CAP_ASYNC_DIO); LL_SET_DEFAULT(1, FUSE_CAP_IOCTL_DIR); LL_SET_DEFAULT(1, FUSE_CAP_ATOMIC_O_TRUNC); - LL_SET_DEFAULT(1, FUSE_CAP_ATTR_FLAGS); LL_SET_DEFAULT(se->op.write_buf, FUSE_CAP_SPLICE_READ); LL_SET_DEFAULT(se->op.getlk && se->op.setlk, FUSE_CAP_POSIX_LOCKS); LL_SET_DEFAULT(se->op.flock, FUSE_CAP_FLOCK_LOCKS); @@ -2122,9 +2103,6 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, if (se->conn.want & FUSE_CAP_POSIX_ACL) { outarg.flags |= FUSE_POSIX_ACL; } - if (se->conn.want & FUSE_CAP_ATTR_FLAGS) { - outarg.flags |= FUSE_ATTR_FLAGS; - } outarg.max_readahead = se->conn.max_readahead; outarg.max_write = se->conn.max_write; if (se->conn.max_background >= (1 << 16)) { diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h index 1ff6ba1..562fd52 100644 --- a/tools/virtiofsd/fuse_lowlevel.h +++ b/tools/virtiofsd/fuse_lowlevel.h @@ -102,11 +102,6 @@ struct fuse_entry_param { * large value. */ double entry_timeout; - - /** - * Flags for fuse_attr.flags that do not fit into attr. - */ - uint32_t attr_flags; }; /** @@ -1314,21 +1309,6 @@ int fuse_reply_attr(fuse_req_t req, const struct stat *attr, double attr_timeout); /** - * Reply with attributes and set fuse_attr.flags - * - * Possible requests: - * getattr, setattr - * - * @param req request handle - * @param attr the attributes - * @param attr_timeout validity timeout (in seconds) for the attributes - * @param attr_flags flags to put into fuse_attr.flags - * @return zero for success, -errno for failure to send reply - */ -int fuse_reply_attr_with_flags(fuse_req_t req, const struct stat *attr, - double attr_timeout, uint32_t attr_flags); - -/** * Reply with the contents of a symbolic link * * Possible requests: diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c index a212f32..2e181a4 100644 --- a/tools/virtiofsd/helper.c +++ b/tools/virtiofsd/helper.c @@ -178,7 +178,6 @@ void fuse_cmdline_help(void) " default: depends on cache= option.\n" " -o writeback|no_writeback enable/disable writeback cache\n" " default: no_writeback\n" - " -o announce_submounts Announce sub-mount points to the guest\n" " -o xattr|no_xattr enable/disable xattr\n" " default: no_xattr\n" " -o modcaps=CAPLIST Modify the list of capabilities\n" diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c index 4db5004..a0beb98 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -40,7 +40,6 @@ #include "fuse_virtio.h" #include "fuse_log.h" #include "fuse_lowlevel.h" -#include "standard-headers/linux/fuse.h" #include #include #include @@ -126,14 +125,6 @@ struct lo_inode { GHashTable *posix_locks; /* protected by lo_inode->plock_mutex */ mode_t filetype; - - /* - * So we can detect crossmount roots - * (As such, this only needs to be valid for directories. Note - * that files can have multiple parents due to hard links, and so - * their parent_dev may fluctuate.) - */ - dev_t parent_dev; }; struct lo_cred { @@ -174,7 +165,6 @@ struct lo_data { int timeout_set; int readdirplus_set; int readdirplus_clear; - int announce_submounts; int allow_direct_io; struct lo_inode root; GHashTable *inodes; /* protected by lo->mutex */ @@ -213,7 +203,6 @@ static const struct fuse_opt lo_opts[] = { { "cache=always", offsetof(struct lo_data, cache), CACHE_ALWAYS }, { "readdirplus", offsetof(struct lo_data, readdirplus_set), 1 }, { "no_readdirplus", offsetof(struct lo_data, readdirplus_clear), 1 }, - { "announce_submounts", offsetof(struct lo_data, announce_submounts), 1 }, { "allow_direct_io", offsetof(struct lo_data, allow_direct_io), 1 }, { "no_allow_direct_io", offsetof(struct lo_data, allow_direct_io), 0 }, FUSE_OPT_END @@ -611,52 +600,22 @@ static void lo_init(void *userdata, struct fuse_conn_info *conn) } } -/** - * Call fstatat() and set st_rdev whenever a directory's st_dev - * differs from the rparent's st_dev (@parent_dev). This will - * announce submounts to the FUSE client (unless @announce_submounts - * is false). - */ -static int do_fstatat(int dirfd, const char *pathname, struct stat *statbuf, - int flags, dev_t parent_dev, uint32_t *fuse_attr_flags) -{ - int res = fstatat(dirfd, pathname, statbuf, flags); - if (res == -1) { - return res; - } - - if (statbuf->st_dev != parent_dev && S_ISDIR(statbuf->st_mode) && - fuse_attr_flags) - { - *fuse_attr_flags |= FUSE_ATTR_SUBMOUNT; - } - - return 0; -} - static void lo_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) { int res; struct stat buf; struct lo_data *lo = lo_data(req); - struct lo_inode *inode = lo_inode(req, ino); - uint32_t fuse_attr_flags = 0; (void)fi; - res = do_fstatat(inode->fd, "", &buf, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW, - inode->parent_dev, &fuse_attr_flags); - lo_inode_put(lo, &inode); + res = + fstatat(lo_fd(req, ino), "", &buf, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW); if (res == -1) { return (void)fuse_reply_err(req, errno); } - if (!lo->announce_submounts) { - fuse_attr_flags &= ~FUSE_ATTR_SUBMOUNT; - } - - fuse_reply_attr_with_flags(req, &buf, lo->timeout, fuse_attr_flags); + fuse_reply_attr(req, &buf, lo->timeout); } static int lo_fi_fd(fuse_req_t req, struct fuse_file_info *fi) @@ -852,16 +811,11 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, goto out_err; } - res = do_fstatat(newfd, "", &e->attr, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW, - dir->key.dev, &e->attr_flags); + res = fstatat(newfd, "", &e->attr, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW); if (res == -1) { goto out_err; } - if (!lo->announce_submounts) { - e->attr_flags &= ~FUSE_ATTR_SUBMOUNT; - } - inode = lo_find(lo, &e->attr); if (inode) { close(newfd); @@ -893,7 +847,6 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, g_hash_table_insert(lo->inodes, &inode->key, inode); pthread_mutex_unlock(&lo->mutex); } - inode->parent_dev = dir->key.dev; e->ino = inode->fuse_ino; lo_inode_put(lo, &inode); lo_inode_put(lo, &dir); @@ -1107,17 +1060,11 @@ static void lo_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t parent, goto out_err; } - res = do_fstatat(inode->fd, "", &e.attr, - AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW, - parent_inode->key.dev, &e.attr_flags); + res = fstatat(inode->fd, "", &e.attr, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW); if (res == -1) { goto out_err; } - if (!lo->announce_submounts) { - e.attr_flags &= ~FUSE_ATTR_SUBMOUNT; - } - pthread_mutex_lock(&lo->mutex); inode->nlookup++; pthread_mutex_unlock(&lo->mutex); @@ -1126,14 +1073,6 @@ static void lo_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t parent, fuse_log(FUSE_LOG_DEBUG, " %lli/%s -> %lli\n", (unsigned long long)parent, name, (unsigned long long)e.ino); - /* - * No need to update inode->parent_dev, because - * (1) We cannot, the inode now has more than one parent, - * (2) Directories cannot have more than one parent, so link() - * does not work for them; but parent_dev only needs to be - * valid for directories. - */ - fuse_reply_entry(req, &e); lo_inode_put(lo, &parent_inode); lo_inode_put(lo, &inode); @@ -1152,21 +1091,14 @@ static struct lo_inode *lookup_name(fuse_req_t req, fuse_ino_t parent, { int res; struct stat attr; - struct lo_data *lo = lo_data(req); - struct lo_inode *dir = lo_inode(req, parent); - if (!dir) { - return NULL; - } - - res = do_fstatat(dir->fd, name, &attr, - AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW, dir->key.dev, NULL); - lo_inode_put(lo, &dir); + res = fstatat(lo_fd(req, parent), name, &attr, + AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW); if (res == -1) { return NULL; } - return lo_find(lo, &attr); + return lo_find(lo_data(req), &attr); } static void lo_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name) -- cgit v1.1