Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp650305rbb; Sat, 24 Feb 2024 18:42:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWEjwEmJtBsIkrycLNBBcrUQx5JioJYi/pQFiXKgzU34WqlObfun6l9+klBTgoo6AEqzcasrFRE2wLIJhAk6FsESafYduHdypa5t7OEaQ== X-Google-Smtp-Source: AGHT+IGoAkE+fTtf9NZu9JWgT154wRtgZfrs+uemD6M0WFjI0liyt83qMYaNhRktPAz7tl6klyVk X-Received: by 2002:a05:622a:8d:b0:42e:79bb:b65e with SMTP id o13-20020a05622a008d00b0042e79bbb65emr2283202qtw.14.1708828973125; Sat, 24 Feb 2024 18:42:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708828973; cv=pass; d=google.com; s=arc-20160816; b=eGQOPScPo2HSBOI7ylaXHFrgbETsdrb9LL4EQyfT8P9KkM46QyeSYggZqurRVOijDI zSAtisH2JsTvDWBiFlKlQO6e0xY3SSOXxj8qiO74TRt3Mx9QKuk5ZRxEnXPGMIIykIhU mWZA+p0v9751Te60LjUj3iDLpjblT875otKtYeShvBM2OFBHSzIBtl6+RLlLfUDGBvrh S9ybvKh7MXFnIEdvo9WdXkrOHjHT00l9q3rEkz/XYog9bl8yBeOCB4CyGwD3nGPyfl1q EUj3WFir3pESMQHYhieIKx3cZP2ReyjEKmH7UcelqqsQLV++zqs9NohtzQ09LK/C8xfZ Fn3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=R05PvZLs8g3ZOV6GSh50wBEFv8JbV+JIgM3xfyBtfwY=; fh=cHCDtKbuQPXHd8MTSa2UUr5dC1B5BRlSqWWb9m+1Nbw=; b=ivrQMvSHW4ZOtvA8RH0lxtS5LzPfuytr9K2dXObr+glIGCz+T9tYg6mfpmJT4ptkca xDRa/M65DIn9p3OKl4D1qgQHNXmE5cgb9b1Ifb6nuoLCGARNO8wbzxUsfCzoDxYdYrFr NfIHcPw6+FWzyYRlc3P0iOprKOCTLv3ItLg3ystWOh5clzWVYt4T/44+Lh2M/vb3LgKP D2eMXCtGemTMghXZyCxEIVR+STXQgV6D1489b2cAKG0vsmpHPRwP5r5tdX72ddk4ihJl Qkxmo6m021Zg0i+J/wdogucnngnZVz7a1BoWc0RgdFGCADs8yLaSVsu2Q7P2arJSgTdh mR1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ABOfH9pg; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-79949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w14-20020a05620a444e00b00787cd797455si256214qkp.391.2024.02.24.18.42.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 18:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ABOfH9pg; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-79949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DBED71C20E2C for ; Sun, 25 Feb 2024 02:42:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072B41B96E; Sun, 25 Feb 2024 02:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ABOfH9pg" Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56ED8DDAD for ; Sun, 25 Feb 2024 02:38:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708828737; cv=none; b=OiDg+RUw5hItsuZG5UpjNvFwHS3+YWGaYjZVUdpKcFY7GZVGCdEQ4whF5azB6AEDhulLv+prQsBS7t5sOCtiiQmcshVIaEDXjSrolQKb7Y7PI9yJkRwS9oKqfAVLNN9qbQVYeh0Nsh6GrHGIhK43LG93fuydIAcIpLrDVJtccgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708828737; c=relaxed/simple; bh=DfA9FVN9BLpGyKYVyfilqkfCwE9P2RiMXuov2SLCyRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bafr9GcwVPQwgu0ZPjxVC1jvFBY+WgOFGf4SefzrFTzOegpk7BZMYjuqumfGoiENJMT5rtI5SXVGEXauTAHmHW8shBkM3IQvoEvJW2bMjFsx0Hq1lO2jCXcme9pNJnYb0BVBODuEW4525x+4/IpnK/yUqNr6DMQ30RyJDabzSns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ABOfH9pg; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708828733; 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=R05PvZLs8g3ZOV6GSh50wBEFv8JbV+JIgM3xfyBtfwY=; b=ABOfH9pgrb1Dn5VORYxI5KNr7K0saesLc8gSTUBUt1urNenkobzD64qE8QGOxt8XhmFwp6 4uk5NdJ08DMgkYwbothiJa4mlww9zk2RIBSiZLMd4iLL9u6pQlTm16HgnAv8jPtQmxAjCS IkUZ+qEOfB/dlGkaO9MjJJfoP/JeWWc= From: Kent Overstreet To: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet , djwong@kernel.org, bfoster@redhat.com Subject: [PATCH 21/21] bcachefs: bch2_fs_usage_base_to_text() Date: Sat, 24 Feb 2024 21:38:23 -0500 Message-ID: <20240225023826.2413565-22-kent.overstreet@linux.dev> In-Reply-To: <20240225023826.2413565-1-kent.overstreet@linux.dev> References: <20240225023826.2413565-1-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Helper to show raw accounting in sysfs, mainly for debugging. Signed-off-by: Kent Overstreet --- fs/bcachefs/sysfs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c index 10470cef30f0..27aca70cb385 100644 --- a/fs/bcachefs/sysfs.c +++ b/fs/bcachefs/sysfs.c @@ -205,6 +205,7 @@ read_attribute(disk_groups); read_attribute(has_data); read_attribute(alloc_debug); read_attribute(accounting); +read_attribute(usage_base); #define x(t, n, ...) read_attribute(t); BCH_PERSISTENT_COUNTERS() @@ -329,6 +330,20 @@ static void bch2_btree_wakeup_all(struct bch_fs *c) seqmutex_unlock(&c->btree_trans_lock); } +static void bch2_fs_usage_base_to_text(struct printbuf *out, struct bch_fs *c) +{ + struct bch_fs_usage_base b = {}; + + acc_u64s_percpu(&b.hidden, &c->usage->hidden, sizeof(b) / sizeof(u64)); + + prt_printf(out, "hidden:\t\t%llu\n", b.hidden); + prt_printf(out, "btree:\t\t%llu\n", b.btree); + prt_printf(out, "data:\t\t%llu\n", b.data); + prt_printf(out, "cached:\t%llu\n", b.cached); + prt_printf(out, "reserved:\t\t%llu\n", b.reserved); + prt_printf(out, "nr_inodes:\t%llu\n", b.nr_inodes); +} + SHOW(bch2_fs) { struct bch_fs *c = container_of(kobj, struct bch_fs, kobj); @@ -417,6 +432,9 @@ SHOW(bch2_fs) if (attr == &sysfs_accounting) bch2_fs_accounting_to_text(out, c); + if (attr == &sysfs_usage_base) + bch2_fs_usage_base_to_text(out, c); + return 0; } @@ -630,6 +648,7 @@ struct attribute *bch2_fs_internal_files[] = { &sysfs_disk_groups, &sysfs_accounting, + &sysfs_usage_base, NULL }; -- 2.43.0