From: Yafang Shao <laoar.shao@gmail.com>
To: miklos@szeredi.hu
Cc: linux-fsdevel@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [RFC PATCH 1/2] fuse: Add "timeout" sysfs attribute for each fuse connection
Date: Wed, 24 Jul 2024 15:11:55 +0800 [thread overview]
Message-ID: <20240724071156.97188-2-laoar.shao@gmail.com> (raw)
In-Reply-To: <20240724071156.97188-1-laoar.shao@gmail.com>
A dedicated "timeout" sysfs attribute has been introduced for each fuse
connection, empowering users to manage and control the timeout duration for
individual connections.
This is a preparation for the followup patch.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
fs/fuse/control.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++-
fs/fuse/fuse_i.h | 5 ++++-
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 97ac994ff78f..247fbec72cda 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -180,6 +180,44 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
return ret;
}
+static ssize_t fuse_conn_timeout_read(struct file *file,
+ char __user *buf, size_t len,
+ loff_t *ppos)
+{
+ struct fuse_conn *fc;
+ u32 val;
+
+ fc = fuse_ctl_file_conn_get(file);
+ if (!fc)
+ return 0;
+
+ val = READ_ONCE(fc->timeout);
+ fuse_conn_put(fc);
+ return fuse_conn_limit_read(file, buf, len, ppos, val);
+}
+
+static ssize_t fuse_conn_timeout_write(struct file *file,
+ const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct fuse_conn *fc;
+ ssize_t ret;
+ u32 val;
+
+ ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
+ 3600);
+ if (ret <= 0)
+ goto out;
+ fc = fuse_ctl_file_conn_get(file);
+ if (!fc)
+ goto out;
+
+ WRITE_ONCE(fc->timeout, val);
+ fuse_conn_put(fc);
+out:
+ return ret;
+}
+
static const struct file_operations fuse_ctl_abort_ops = {
.open = nonseekable_open,
.write = fuse_conn_abort_write,
@@ -206,6 +244,13 @@ static const struct file_operations fuse_conn_congestion_threshold_ops = {
.llseek = no_llseek,
};
+static const struct file_operations fuse_conn_timeout_ops = {
+ .open = nonseekable_open,
+ .read = fuse_conn_timeout_read,
+ .write = fuse_conn_timeout_write,
+ .llseek = no_llseek,
+};
+
static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
struct fuse_conn *fc,
const char *name,
@@ -274,7 +319,10 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
1, NULL, &fuse_conn_max_background_ops) ||
!fuse_ctl_add_dentry(parent, fc, "congestion_threshold",
S_IFREG | 0600, 1, NULL,
- &fuse_conn_congestion_threshold_ops))
+ &fuse_conn_congestion_threshold_ops) ||
+ !fuse_ctl_add_dentry(parent, fc, "timeout",
+ S_IFREG | 0600, 1, NULL,
+ &fuse_conn_timeout_ops))
goto err;
return 0;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index f23919610313..367601bf7285 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -45,7 +45,7 @@
#define FUSE_NAME_MAX 1024
/** Number of dentries for each connection in the control filesystem */
-#define FUSE_CTL_NUM_DENTRIES 5
+#define FUSE_CTL_NUM_DENTRIES 6
/** List of active connections */
extern struct list_head fuse_conn_list;
@@ -917,6 +917,9 @@ struct fuse_conn {
/** IDR for backing files ids */
struct idr backing_files_map;
#endif
+
+ /* fuse request timeout */
+ u32 timeout;
};
/*
--
2.43.5
next prev parent reply other threads:[~2024-07-24 7:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 7:11 [RFC PATCH 0/2] fuse: Add timeout support for fuse connection Yafang Shao
2024-07-24 7:11 ` Yafang Shao [this message]
2024-07-24 7:11 ` [RFC PATCH 2/2] fuse: Enhance each fuse connection with timeout support Yafang Shao
2024-07-24 17:09 ` Joanne Koong
2024-07-25 2:06 ` Yafang Shao
2024-07-25 17:56 ` Joanne Koong
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=20240724071156.97188-2-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).