Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4657078pxv; Tue, 29 Jun 2021 12:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuE4ZZVumyqoxLhQdE67tUY7VZ8TXZOeAUlxcxk+KwjhBsV0eQammn3MkC2IMlY/PvkO8K X-Received: by 2002:a50:fd0a:: with SMTP id i10mr41755453eds.251.1624994144400; Tue, 29 Jun 2021 12:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994144; cv=none; d=google.com; s=arc-20160816; b=ZDiUS8TfrmVT3sOSgijiOGZPn4sZzcuEln/ivqcys0q3NkSYYiTHtbdt4ubPY/GpUw 64coi3Vp+bM21gGEyHXBLV9CtyryWToloB+5w5t1M0wrzswEdo3v5XzQEpe/IL+Wh9Xq LiiyGyVWWQXvtS37AWgfLyzG015O+2AIw7QgbLB/XY4dHJBUvtDtI5Rjz/Wn8TNZbqdB TdbZo23LGU9JVBK1d9ychrniM7Uz6rHZ4f3gdU9cKrRxOanMbBtvtaMceU6E9Tp+37np O1wq4dIpUr9pOqNGX0CoCYas01OpTVn1t2ovOJ5EbtRGfO5qBGrYwpI+kmuLb7VgYbm4 5+5Q== 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=pKGukfSwD57f1vvJbuA0svwYJKMnJ3C8yt1uQmAp+DA=; b=kW1m6hwFJiUqYlo89LVYanJ6n6sb9Xm4fYGilDz4DcsPdrXEqwr6fv1nvzgLhBEZ0v TUa0KtmWkYAoEvZ+1TNk/7i2YrZYkHTx0gPqMatj/bpC9YO1QwrGjKX4PNzriwU6u4f4 /wj5agG98nxT7+4/nl58uUcCzwD0RB0D/ORXqtw56IlZC0ZlKxfiZZasH5qrbD+SsuHu y4Ord1ywYJf9IZq9xhkTXeoRWCPU3zrh8V/JO/UFhvRRk253GyvtjjVBiZDxZvyrl9xX rOmkFi8Y46PjBIU5N++70jBw3h36lral7sYThR2pV8fgdh9S0fFHrFpuHDvWejR3qTNj FCDA== 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 j9si13835000edw.41.2021.06.29.12.15.20; Tue, 29 Jun 2021 12:15:44 -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 S235504AbhF2TPe (ORCPT + 99 others); Tue, 29 Jun 2021 15:15:34 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34990 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbhF2TPd (ORCPT ); Tue, 29 Jun 2021 15:15:33 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id A45CC1F431AF From: Gabriel Krisman Bertazi To: amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, jack@suse.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 v3 13/15] ext4: Send notifications on error Date: Tue, 29 Jun 2021 15:10:33 -0400 Message-Id: <20210629191035.681913-14-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210629191035.681913-1-krisman@collabora.com> References: <20210629191035.681913-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 d29f6aa7d96e..b5a8c4bab3ab 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_sb_error(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_sb_error(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_sb_error(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_sb_error(sb, sb->s_root->d_inode, errno); ext4_handle_error(sb, false, -errno, 0, 0, function, line); } -- 2.32.0