Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4153747pxj; Tue, 15 Jun 2021 16:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygz4gLdGUVlIOju68icq/4nSdAl4H/RLJPmoRxhrOwAKsPb+TWDFOkt8W9mhIKuRQ4GOrB X-Received: by 2002:aa7:c450:: with SMTP id n16mr783268edr.386.1623801545901; Tue, 15 Jun 2021 16:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623801545; cv=none; d=google.com; s=arc-20160816; b=pI1Fm0urkVtApJGF3KkB1bbj4SHlEvm6MFeLGiLyq9Gi7lT25y0QCp6MFA1W38X6V9 lQfpoVPBy6Zyy4EYO2mZbwIH7WmabbrlB9cBHC7Z2x8g+m77rCQlGkUYfDk/00XIRPED q5lTCvmNtehLUY93+CYwlKqOzjit76s4oFQWIjqeaSNbCc4zKp+MryvT7u6KkWCYftVU yxF3Odvs5gELpVORjm46HOmVQOdMLGzUihKRWeJAvoekVbXv6J23FBFSZUOVgclCxkn/ Ac8Oi4eJz3YIpnBLJpQMazDaHh8jgmCWobCjsAVjNJj5pkw4AoZMJAIjJJtzJForlImP A+tA== 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=PHEDapxbZhJ2Oce9k1dMbtIC/Yn8YmguCxaCy40oJzI=; b=CnkrVkRh6gG0+BoLlN/MCtm86uUIFjCetWtVqoW5DYjXXSSZptzNTdUrSPNc3iLLkM 5w7xh9GU1eG+/NqlNcRyO/PNx16F3AFZervbQLbJP2+3E8uOZgMk3zTauALmv+BHH/S8 xvSy/H+Z1XbWrlLOo2X5s7SOSb5W5oZp9/iSyn/LR6jlygAsNgfqztLbSb4mm/bCGThl sRmlFwS7F9KCxNwuaKwsHQ7YX1kLkTm6ft6Y1Wo3DWHlrF04fYGvkaoB+KjBR/DjyC9c H2MrSUC0GwL7vzvOD9eLVadqLkGMlTJeEySK3jMhBDWfFE9Z1tzEpmBdQIe/2L8PX64T odPw== 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 4si366421ejr.388.2021.06.15.16.58.42; Tue, 15 Jun 2021 16:59:05 -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 S231718AbhFOX7A (ORCPT + 99 others); Tue, 15 Jun 2021 19:59:00 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40102 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231651AbhFOX6y (ORCPT ); Tue, 15 Jun 2021 19:58:54 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id D5E121F43345 From: Gabriel Krisman Bertazi To: amir73il@gmail.com Cc: kernel@collabora.com, 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 Subject: [PATCH v2 12/14] ext4: Send notifications on error Date: Tue, 15 Jun 2021 19:55:54 -0400 Message-Id: <20210615235556.970928-13-krisman@collabora.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210615235556.970928-1-krisman@collabora.com> References: <20210615235556.970928-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.31.0