[CRIU] [RFC PATCH v2 9/9] fuse: add fuse device ioctl(FUSE_DEV_IOC_BM_REVAL)
Alexander Mikhalitsyn
aleksandr.mikhalitsyn at canonical.com
Mon Apr 3 17:45:17 MSK 2023
This ioctl allows to revalidate all the existing fuse bindmounts
by performing relookup of all root dentries and resetting them.
Useful if it's needed to make fuse bindmounts work without
remounting them after fuse connection reinitialization.
Cc: Miklos Szeredi <mszeredi at redhat.com>
Cc: Al Viro <viro at zeniv.linux.org.uk>
Cc: Amir Goldstein <amir73il at gmail.com>
Cc: Stéphane Graber <stgraber at ubuntu.com>
Cc: Seth Forshee <sforshee at kernel.org>
Cc: Christian Brauner <brauner at kernel.org>
Cc: Andrei Vagin <avagin at gmail.com>
Cc: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Cc: Bernd Schubert <bschubert at ddn.com>
Cc: linux-fsdevel at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: criu at openvz.org
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn at canonical.com>
---
fs/fuse/dev.c | 29 ++++++++++++++++++++++++++++-
include/uapi/linux/fuse.h | 1 +
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 93a457c90b49..dae4d718b03a 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -13,6 +13,7 @@
#include <linux/poll.h>
#include <linux/sched/signal.h>
#include <linux/uio.h>
+#include <linux/mnt_namespace.h>
#include <linux/miscdevice.h>
#include <linux/pagemap.h>
#include <linux/file.h>
@@ -2313,6 +2314,27 @@ static int fuse_reinit_conn(struct fuse_conn *fc)
return 0;
}
+static ssize_t fuse_revalidate_bindmounts(struct fuse_conn *fc)
+{
+ int ret = 0;
+
+ down_read(&fc->killsb);
+ if (!list_empty(&fc->mounts)) {
+ struct fuse_mount *fm;
+
+ fm = list_first_entry(&fc->mounts, struct fuse_mount, fc_entry);
+ if (!fm->sb) {
+ up_read(&fc->killsb);
+ return -EINVAL;
+ }
+
+ ret = sb_revalidate_bindmounts(fm->sb);
+ }
+ up_read(&fc->killsb);
+
+ return ret;
+}
+
void fuse_wait_aborted(struct fuse_conn *fc)
{
/* matches implicit memory barrier in fuse_drop_waiting() */
@@ -2409,6 +2431,7 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
}
break;
case FUSE_DEV_IOC_REINIT:
+ case FUSE_DEV_IOC_BM_REVAL:
struct fuse_conn *fc;
if (!checkpoint_restore_ns_capable(file->f_cred->user_ns))
@@ -2429,7 +2452,11 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
mutex_unlock(&fuse_mutex);
if (fc) {
- res = fuse_reinit_conn(fc);
+ if (cmd == FUSE_DEV_IOC_REINIT)
+ res = fuse_reinit_conn(fc);
+ else if (cmd == FUSE_DEV_IOC_BM_REVAL)
+ res = fuse_revalidate_bindmounts(fc);
+
fuse_conn_put(fc);
}
}
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 325da23431ef..d8d1997876d8 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -993,6 +993,7 @@ struct fuse_notify_retrieve_in {
#define FUSE_DEV_IOC_MAGIC 229
#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
#define FUSE_DEV_IOC_REINIT _IO(FUSE_DEV_IOC_MAGIC, 0)
+#define FUSE_DEV_IOC_BM_REVAL _IO(FUSE_DEV_IOC_MAGIC, 1)
struct fuse_lseek_in {
uint64_t fh;
--
2.34.1
More information about the CRIU
mailing list