From patchwork Tue Jan 28 13:02:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 11354241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 989C0112B for ; Tue, 28 Jan 2020 13:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 779FE24683 for ; Tue, 28 Jan 2020 13:03:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PYXAaRYr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726143AbgA1NDs (ORCPT ); Tue, 28 Jan 2020 08:03:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21888 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726034AbgA1NDs (ORCPT ); Tue, 28 Jan 2020 08:03:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580216627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qT0u0w/rIGkT+szIUYmmBy4V5W+EnHMTgs0zakAMYac=; b=PYXAaRYr1Oy5CetBslb4+1zUQKunUEmyGiz2JC8iowMNUB33CESbTShOHo8vliN31SVRbi Vmhgb9tKTgtNI8mgdF6aAyBToPRIdEddJnc4Fpog5WAOHreR80fI8kCTNdtB8OPWG3XmHA SKgB3CFj3ZUcxwP2fSefG3lHo0uiK/c= 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-69-eb1wbxVsMKaG20KWkbeFUg-1; Tue, 28 Jan 2020 08:03:45 -0500 X-MC-Unique: eb1wbxVsMKaG20KWkbeFUg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13A21107ACC5; Tue, 28 Jan 2020 13:03:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57E8E80A5C; Tue, 28 Jan 2020 13:03:41 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org, idryomov@gmail.com, zyan@redhat.com Cc: sage@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH v5 09/10] ceph: add reset metrics support Date: Tue, 28 Jan 2020 08:02:47 -0500 Message-Id: <20200128130248.4266-10-xiubli@redhat.com> In-Reply-To: <20200128130248.4266-1-xiubli@redhat.com> References: <20200128130248.4266-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li This will reset the most metric counters, except the cap and dentry total numbers. Sometimes we need to discard the old metrics and start to get new metrics. URL: https://tracker.ceph.com/issues/43215 Signed-off-by: Xiubo Li --- fs/ceph/debugfs.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-- fs/ceph/super.h | 1 + 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 8aae7ecea54a..37ca1efa6b27 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -217,6 +217,55 @@ static int metric_show(struct seq_file *s, void *p) return 0; } +static ssize_t metric_store(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct seq_file *s = file->private_data; + struct ceph_fs_client *fsc = s->private; + struct ceph_mds_client *mdsc = fsc->mdsc; + struct ceph_client_metric *metric = &mdsc->metric; + char buf[8]; + int i; + + if (copy_from_user(buf, user_buf, 8)) + return -EFAULT; + + if (strcmp(buf, "reset")) { + pr_err("Invalid set value '%s', only 'reset' is valid\n", buf); + return -EINVAL; + } + + percpu_counter_set(&metric->d_lease_hit, 0); + percpu_counter_set(&metric->d_lease_mis, 0); + + percpu_counter_set(&metric->read_latency_sum, 0); + percpu_counter_set(&metric->total_reads, 0); + + percpu_counter_set(&metric->write_latency_sum, 0); + percpu_counter_set(&metric->total_writes, 0); + + percpu_counter_set(&metric->metadata_latency_sum, 0); + percpu_counter_set(&metric->total_metadatas, 0); + + mutex_lock(&mdsc->mutex); + for (i = 0; i < mdsc->max_sessions; i++) { + struct ceph_mds_session *session; + + session = __ceph_lookup_mds_session(mdsc, i); + if (!session) + continue; + percpu_counter_set(&session->i_caps_hit, 0); + percpu_counter_set(&session->i_caps_mis, 0); + ceph_put_mds_session(session); + } + + mutex_unlock(&mdsc->mutex); + + return 0; +} + +CEPH_DEFINE_RW_FUNC(metric) + static int caps_show_cb(struct inode *inode, struct ceph_cap *cap, void *p) { struct seq_file *s = p; @@ -313,7 +362,6 @@ static int mds_sessions_show(struct seq_file *s, void *ptr) CEPH_DEFINE_SHOW_FUNC(mdsmap_show) CEPH_DEFINE_SHOW_FUNC(mdsc_show) -CEPH_DEFINE_SHOW_FUNC(metric_show) CEPH_DEFINE_SHOW_FUNC(caps_show) CEPH_DEFINE_SHOW_FUNC(mds_sessions_show) @@ -349,6 +397,7 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) debugfs_remove(fsc->debugfs_caps); debugfs_remove(fsc->debugfs_metric); debugfs_remove(fsc->debugfs_sending_metrics); + debugfs_remove(fsc->debugfs_reset_metrics); debugfs_remove(fsc->debugfs_mdsc); } @@ -400,7 +449,7 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc) 0400, fsc->client->debugfs_dir, fsc, - &metric_show_fops); + &metric_fops); fsc->debugfs_caps = debugfs_create_file("caps", 0400, diff --git a/fs/ceph/super.h b/fs/ceph/super.h index a91431e9bdf7..d24929f1c4bf 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -129,6 +129,7 @@ struct ceph_fs_client { struct dentry *debugfs_bdi; struct dentry *debugfs_mdsc, *debugfs_mdsmap; struct dentry *debugfs_sending_metrics; + struct dentry *debugfs_reset_metrics; struct dentry *debugfs_metric; struct dentry *debugfs_mds_sessions; #endif