Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp211702pxt; Wed, 4 Aug 2021 09:12:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx62a+KXaKmClXWIPt7tbK9TvU4P3fpF4M9hbmIsYdSNAm4WJP6+mPB8GJ4vvda2+jjX37S X-Received: by 2002:a92:b112:: with SMTP id t18mr110121ilh.36.1628093572839; Wed, 04 Aug 2021 09:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093572; cv=none; d=google.com; s=arc-20160816; b=TzJaSJkULPz/uPOeMeeAB4H/yjMVgW/mA+yKfztk0qu5NLTS30Djkc4ndTrPMaNCJP dbkZdoUnBJ0cUbIYLIbwBwYCPoX9NlOKkF/626f1SBCobsIzyj9FdUGwvtxnU31DzOlo mftwQoNmsMfmUU486EkPcdrjjBPqlb5DNNlg+e/MNPbAFpt0WdGu2wbV1VyW/5U10rP0 1QDphFHn8SXBI7JMgKKvHElsOs8KD/ZhqU29SG0Kd6c1JOH6SLAwCGibHqZLu02d/HdL kvLtudrRXlBivKpHEsdqVgsUqxWRqqms7fz92HICaICT2Q3iesHMSEWSFxhUSoSteM+9 QIbg== 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=vi2RHSexTbfhwrfLW1wB/OPmdzL5v/Ww7yTRT9OLr1MhsEoblbECTkr3JjizDWJvfz rSaImvWNw3S3IWWW72tgMuxLWpzVh+WWmBhvMCgqNHIar1vh6124i6nSWuPNvfYEhHWJ myAeH4/iqx9n2jnc7EBiRbjJnAipHB2lGWOlB1JCfi/7goP3q4CTOJeHyvnFu1IYxkOR DCarEfhA1MYHW+VFHbpT+w5ZTHIuYH0Gd0WBuO3dtjvxEuyTReEV1PTfhYTaIUnvqsFG B6Pt1e+Af74dOL36+Uwy9sswosXU9yp5cDFD8JvCTuGTxZbbM6j79s4CzEYMKPHwz7eD 9NWw== 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 y23si1345422jak.77.2021.08.04.09.12.16; Wed, 04 Aug 2021 09:12:52 -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 S233637AbhHDQIO (ORCPT + 99 others); Wed, 4 Aug 2021 12:08:14 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42168 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbhHDQIM (ORCPT ); Wed, 4 Aug 2021 12:08:12 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 64F071F43697 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, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v5 21/23] ext4: Send notifications on error Date: Wed, 4 Aug 2021 12:06:10 -0400 Message-Id: <20210804160612.3575505-22-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210804160612.3575505-1-krisman@collabora.com> References: <20210804160612.3575505-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