Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp929479pxj; Fri, 21 May 2021 02:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV+ybS89phLRJ32yD4NmxP4Fz09BptrG8uBOCyfpa5tyqZXAT3RU/FJOt1l5JdDAlV09N5 X-Received: by 2002:a17:906:5917:: with SMTP id h23mr9417360ejq.457.1621589187872; Fri, 21 May 2021 02:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621589187; cv=none; d=google.com; s=arc-20160816; b=OV6ed8EBQgnvxXKNM0BOLt6L9LpA5l7GEb/GVZvWj4q0v4NRXWQ7bNGMAJ0PG9yuFl u4sII5ptNLIdzG9Q1xgAsK8O5S0lR28awZ0u+9PWhyLqVkg3218pf5X1uPBRfjQFU18k tpYPNFzAeJ7GQlnCGlJOkKgn0BjNj+AxN1IxEwkhQxvm8UjSD0e1rMgtNKfvogNqN0XE wYayX47eGeda74lR6fSIyv7b4XTLkarilTZHGCZwyr24uXK1D6dbQkRCQxyOE9R8C7nb nN+pkvdZhrN/MaeX/2Y5cFq9WOQoKvGIWCgSrupxOpyPVYvMvlDIzPlo0hQYUxU2bpni YrkQ== 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=jgEOIuv330YjuuUf4w+VdpdOn7UrK10iFmA6lcA+Htg=; b=dqUrrYZiZ7APexuiYMu0I0wbc8WM2xEaSjriNM5pSIYBYCvlAO6qjFQ8NYVVTS5//l nT4dwWod/PkHOM/qlmlplFflGgrIdoMf9i9w9qRPLZ7mTZQHLe8dZJXhk5pUIhtVLAiX sXDX3EW5ZrwFDuM6SvidVuVkMmcVVqJExO2RvH9N3BwmAKK2m5qN0+Am8J9nneIryxNv BoAf0D0KkelbnNffn2h2zkUxptWNqXvMUhXsWC0x9WbTfMmjTjT61RulugpLyVCzZRzo jgYtecM5SFN9AnsR6YKeFh8yfC6QZVQh9exGa0EPBki40BzaTNAKCSAwOH2jPjuMbq8S awbw== 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 q13si5152197edd.354.2021.05.21.02.26.04; Fri, 21 May 2021 02:26:27 -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 S238684AbhEUCnz (ORCPT + 99 others); Thu, 20 May 2021 22:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbhEUCny (ORCPT ); Thu, 20 May 2021 22:43:54 -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 BF21CC061574; Thu, 20 May 2021 19:42:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 4579E1F43D46 From: Gabriel Krisman Bertazi To: amir73il@gmail.com Cc: Gabriel Krisman Bertazi , kernel@collabora.com, "Darrick J . Wong" , Theodore Ts'o , Dave Chinner , jack@suse.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 09/11] ext4: Send notifications on error Date: Thu, 20 May 2021 22:41:32 -0400 Message-Id: <20210521024134.1032503-10-krisman@collabora.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210521024134.1032503-1-krisman@collabora.com> References: <20210521024134.1032503-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 --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7dc94f3e18e6..a8c0ac2c3e4c 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 */ @@ -752,6 +753,8 @@ void __ext4_error(struct super_block *sb, const char *function, sb->s_id, function, line, current->comm, &vaf); va_end(args); } + fsnotify_error_event(sb, NULL, error); + ext4_handle_error(sb, force_ro, error, 0, block, function, line); } @@ -782,6 +785,8 @@ void __ext4_error_inode(struct inode *inode, const char *function, current->comm, &vaf); va_end(args); } + fsnotify_error_event(inode->i_sb, inode, error); + ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block, function, line); } @@ -820,6 +825,8 @@ void __ext4_error_file(struct file *file, const char *function, current->comm, path, &vaf); va_end(args); } + fsnotify_error_event(inode->i_sb, inode, EFSCORRUPTED); + ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block, function, line); } @@ -887,6 +894,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_error_event(sb, sb->s_root->d_inode, errno); ext4_handle_error(sb, false, -errno, 0, 0, function, line); } -- 2.31.0