Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5106734pxb; Thu, 14 Oct 2021 19:37:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziaPVtm1PvkfshaXxoCsnpwxcBvUJ2lQtx7AxIjUii8ePO1lm+AZFHwmCsnBl9/IP5vKl3 X-Received: by 2002:a17:907:1b16:: with SMTP id mp22mr3436262ejc.503.1634265477240; Thu, 14 Oct 2021 19:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634265477; cv=none; d=google.com; s=arc-20160816; b=ClmOB8DMd7ArBDuImwXF2sQIG5FcM13Lz8gYpJAJqAQQrXGJCk3cFgB/wC1W2m4Sk5 mXq0UmJRctZCNh5k5mBqXTL2iOkyTIxOovLEO2vHdN0XN5cIxELrkJMyi4QhuCMgKNXN lFLf5JwiZVq+0ontUkzl9IlnlFIZPJU1aykGy+fmvZWyAnmfiibJrX5FD0wxXcZBWU8C ZkmBbsElIyL4CO8q8P/kWmB6AwDwS/RboDlpADCwgzVg7D7pgi93X1nNpxGq8ekb4Kt4 70Nl//VBUK5Q30h3UfqVF+FxcD+++skAO4vKK4pMg4re+RimhTiROhJA5DjJafHrFzii 9qIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=62Jk1PH3NLzg2qbBL2BGuupvllJNjt2DeC8fpMlGDp0=; b=xGyQ2/rC3cufcbgv/CmEpIsFdWpVjc0DbvD5USh4OVEZ0c3BcDUdoPz7AhJd0jdXpr yospIMfxHOi0wJdaDvSamsiGEBdnPU05kWnRtJO1BgBZ/o01bsvzcnhcIe47DleVGCOO VZW1fTvqlYc2q1H7yqTNu87kXgxGPB/ZKwIEoUG4YRzmiW+3/QnHEvxdn2GZXKaGfbEv 1fvKGusjmg+v9tWee5pe4ukyCiUmYIAtTxGO1Dh9dH0kX/IEL9YWIzQBPVvRlacrZ4Hq 6hKFx1rd/TP53XCj+f3DRWmp/Hl+znWliJG5M0ParY9YrhaiJK+Om5ctwHy3alWzz1oJ QYkA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si5771454edu.358.2021.10.14.19.37.26; Thu, 14 Oct 2021 19:37:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234066AbhJNVmI (ORCPT + 99 others); Thu, 14 Oct 2021 17:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230422AbhJNVmH (ORCPT ); Thu, 14 Oct 2021 17:42:07 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5921CC061570; Thu, 14 Oct 2021 14:40:02 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B0DE71F415A6; Thu, 14 Oct 2021 22:40:00 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v7 26/28] ext4: Send notifications on error Date: Thu, 14 Oct 2021 18:36:44 -0300 Message-Id: <20211014213646.1139469-27-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Send a FS_ERROR message via fsnotify to a userspace monitoring tool whenever a ext4 error condition is triggered. This follows the existing error conditions in ext4, so it is hooked to the ext4_error* functions. It also follows the current dmesg reporting in the format. The filesystem message is composed mostly by the string that would be otherwise printed in dmesg. A new ext4 specific record format is exposed in the uapi, such that a monitoring tool knows what to expect when listening errors of an ext4 filesystem. Signed-off-by: Gabriel Krisman Bertazi Reviewed-by: Amir Goldstein --- Changes since v6: - Report ext4_std_errors agains superblock (jan) --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 88d5d274a868..67183e6b1920 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "ext4.h" #include "ext4_extents.h" /* Needed for trace points definition */ @@ -759,6 +760,8 @@ void __ext4_error(struct super_block *sb, const char *function, sb->s_id, function, line, current->comm, &vaf); va_end(args); } + fsnotify_sb_error(sb, NULL, error); + ext4_handle_error(sb, force_ro, error, 0, block, function, line); } @@ -789,6 +792,8 @@ void __ext4_error_inode(struct inode *inode, const char *function, current->comm, &vaf); va_end(args); } + fsnotify_sb_error(inode->i_sb, inode, error); + ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block, function, line); } @@ -827,6 +832,8 @@ void __ext4_error_file(struct file *file, const char *function, current->comm, path, &vaf); va_end(args); } + fsnotify_sb_error(inode->i_sb, inode, EFSCORRUPTED); + ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block, function, line); } @@ -894,6 +901,7 @@ void __ext4_std_error(struct super_block *sb, const char *function, printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n", sb->s_id, function, line, errstr); } + fsnotify_sb_error(sb, NULL, errno); ext4_handle_error(sb, false, -errno, 0, 0, function, line); } -- 2.33.0