Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4681709pxv; Tue, 20 Jul 2021 09:13:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxx2A1CzHX1xkJG7IU7wR6dt/TkqheLMuHXF+us9/y5mTGREuogBiiEmVwUHgHWEviLnWk X-Received: by 2002:a05:6638:c58:: with SMTP id g24mr26854161jal.63.1626797597026; Tue, 20 Jul 2021 09:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626797597; cv=none; d=google.com; s=arc-20160816; b=LQlR5jf8G4ZGPtiksaShgi+TWZ9qKIn0iF9flLZbo9qwCEdgivwKyiRzB3VZaCi3Kv vSHon4FokaO/2PT2o0T0QKggG8G6AMl5EbKBupSJoZC4W8l+KYtgxapsuilWuCCSBNOT CBilBU6VMzbI094Ih4ypMVrI1H16yx//AO5og+Ve7QLD7IP20oLjUm7w0ieNKRKGC8DX 2+6OEW9GQSWHNIXpgPRVX7jge4i6hLWPiWbTmfKTFCUi7OPIgEMMn8IIMhOl6SXhAkzS ZzBVb2oSZJ91zF6X2LKNE3bOFvKC4kzxxnpuoE/Oq0qmRxBeUXSV4vGCZYa6SAPqLUy4 N43w== 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=1bX9u2cWFiGFrB35V5V4laGiCrwQXKXxaGZGYp127oo=; b=ugMlMWkPciI6ZZeCXkzr6A0VgIH2dtDxz0ZeFIEytfbRJ7L5ffs7OtsqJ9kHyrG3kR tRrzqSDDCgToVm+lARESoCKwDzXCgQ4MYEC64lNU1B83DHcOjo45lpfzklpUOFxedDC3 BcJaWVq5Sv6mncNXu/8xoOV+g9AGGMjZ55LsVQUJTfVh7x8VRZoKe6RFDdmDZjWJVXMe TRI7EP9cnOsSP3HRJnu1/o3FvmGiMV3KGd+sd8AwkL73eYZnXgab8MDiKZ2vgX7zfkRX dtcOFw1xRy3urPdv1kK2gjih7zDTjazJLJkFF2Lpm5Zcj3kEaSzayUhPdD8uTKhMSlul w4ow== 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 g4si20504631jat.17.2021.07.20.09.13.04; Tue, 20 Jul 2021 09:13:17 -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 S229631AbhGTPbY (ORCPT + 99 others); Tue, 20 Jul 2021 11:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240531AbhGTPUo (ORCPT ); Tue, 20 Jul 2021 11:20:44 -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 46DC1C061768; Tue, 20 Jul 2021 09:00:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id D74211F43149 From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v4 14/16] ext4: Send notifications on error Date: Tue, 20 Jul 2021 11:59:42 -0400 Message-Id: <20210720155944.1447086-15-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210720155944.1447086-1-krisman@collabora.com> References: <20210720155944.1447086-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 --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dfa09a277b56..b9ecd43678d7 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 */ @@ -762,6 +763,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); } @@ -792,6 +795,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); } @@ -830,6 +835,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); } @@ -897,6 +904,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, sb->s_root->d_inode, errno); ext4_handle_error(sb, false, -errno, 0, 0, function, line); } -- 2.32.0