Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2915315ybh; Sat, 25 Jul 2020 05:34:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx00CcviKTGs694oi7CwYUgMZ18OromIgIvX+P76IpWvLG4OU/9HgSDQ3RZ4AsBLERkq3oW X-Received: by 2002:a17:907:72c7:: with SMTP id du7mr13921575ejc.248.1595680452195; Sat, 25 Jul 2020 05:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595680452; cv=none; d=google.com; s=arc-20160816; b=bNxUlyRingnGl8tNzQXA1WbagxSKPLLtSjVl76wIt7ttgrPe0CtbSJ17J7FzKTk/tf wrWaBu5OTMmpIyUN1jRqv4O+6LPqenQpCLZUiocUDrwENGzYM44s0Ljtr/woBuNBigvV rrZLPEx9jZRFkx3ANMpexo6RxNnkXHtglYUEi381sRt7sxfbe3TKNYrbCHUUkw56uC1G zzMgvzZd/buUthRLZtlIAuZq3+QqcKZ+cjCTDHl+f7kM9fVQeQ+2mKjE3TD6SrSQcLJW hQX7WWRNJo2CBDsU8snAoePNDy3Nf//98HiHH7MfcDWxmf734/AjEstwJD/6JB/nibFL qLBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=TfCL0CFkdZVUnLf18W8f9TTEIMStg9w7tIP6qnVDzJQ=; b=PJWgptj9eeWXFAtEkX6mC0sZp2laYxD659hLfhjx5wENOv52+lC5UfDDsSWapj5YnR dL05py66x/KG2ENFTSgO+K/mRYMYZ3erxsN8cynljbjUqNVctxgqwnE2sIUv/6vxLW5S rxrjp1eZpa36sIR3XwJBkxdkKwhsdUd1BfOer5+TFZY00tUSRT9VZTBW7e7bMrC2BSwv W5SaXiNLbW84Y2M3o0yxlcYs2r4cF7kXuPFpE+Nr9TP3d3DWvxw32AGTDCF40TjTDLMn PGi03l9b7WyCHvM5S25KsV7bTtj3a1JwYZvSpvOuNBojr/xjk7l3uqL+dmpo2Xhjahze jj1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=yTpIdvhe; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si2394424eji.304.2020.07.25.05.33.33; Sat, 25 Jul 2020 05:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=yTpIdvhe; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbgGYMda (ORCPT + 99 others); Sat, 25 Jul 2020 08:33:30 -0400 Received: from forwardcorp1p.mail.yandex.net ([77.88.29.217]:37044 "EHLO forwardcorp1p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbgGYMda (ORCPT ); Sat, 25 Jul 2020 08:33:30 -0400 Received: from myt5-23f0be3aa648.qloud-c.yandex.net (myt5-23f0be3aa648.qloud-c.yandex.net [IPv6:2a02:6b8:c12:3e29:0:640:23f0:be3a]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 738F12E150C; Sat, 25 Jul 2020 15:33:23 +0300 (MSK) Received: from myt5-70c90f7d6d7d.qloud-c.yandex.net (myt5-70c90f7d6d7d.qloud-c.yandex.net [2a02:6b8:c12:3e2c:0:640:70c9:f7d]) by myt5-23f0be3aa648.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id tkF5ew7AMV-XMu8o3O4; Sat, 25 Jul 2020 15:33:23 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1595680403; bh=TfCL0CFkdZVUnLf18W8f9TTEIMStg9w7tIP6qnVDzJQ=; h=Message-Id:Date:Subject:To:From:Cc; b=yTpIdvheW/mQKsauTTW/uuLbW4P+QzWYUXRJliWdMdlEhd++bxEFXizONox23cmLI bfrzJawcB8tHqxXVoPT6zETWOnPLEffwP1M/My5cjlePyvAxdjrJ2gIAz4gT4bvLo9 LtGW2dVwGGw2D2FscfcWCvXlJ88vmjbzwhbsvIvE= Authentication-Results: myt5-23f0be3aa648.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from 95.108.174.193-red.dhcp.yndx.net (95.108.174.193-red.dhcp.yndx.net [95.108.174.193]) by myt5-70c90f7d6d7d.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id MtNvF1pJiO-XMj8gjtg; Sat, 25 Jul 2020 15:33:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) From: Dmitry Monakhov To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Dmitry Monakhov Subject: [PATCH] ext4: export msg_count and warning_count via sysfs Date: Sat, 25 Jul 2020 12:33:13 +0000 Message-Id: <20200725123313.4467-1-dmtrmonakhov@yandex-team.ru> X-Mailer: git-send-email 2.18.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This numbers can be analized by system automation similar to errors_count. In ideal world it would be nice to have separate counters for different log-levels, but this makes this patch too intrusive. Signed-off-by: Dmitry Monakhov --- fs/ext4/ext4.h | 2 ++ fs/ext4/super.c | 12 +++++++++--- fs/ext4/sysfs.c | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 99a737c..e7bef27 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1573,6 +1573,8 @@ struct ext4_sb_info { struct ratelimit_state s_err_ratelimit_state; struct ratelimit_state s_warning_ratelimit_state; struct ratelimit_state s_msg_ratelimit_state; + atomic_t s_warning_count; + atomic_t s_msg_count; /* Encryption context for '-o test_dummy_encryption' */ struct fscrypt_dummy_context s_dummy_enc_ctx; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7a5a8a5..4c408d3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -744,6 +744,7 @@ void __ext4_msg(struct super_block *sb, struct va_format vaf; va_list args; + atomic_inc(&EXT4_SB(sb)->s_msg_count); if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), "EXT4-fs")) return; @@ -754,9 +755,12 @@ void __ext4_msg(struct super_block *sb, va_end(args); } -#define ext4_warning_ratelimit(sb) \ - ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), \ - "EXT4-fs warning") +static int ext4_warning_ratelimit(struct super_block *sb) +{ + atomic_inc(&EXT4_SB(sb)->s_warning_count); + return ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), + "EXT4-fs warning"); +} void __ext4_warning(struct super_block *sb, const char *function, unsigned int line, const char *fmt, ...) @@ -4819,6 +4823,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ratelimit_state_init(&sbi->s_err_ratelimit_state, 5 * HZ, 10); ratelimit_state_init(&sbi->s_warning_ratelimit_state, 5 * HZ, 10); ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10); + atomic_set(&sbi->s_warning_count, 0); + atomic_set(&sbi->s_msg_count, 0); kfree(orig_data); return 0; diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 6c9fc9e..4f15992 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -189,6 +189,9 @@ static struct ext4_attr ext4_attr_##_name = { \ #define EXT4_RW_ATTR_SBI_UL(_name,_elname) \ EXT4_ATTR_OFFSET(_name, 0644, pointer_ul, ext4_sb_info, _elname) +#define EXT4_RO_ATTR_SBI_ATOMIC(_name,_elname) \ + EXT4_ATTR_OFFSET(_name, 0444, pointer_atomic, ext4_sb_info, _elname) + #define EXT4_ATTR_PTR(_name,_mode,_id,_ptr) \ static struct ext4_attr ext4_attr_##_name = { \ .attr = {.name = __stringify(_name), .mode = _mode }, \ @@ -226,6 +229,8 @@ EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst); #ifdef CONFIG_EXT4_DEBUG EXT4_RW_ATTR_SBI_UL(simulate_fail, s_simulate_fail); #endif +EXT4_RO_ATTR_SBI_ATOMIC(warning_count, s_warning_count); +EXT4_RO_ATTR_SBI_ATOMIC(msg_count, s_msg_count); EXT4_RO_ATTR_ES_UI(errors_count, s_error_count); EXT4_RO_ATTR_ES_U8(first_error_errcode, s_first_error_errcode); EXT4_RO_ATTR_ES_U8(last_error_errcode, s_last_error_errcode); @@ -267,6 +272,8 @@ static struct attribute *ext4_attrs[] = { ATTR_LIST(msg_ratelimit_interval_ms), ATTR_LIST(msg_ratelimit_burst), ATTR_LIST(errors_count), + ATTR_LIST(warning_count), + ATTR_LIST(msg_count), ATTR_LIST(first_error_ino), ATTR_LIST(last_error_ino), ATTR_LIST(first_error_block), -- 2.7.4