Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3503305pxb; Mon, 18 Oct 2021 17:04:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVEVI+lzW3RldFcZrAj+mPVRtt46jO/Pgo/K5XeoE1VHZAFj+NLvDz+CbprGjZf/z+rZK+ X-Received: by 2002:a05:6a00:80c:b0:44d:90ef:e90c with SMTP id m12-20020a056a00080c00b0044d90efe90cmr25393016pfk.33.1634601899182; Mon, 18 Oct 2021 17:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601899; cv=none; d=google.com; s=arc-20160816; b=nK2UY3dTW7Ta/26vdRC/yAG6HvRquQ8BDQQFW1uCi4U94w1fwtXIWnhNHaLFnjLCFJ yyoX+MAKo7nB0hRx9G24e/Y2GMno8FNP3LvlOyx6sHDKGK/A2Ra13wZSEisnE8CJW6L/ 8DvJN71pWcDpn/MQLIB1oq/7kSCW15I6xuuyusmYVoA5/TIN6YpEkm+szbRSxYXvSYKr hbsGyR+9fhNVyuCurJdWAtC232Kks0qY0VDQDVCJn3ekFWDxqMNFDI8mk2I+I6UuBnHg XIBQ58gEnssuHa/HM5rZj0OPtRsyUg8uFTZrDkbtDkS9b/87abrqmySVV2sui19Vt3EK PFSw== 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=XLM9MoqLlVAm2IzYrG+WgzddEMtD+Uo4exN7Co30Ano=; b=Vik6aisgFbE4L8rfx0jqGdXr89UYUYp+oUoepmI8ZokYPvNDK//LBKAwc81iNXufPt 3GS9FkrUO10CRwD99CLuMGxyiZySUDQopRcJjZ4CWz8bfHY9yB3fhJkcyTcRMPt7r2P1 50bYTqx5KPcdTmaeTw1XzNppovFsa9JdzaWOwY5nz9/koz+umPLdN7YNd7ZqBjts3lPS x6nsgx7MbpkHSoqnvMHM/GQoO3JwqmyNMO98jEG+GSlaZTRZ+D2uV5s388eYOeEMkHvh XkrsJVInceSqSiTVmLaGPe77Vwzid5u43or6fyTgDWw+kzrN9s5Z4mg+h2ivkftRB7Su nVUQ== 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 y71si12245163pgd.574.2021.10.18.17.04.45; Mon, 18 Oct 2021 17:04:59 -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 S233660AbhJSAGt (ORCPT + 99 others); Mon, 18 Oct 2021 20:06:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhJSAGt (ORCPT ); Mon, 18 Oct 2021 20:06:49 -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 C48C0C06161C; Mon, 18 Oct 2021 17:04:36 -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 231451F40F21; Tue, 19 Oct 2021 01:04:34 +0100 (BST) 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 v8 30/32] ext4: Send notifications on error Date: Mon, 18 Oct 2021 21:00:13 -0300 Message-Id: <20211019000015.1666608-31-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-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. Reviewed-by: Amir Goldstein Reviewed-by: Theodore Ts'o Signed-off-by: Gabriel Krisman Bertazi --- 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