From: Boaz harrosh <boaz@plexistor.com>
To: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Anna Schumaker <Anna.Schumaker@netapp.com>,
Al Viro <viro@zeniv.linux.org.uk>
Cc: Ric Wheeler <rwheeler@redhat.com>,
Miklos Szeredi <mszeredi@redhat.com>,
Steven Whitehouse <swhiteho@redhat.com>,
Jefff moyer <jmoyer@redhat.com>,
Amir Goldstein <amir73il@gmail.com>,
Amit Golander <Amit.Golander@netapp.com>,
Sagi Manole <sagim@netapp.com>
Subject: [RFC PATCH 17/17] zuf: Support for dynamic-debug of zusFSs
Date: Tue, 19 Feb 2019 13:51:36 +0200 [thread overview]
Message-ID: <20190219115136.29952-18-boaz@plexistor.com> (raw)
In-Reply-To: <20190219115136.29952-1-boaz@plexistor.com>
From: Boaz Harrosh <boazh@netapp.com>
In zus we support dynamic-debug prints. ie user can
turn on and off the prints at run time by writing
to some special files.
The API is exactly the same as the Kernel's dynamic-prints
only the special file that we perform read/write on is:
/sys/fs/zuf/ddbg
But otherwise it is identical to Kernel.
The Kernel code is a thin wrapper to dispatch to/from
the read/write of /sys/fs/zuf/ddbg file to the zus
server.
The heavy lifting is done by the zus project build system
and core code. See zus project how this is done
This facility is dispatched on the mount-thread and not
the regular ZTs. Because it is available globally before
any mounts.
Signed-off-by: Boaz Harrosh <boazh@netapp.com>
---
fs/zuf/zuf-core.c | 1 +
fs/zuf/zuf-root.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++
fs/zuf/zus_api.h | 12 +++++++-
3 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/fs/zuf/zuf-core.c b/fs/zuf/zuf-core.c
index 2afccfcf90bb..a9034bb196db 100644
--- a/fs/zuf/zuf-core.c
+++ b/fs/zuf/zuf-core.c
@@ -777,6 +777,7 @@ const char *zuf_op_name(enum e_zufs_operation op)
CASE_ENUM_NAME(ZUFS_OP_READDIR );
CASE_ENUM_NAME(ZUFS_OP_CLONE );
CASE_ENUM_NAME(ZUFS_OP_COPY );
+
CASE_ENUM_NAME(ZUFS_OP_READ );
CASE_ENUM_NAME(ZUFS_OP_PRE_READ );
CASE_ENUM_NAME(ZUFS_OP_WRITE );
diff --git a/fs/zuf/zuf-root.c b/fs/zuf/zuf-root.c
index 37b70ca33d3c..5c8c4af1a7e7 100644
--- a/fs/zuf/zuf-root.c
+++ b/fs/zuf/zuf-root.c
@@ -79,6 +79,82 @@ static void _fs_type_free(struct zuf_fs_type *zft)
}
#endif /*CONFIG_LOCKDEP*/
+#define DDBG_MAX_BUF_SIZE (8 * PAGE_SIZE)
+/* We use ppos as a cookie for the dynamic debug ID we want to read from */
+static ssize_t _zus_ddbg_read(struct file *file, char __user *buf, size_t len,
+ loff_t *ppos)
+{
+ struct zufs_ioc_mount *zim;
+ size_t buf_size = (DDBG_MAX_BUF_SIZE <= len) ? DDBG_MAX_BUF_SIZE : len;
+ size_t zim_size = sizeof(zim->hdr) + sizeof(zim->zdi);
+ ssize_t err;
+
+ zim = vzalloc(zim_size + buf_size);
+ if (unlikely(!zim))
+ return -ENOMEM;
+
+ /* null terminate the 1st character in the buffer, hence the '+ 1' */
+ zim->hdr.in_len = zim_size + 1;
+ zim->hdr.out_len = zim_size + buf_size;
+ zim->zdi.len = buf_size;
+ zim->zdi.id = *ppos;
+ *ppos = 0;
+
+ err = __zufc_dispatch_mount(ZRI(file->f_inode->i_sb), ZUFS_M_DDBG_RD,
+ zim);
+ if (unlikely(err)) {
+ zuf_err("error dispatching contorl message => %ld\n", err);
+ goto out;
+ }
+
+ err = simple_read_from_buffer(buf, zim->zdi.len, ppos, zim->zdi.msg,
+ buf_size);
+ if (unlikely(err <= 0))
+ goto out;
+
+ *ppos = zim->zdi.id;
+out:
+ vfree(zim);
+ return err;
+}
+
+static ssize_t _zus_ddbg_write(struct file *file, const char __user *buf,
+ size_t len, loff_t *ofst)
+{
+ struct _ddbg_info {
+ struct zufs_ioc_mount zim;
+ char buf[512];
+ } ddi = {};
+ ssize_t err;
+
+ if (unlikely(512 < len)) {
+ zuf_err("ddbg control message to long\n");
+ return -EINVAL;
+ }
+
+ memset(&ddi, 0, sizeof(ddi));
+ if (copy_from_user(ddi.zim.zdi.msg, buf, len))
+ return -EFAULT;
+
+ ddi.zim.hdr.in_len = sizeof(ddi);
+ ddi.zim.hdr.out_len = sizeof(ddi.zim);
+ err = __zufc_dispatch_mount(ZRI(file->f_inode->i_sb), ZUFS_M_DDBG_WR,
+ &ddi.zim);
+ if (unlikely(err)) {
+ zuf_err("error dispatching contorl message => %ld\n", err);
+ return err;
+ }
+
+ return len;
+}
+
+static const struct file_operations _zus_ddbg_ops = {
+ .open = nonseekable_open,
+ .read = _zus_ddbg_read,
+ .write = _zus_ddbg_write,
+ .llseek = no_llseek,
+};
+
int zufr_register_fs(struct super_block *sb, struct zufs_ioc_register_fs *rfs)
{
struct zuf_fs_type *zft = _fs_type_alloc();
@@ -256,6 +332,7 @@ static const struct super_operations zufr_super_operations = {
static int zufr_fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr zufr_files[] = {
+ [2] = {"ddbg", &_zus_ddbg_ops, S_IFREG | 0600},
{""},
};
struct zuf_root_info *zri;
diff --git a/fs/zuf/zus_api.h b/fs/zuf/zus_api.h
index 95fb5c35cde5..14ada4c760ae 100644
--- a/fs/zuf/zus_api.h
+++ b/fs/zuf/zus_api.h
@@ -268,10 +268,20 @@ struct zufs_mount_info {
struct zufs_parse_options po;
};
+struct zufs_ddbg_info {
+ __u64 id; /* IN where to start from, OUT last ID */
+ /* IN size of buffer, OUT size of dynamic debug message */
+ __u64 len;
+ char msg[0];
+};
+
/* mount / umount */
struct zufs_ioc_mount {
struct zufs_ioc_hdr hdr;
- struct zufs_mount_info zmi;
+ union {
+ struct zufs_mount_info zmi;
+ struct zufs_ddbg_info zdi;
+ };
};
#define ZU_IOC_MOUNT _IOWR('Z', 11, struct zufs_ioc_mount)
--
2.20.1
next prev parent reply other threads:[~2019-02-19 11:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 11:51 [RFC PATCH 00/17] zuf: ZUFS Zero-copy User-mode FileSystem Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License Boaz harrosh
2019-02-20 11:03 ` Greg KH
2019-02-20 14:55 ` Boaz Harrosh
2019-02-20 19:40 ` Greg KH
2019-02-26 17:55 ` Schumaker, Anna
2019-02-28 16:42 ` Boaz Harrosh
2019-02-19 11:51 ` [RFC PATCH 02/17] zuf: Preliminary Documentation Boaz harrosh
2019-02-20 8:27 ` Miklos Szeredi
2019-02-20 14:24 ` Boaz Harrosh
2019-02-19 11:51 ` [RFC PATCH 03/17] zuf: zuf-rootfs Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 04/17] zuf: zuf-core The ZTs Boaz harrosh
2019-02-26 18:34 ` Schumaker, Anna
2019-02-28 17:01 ` Boaz Harrosh
2019-02-19 11:51 ` [RFC PATCH 05/17] zuf: Multy Devices Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 06/17] zuf: mounting Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 07/17] zuf: Namei and directory operations Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 08/17] zuf: readdir operation Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 09/17] zuf: symlink Boaz harrosh
2019-02-20 11:05 ` Greg KH
2019-02-20 14:12 ` Boaz Harrosh
2019-02-19 11:51 ` [RFC PATCH 10/17] zuf: More file operation Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 11/17] zuf: Write/Read implementation Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 12/17] zuf: mmap & sync Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 13/17] zuf: ioctl implementation Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 14/17] zuf: xattr implementation Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 15/17] zuf: ACL support Boaz harrosh
2019-02-19 11:51 ` [RFC PATCH 16/17] zuf: Special IOCTL fadvise (TODO) Boaz harrosh
2019-02-19 11:51 ` Boaz harrosh [this message]
2019-02-19 12:15 ` [RFC PATCH 00/17] zuf: ZUFS Zero-copy User-mode FileSystem Matthew Wilcox
2019-02-19 19:15 ` Boaz Harrosh
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=20190219115136.29952-18-boaz@plexistor.com \
--to=boaz@plexistor.com \
--cc=Amit.Golander@netapp.com \
--cc=Anna.Schumaker@netapp.com \
--cc=amir73il@gmail.com \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=rwheeler@redhat.com \
--cc=sagim@netapp.com \
--cc=swhiteho@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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).