From patchwork Tue Feb 19 11:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 10819755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC0DD139A for ; Tue, 19 Feb 2019 11:52:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A87A12B5BF for ; Tue, 19 Feb 2019 11:52:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CCAC2B923; Tue, 19 Feb 2019 11:52:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F55A2B5BF for ; Tue, 19 Feb 2019 11:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbfBSLwQ (ORCPT ); Tue, 19 Feb 2019 06:52:16 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54244 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfBSLwQ (ORCPT ); Tue, 19 Feb 2019 06:52:16 -0500 Received: by mail-wm1-f68.google.com with SMTP id e74so1751474wmg.3 for ; Tue, 19 Feb 2019 03:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexistor-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ph8vKEGiOH/vf7OSzJjotFH00preL4WewEOjQopbJT8=; b=q6fccEaz4h2Rz6D8d/ErsOjuVhKPqRScdIV/KlHjjtGLRFRuTqjxhYi3ZU5zQYb3mj sRkdBBOmg+m1n5cooR/DCkUTv5g9zg/vu3VfFBvefXu28UoBH3Q2FWtFJpK7WTUPsdxC E0TIky0OyyECEY1uOa4La8a1+EoTabq11O8djEUabONIq0sFwDIQ0gN8i3SN6jEBOjjL du9x6lU9kYj1d40RgJT4NpWMqZVIwpn64syZL1LVQvLInGWL1mGHS7wFyEwmWtfXsyxe okmPLAb+8d6wiy8vniq8kUVM1QJ8TR1FnaC1wOedgyPKXRY7tuPPOWgwj5EvfEHxWpVT J3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ph8vKEGiOH/vf7OSzJjotFH00preL4WewEOjQopbJT8=; b=dMF5QPmPx+79FtR9ITxN87ZJPUMry/rDwammnYgC8pHDUQSaTf7wpoG04vKadw7Bmw Q/mPSPZJrlb9WwuTy4eMjRzFGiL3NUOzuuiWWaWJl3CBSZYX9pWqmtB6y/CbFfKYdO1d sKg+ScE3ybA9QpTq3BaDz6dXXxMqrCDl3ar0XC/IZCRZk0c3HX6PAcWiPlYb2LMGvUGk svkqnhuvu2Cd22cwT+Dlmmn+rBV6WkQ/JyVjuR7uC62E7xdsgrn4tkYh0qRgPY2huW8x yWi3pW1MW4u/O5WCA1Y94UmrRcvH8w+NZCdPqBoKb6dDWQCQD/0hzWzKkx+oEJu9K2r7 BJPw== X-Gm-Message-State: AHQUAub6lAegVxC4B/P6Q+GLUDXZadzYMHCzx1N6sumV3EHgLQFWYS4R d+YuE85E5hgxGwuaK6kBMDe8Gj4fImA= X-Google-Smtp-Source: AHgI3IZxoXfRWCeOaSQeeLYLcrKDSbzDOsSbE2NsEu+OquhWg7xR/BgQWqWLyLK+HH/eB+08npeWYQ== X-Received: by 2002:a1c:9aca:: with SMTP id c193mr2559970wme.2.1550577133380; Tue, 19 Feb 2019 03:52:13 -0800 (PST) Received: from Bfire.plexistor.com ([207.232.55.62]) by smtp.gmail.com with ESMTPSA id t18sm3605830wmt.8.2019.02.19.03.52.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 19 Feb 2019 03:52:12 -0800 (PST) From: Boaz harrosh To: linux-fsdevel , Anna Schumaker , Al Viro Cc: Ric Wheeler , Miklos Szeredi , Steven Whitehouse , Jefff moyer , Amir Goldstein , Amit Golander , Sagi Manole Subject: [RFC PATCH 17/17] zuf: Support for dynamic-debug of zusFSs Date: Tue, 19 Feb 2019 13:51:36 +0200 Message-Id: <20190219115136.29952-18-boaz@plexistor.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190219115136.29952-1-boaz@plexistor.com> References: <20190219115136.29952-1-boaz@plexistor.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Boaz Harrosh 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 --- 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)