From patchwork Mon Nov 25 19:46:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 11260797 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 4646E14C0 for ; Mon, 25 Nov 2019 19:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2705C2075C for ; Mon, 25 Nov 2019 19:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574711244; bh=h6Vv/bZsh5+4kB+hJZfPq5LmhISUqbIg9sn2t8rGfpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:List-ID:From; b=T1zyd22vvpfk5YUVLKOQaHuejPegbCnECThhSGyVFu7xKwu39Yvdro7VgzqnrUimB 3dZs8zr8JxV1OdO6NJLh13xmSF2tnCmXkqAdUwEXlocmHnwxGyGlKkOJCfAlo8tqna MBTXjune7Npis9YLOHKM/q07PkotnW6UU2P02+nw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbfKYTrX (ORCPT ); Mon, 25 Nov 2019 14:47:23 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41292 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727127AbfKYTrV (ORCPT ); Mon, 25 Nov 2019 14:47:21 -0500 Received: by mail-qt1-f196.google.com with SMTP id 59so13068017qtg.8 for ; Mon, 25 Nov 2019 11:47:19 -0800 (PST) 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:in-reply-to:references; bh=/uSEcZmYQD26T6L5eL2QFlCiJ6inR86K4hroBrXIOK8=; b=hkJewWn5kcaehAPRfT8vtbyR2uMbC3TVW3D05kzP1PhhEmJrVW6k5vySE8Yq4e2CZ+ vCWVDuPVs6KtAczyTPe76eneu4ORDoCS7mYQMJL+BuBaHyAhnwXyOWSUH9DB6xa03h5h lJ1i1VX4CmEYyPMue6aFa/mc+/2XQ/ktAieE5hw0iSuQDrFzPQIAr2fUlLM8TsTNbIDq OpUZSXY2ciW8YM2/VudoZ0WBQ6f4yiI5ZM5NEQkxziyW71IRLOfQsimIGcCpjagJh4Ia I0861CrUmeXhfv/o2kQFsEv3HNXXyBeOEIM/afJiRWD+L6mOfWwKsaqwZLGjVKnQW7eP GELg== X-Gm-Message-State: APjAAAWj38mN5Rc3AC8iAzWPAmBn9cee0ovBk7elOuVcGeg+O71eq27d VnBuVOihZFsfTVhH9Wy7Zy8= X-Google-Smtp-Source: APXvYqxBVVH44zODn9OWbonotPjuAyvYwgPtZoNYKiqU/uw/c6bctPBZS61K6Z5GaWsh5J0cyj2KcQ== X-Received: by 2002:ac8:6f66:: with SMTP id u6mr13690152qtv.72.1574711238734; Mon, 25 Nov 2019 11:47:18 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([163.114.130.128]) by smtp.gmail.com with ESMTPSA id o13sm4481033qto.96.2019.11.25.11.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Nov 2019 11:47:18 -0800 (PST) From: Dennis Zhou To: David Sterba , Chris Mason , Josef Bacik , Omar Sandoval Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org, Dennis Zhou Subject: [PATCH 10/22] btrfs: add discard sysfs directory Date: Mon, 25 Nov 2019 14:46:50 -0500 Message-Id: X-Mailer: git-send-email 2.13.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Setup sysfs directory for discard stats + tunables. Signed-off-by: Dennis Zhou Reviewed-by: Josef Bacik --- fs/btrfs/ctree.h | 1 + fs/btrfs/sysfs.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0c5cd5e6c2c5..6a547317d26f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -930,6 +930,7 @@ struct btrfs_fs_info { #ifdef CONFIG_BTRFS_DEBUG struct kobject *debug_kobj; + struct kobject *discard_debug_kobj; #endif }; diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index beae5c8146fb..e877e4b3c631 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -338,6 +338,13 @@ static const struct attribute_group btrfs_static_feature_attr_group = { #ifdef CONFIG_BTRFS_DEBUG +/* + * Discard statistics and tunables. + */ +static const struct attribute *discard_debug_attrs[] = { + NULL, +}; + /* * Runtime debugging exported via sysfs * @@ -776,6 +783,12 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) kobject_put(fs_info->space_info_kobj); } #ifdef CONFIG_BTRFS_DEBUG + if (fs_info->discard_debug_kobj) { + sysfs_remove_files(fs_info->discard_debug_kobj, + discard_debug_attrs); + kobject_del(fs_info->discard_debug_kobj); + kobject_put(fs_info->discard_debug_kobj); + } if (fs_info->debug_kobj) { sysfs_remove_files(fs_info->debug_kobj, btrfs_debug_mount_attrs); @@ -1131,6 +1144,19 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) btrfs_debug_mount_attrs); if (error) goto failure; + + /* Discard directory. */ + fs_info->discard_debug_kobj = kobject_create_and_add("discard", + fs_info->debug_kobj); + if (!fs_info->discard_debug_kobj) { + error = -ENOMEM; + goto failure; + } + + error = sysfs_create_files(fs_info->discard_debug_kobj, + discard_debug_attrs); + if (error) + goto failure; #endif error = addrm_unknown_feature_attrs(fs_info, true);