From patchwork Thu Nov 5 02:37:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 319398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC967C2D0A3 for ; Thu, 5 Nov 2020 02:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6948E20756 for ; Thu, 5 Nov 2020 02:37:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hZQIMIy1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730344AbgKEChQ (ORCPT ); Wed, 4 Nov 2020 21:37:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30606 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbgKEChQ (ORCPT ); Wed, 4 Nov 2020 21:37:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604543835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=1dSGZzxQu3kNzQMnPsPJADY/Or7m2Kdz7OejkdDIHAc=; b=hZQIMIy1pkK4PfP88j7eoAmqxdYSzJPpYvZZDZCPj6cbFDP5iyj/QQbAtgZgv5Fip7+ZgW r63Mjwg9Lv0yk/iW+iNs6n83GdvlnvomzzkExniDaDqAXO9uRrJgb0pfVFVsGNeI4Y6XvK WShsMRKfGBOz64cjRWtdDfZo058bAAY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-wYaiYFr8PBK3snlmJPqP_g-1; Wed, 04 Nov 2020 21:37:12 -0500 X-MC-Unique: wYaiYFr8PBK3snlmJPqP_g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDDCA809DE5; Thu, 5 Nov 2020 02:37:10 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (vm37-120.gsslab.pek2.redhat.com [10.72.37.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id C75D15D994; Thu, 5 Nov 2020 02:37:08 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, zyan@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 1/2] ceph: add status debug file support Date: Wed, 4 Nov 2020 21:37:02 -0500 Message-Id: <20201105023703.735882-2-xiubli@redhat.com> In-Reply-To: <20201105023703.735882-1-xiubli@redhat.com> References: <20201105023703.735882-1-xiubli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li This will help list some useful client side info, like the client entity address/name and bloclisted status, etc. URL: https://tracker.ceph.com/issues/48057 Signed-off-by: Xiubo Li --- fs/ceph/debugfs.c | 22 ++++++++++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 23 insertions(+) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 7a8fbe3e4751..8b6db73c94ad 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "super.h" @@ -127,6 +128,20 @@ static int mdsc_show(struct seq_file *s, void *p) return 0; } +static int status_show(struct seq_file *s, void *p) +{ + struct ceph_fs_client *fsc = s->private; + struct ceph_messenger *msgr = &fsc->client->msgr; + struct ceph_entity_inst *inst = &msgr->inst; + + seq_printf(s, "status:\n\n"), + seq_printf(s, "\tinst_str:\t%s.%lld %s/%u\n", ENTITY_NAME(inst->name), + ceph_pr_addr(&inst->addr), le32_to_cpu(inst->addr.nonce)); + seq_printf(s, "\tblocklisted:\t%s\n", fsc->blocklisted ? "true" : "false"); + + return 0; +} + #define CEPH_METRIC_SHOW(name, total, avg, min, max, sq) { \ s64 _total, _avg, _min, _max, _sq, _st; \ _avg = ktime_to_us(avg); \ @@ -309,6 +324,7 @@ DEFINE_SHOW_ATTRIBUTE(mdsc); DEFINE_SHOW_ATTRIBUTE(caps); DEFINE_SHOW_ATTRIBUTE(mds_sessions); DEFINE_SHOW_ATTRIBUTE(metric); +DEFINE_SHOW_ATTRIBUTE(status); /* @@ -394,6 +410,12 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc) fsc->client->debugfs_dir, fsc, &caps_fops); + + fsc->debugfs_status = debugfs_create_file("status", + 0400, + fsc->client->debugfs_dir, + fsc, + &status_fops); } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index f097237a5ad3..5138b75923f9 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -128,6 +128,7 @@ struct ceph_fs_client { struct dentry *debugfs_bdi; struct dentry *debugfs_mdsc, *debugfs_mdsmap; struct dentry *debugfs_metric; + struct dentry *debugfs_status; struct dentry *debugfs_mds_sessions; #endif From patchwork Thu Nov 5 02:37:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 317885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F26C388F9 for ; Thu, 5 Nov 2020 02:37:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F57320756 for ; Thu, 5 Nov 2020 02:37:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Aka7GGCl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732745AbgKEChS (ORCPT ); Wed, 4 Nov 2020 21:37:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31555 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732449AbgKEChS (ORCPT ); Wed, 4 Nov 2020 21:37:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604543837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=vxLaAOiS9OMcKUlvUrWLAonff1LD/4DpDeLWNSE+F1w=; b=Aka7GGCljnsDNvDwKbBol9PGoZTihZj1pU2L4dcDmvcL7YGGjcCR1zIEj89Ry7XJd6G6ZA 0gULPA0nOfijLg0RSeXx5ZXsPjbDYSt4psKZBR0Ang7nzoBO/LNs7N3qQK36CSljWEizAn I+WpvBlRH4xUdssKFHmK3tVYa2a0thE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-r8sVILSkNHC3BsWSvIEwfw-1; Wed, 04 Nov 2020 21:37:14 -0500 X-MC-Unique: r8sVILSkNHC3BsWSvIEwfw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77BF41842146; Thu, 5 Nov 2020 02:37:13 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (vm37-120.gsslab.pek2.redhat.com [10.72.37.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 633675DA71; Thu, 5 Nov 2020 02:37:11 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, zyan@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support Date: Wed, 4 Nov 2020 21:37:03 -0500 Message-Id: <20201105023703.735882-3-xiubli@redhat.com> In-Reply-To: <20201105023703.735882-1-xiubli@redhat.com> References: <20201105023703.735882-1-xiubli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li This ioctl will return the dedicated fs and client IDs back to userspace. With this we can easily know which mountpoint the file blongs to and also they can help locate the debugfs path quickly. URL: https://tracker.ceph.com/issues/48124 Signed-off-by: Xiubo Li --- fs/ceph/ioctl.c | 22 ++++++++++++++++++++++ fs/ceph/ioctl.h | 15 +++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 6e061bf62ad4..2498a1df132e 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -268,6 +268,25 @@ static long ceph_ioctl_syncio(struct file *file) return 0; } +static long ceph_ioctl_get_client_id(struct file *file, void __user *arg) +{ + struct inode *inode = file_inode(file); + struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); + struct fs_client_ids ids; + char fsid[40]; + + snprintf(fsid, sizeof(fsid), "%pU", &fsc->client->fsid); + memcpy(ids.fsid, fsid, sizeof(fsid)); + + ids.global_id = fsc->client->monc.auth->global_id; + + /* send result back to user */ + if (copy_to_user(arg, &ids, sizeof(ids))) + return -EFAULT; + + return 0; +} + long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg); @@ -289,6 +308,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case CEPH_IOC_SYNCIO: return ceph_ioctl_syncio(file); + + case CEPH_IOC_GET_FS_CLIENT_IDS: + return ceph_ioctl_get_client_id(file, (void __user *)arg); } return -ENOTTY; diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h index 51f7f1d39a94..59c7479e77b2 100644 --- a/fs/ceph/ioctl.h +++ b/fs/ceph/ioctl.h @@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc { */ #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5) +/* + * CEPH_IOC_GET_FS_CLIENT_IDS - get the fs and client ids + * + * This ioctl will return the dedicated fs and client IDs back to + * userspace. With this we can easily know which mountpoint the file + * blongs to and also they can help locate the debugfs path quickly. + */ + +struct fs_client_ids { + char fsid[40]; + __u64 global_id; +}; +#define CEPH_IOC_GET_FS_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \ + struct fs_client_ids) + #endif