Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp265736pxb; Thu, 12 Aug 2021 16:06:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKPmtC13Ow/cU7mkGy3Q9cIkwXVK4C0IXVOTQcmSpTChOgKduk6MF1p/M/olUZ5daH8n5+ X-Received: by 2002:a05:6638:974:: with SMTP id o20mr5823144jaj.10.1628809578898; Thu, 12 Aug 2021 16:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628809578; cv=none; d=google.com; s=arc-20160816; b=WAgH/tVBBi1thDSNqPnsOIU6cWCHmNzb7ww4O+urpVYqGfHWC6SB3UHobTQhvw/cno 5si3l3xablUF7my4ORLICkSx4BlUSVKCHIL1ksJ0Rq5xTQlOcC7PeVz87tDOLfUp386H AC/Z1F/ozG3bS0De+1hncM+bgOY+wD+ObVFkeXh2Mizkmi+nN9CjbDZyleJbnCQcOIa4 O3PwCFUxuMeJAnzPRb+Os15gPZlkaLARXUDuVZqcGntraXCKAQ6rP4yYZRPzrMqe6IcI HflDhTEjsKNenlW+amgNhcXCbWQqnWR0HUM55dh3wr/O+ZgtNW4rr9O9uUffFUsrZ4D0 ItNw== 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=WAHaTI/CjdC1kDrCSR8Sv9cdqSu+9LfDD/bcLq9a5kpBoqM/tJzgUlMPt+dOLzbuKm o3ezanoCb1x6pS+IZFA3XiV+S2PdI/HshkzmztA+4TzLikdKjNsKtt3m5l9C0qjYZQCD z0AbQ0VNEMK1c6eV5EaCZVo/5PVi/w+Yy0wTku7NwJdHx5O89Bk1xhF5cAEOCH/U1q17 DImlD2ynVSkA2CVly0aCgRMerdtdrMd/oW8g3gg2AFExwYBNXS3evGC+iQ+XCunwJAia Ar8a10AdPqfFFzK04jVBF0q+oWIoweU0V0O+oJYvN5TKZIAkp8BZeD+dNf5GxRh4KuPt h8Ug== 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 d7si5358326ilg.118.2021.08.12.16.06.06; Thu, 12 Aug 2021 16:06:18 -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 S235297AbhHLVmN (ORCPT + 99 others); Thu, 12 Aug 2021 17:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238058AbhHLVmM (ORCPT ); Thu, 12 Aug 2021 17:42:12 -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 2A605C061756; Thu, 12 Aug 2021 14:41:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id B699E1F41890 From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, khazhy@google.com, dhowells@redhat.com, david@fromorbit.com, tytso@mit.edu, djwong@kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v6 19/21] ext4: Send notifications on error Date: Thu, 12 Aug 2021 17:40:08 -0400 Message-Id: <20210812214010.3197279-20-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812214010.3197279-1-krisman@collabora.com> References: <20210812214010.3197279-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