Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp636268pxb; Tue, 19 Oct 2021 09:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBGLRJ4Zp6T+mYUaK/clEFuP42Df1inRlcatlZ4+ssW9vA6xZboImgq7iQtL2bYhoM9FMX X-Received: by 2002:aa7:c359:: with SMTP id j25mr2774107edr.348.1634662125613; Tue, 19 Oct 2021 09:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634662125; cv=none; d=google.com; s=arc-20160816; b=g6eb0hjcmFUVY5eBZmS3IwSH3leQ2xC072n/omu4ghHtVz05v0hKuBq7mPAhspJKrj gokS2uuY558sm6I/Cm8ydCw7c7QlaIDX4z7hx2z/ji8QCfviUpNcIl+KITKPGISK81gv YZfRnFOXMzDwCisWSAdXrl3QyIzDq67edfRoYWEf6MQNzGiieSyO+CWHMTQuargSj0V9 obenOYoft3t/xDJnATn8YkzVKMKn8AMOkUptQfGZhj69w12xHvwGJNfbspOf+ONHBw41 nbeiyHQ3y8r9/T8ZHgC923LWSxwrOS4JyDXXi6JNpXN3nEg2mNL2XLwqN6j2n5YAxmDB M48w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=RGaPuv31UfSY7MzqbTTvLJbAn2A/its3lnIVP/6dwtE=; b=WAE7t8Vi4TLV6cXv6E71g0A2rNHBL6Ff5Q/6EoVQtB5vpdJ4CU792FdTO/9JU/IC6+ Nd/qXg+9JUtrKmJhyicdm9lW6xqrz664CSvmz/bsc+6rrp7BuTIkDqKJkwIi8iph31u1 aoe91HVemS6huFDd8cs+Q4ycArmTKhFKi5BfSZTfrSUanAn3D41uNnwlVaSxjLUo4L0F nnhRy7YKoKoHfeXWOanQC7rpokdt8+JkEqlMOsZ3Q/Sgrucan9mpVsQ2WTcnZiHpSwux M7wDQdpX/mOpF+x/x2DTN0qYD1Zrnhjc+claNJ6DCleqioOkUyPe8XQmp7ddCxD+V+vh sq7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=iXNmh1SH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=1H582NFa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si30902015edm.164.2021.10.19.09.48.16; Tue, 19 Oct 2021 09:48:45 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=iXNmh1SH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=1H582NFa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234456AbhJSQtt (ORCPT + 99 others); Tue, 19 Oct 2021 12:49:49 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34194 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234469AbhJSQtt (ORCPT ); Tue, 19 Oct 2021 12:49:49 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E81C22196D; Tue, 19 Oct 2021 16:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1634662054; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RGaPuv31UfSY7MzqbTTvLJbAn2A/its3lnIVP/6dwtE=; b=iXNmh1SHFpPh1eTWHLRhaMCsPIzEubN1tblfc6v8Vzf4D3unWM9bNvZfN/vC9GK/O1A3Bq MWDi/PeY4tX28f1Zf+TsLpkLRhNf9nEYNESbuCYDvBgz3WL6BDd8uo31kmvDGmMJ1oJ+0k Vp6GUy9Ke/hBSob+Iihk4b+au5TQxnA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1634662054; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RGaPuv31UfSY7MzqbTTvLJbAn2A/its3lnIVP/6dwtE=; b=1H582NFamAi4ZMk1WdNvtErWxFI4KGkDrD7zoa4T5HpXx/FgcQfqUYLz+gq7lp8FjBoQ+B rSbpYyWVWRYy/1BQ== Received: from quack2.suse.cz (unknown [10.100.200.198]) by relay2.suse.de (Postfix) with ESMTP id D07FDA3B9A; Tue, 19 Oct 2021 16:47:34 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A80791E0983; Tue, 19 Oct 2021 18:47:33 +0200 (CEST) Date: Tue, 19 Oct 2021 18:47:33 +0200 From: Jan Kara To: Gabriel Krisman Bertazi Cc: jack@suse.com, amir73il@gmail.com, 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, kernel@collabora.com Subject: Re: [PATCH v8 32/32] docs: Document the FAN_FS_ERROR event Message-ID: <20211019164733.GU3255@quack2.suse.cz> References: <20211019000015.1666608-1-krisman@collabora.com> <20211019000015.1666608-33-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211019000015.1666608-33-krisman@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 18-10-21 21:00:15, Gabriel Krisman Bertazi wrote: > Document the FAN_FS_ERROR event for user administrators and user space > developers. > > Reviewed-by: Amir Goldstein > Signed-off-by: Gabriel Krisman Bertazi > > --- > Changes Since v7: > - Update semantics > Changes Since v6: > - English fixes (jan) > - Proper document error field (jan) > Changes Since v4: > - Update documentation about reporting non-file error. > Changes Since v3: > - Move FAN_FS_ERROR notification into a subsection of the file. > Changes Since v2: > - NTR > Changes since v1: > - Drop references to location record > - Explain that the inode field is optional > - Explain we are reporting only the first error > --- > .../admin-guide/filesystem-monitoring.rst | 76 +++++++++++++++++++ > Documentation/admin-guide/index.rst | 1 + > 2 files changed, 77 insertions(+) > create mode 100644 Documentation/admin-guide/filesystem-monitoring.rst > > diff --git a/Documentation/admin-guide/filesystem-monitoring.rst b/Documentation/admin-guide/filesystem-monitoring.rst > new file mode 100644 > index 000000000000..f1f6476fa4f3 > --- /dev/null > +++ b/Documentation/admin-guide/filesystem-monitoring.rst > @@ -0,0 +1,76 @@ > +.. SPDX-License-Identifier: GPL-2.0 > + > +==================================== > +File system Monitoring with fanotify > +==================================== > + > +File system Error Reporting > +=========================== > + > +Fanotify supports the FAN_FS_ERROR event type for file system-wide error > +reporting. It is meant to be used by file system health monitoring > +daemons, which listen for these events and take actions (notify > +sysadmin, start recovery) when a file system problem is detected. > + > +By design, A FAN_FS_ERROR notification exposes sufficient information ^^ a > +for a monitoring tool to know a problem in the file system has happened. > +It doesn't necessarily provide a user space application with semantics > +to verify an IO operation was successfully executed. That is out of > +scope for this feature. Instead, it is only meant as a framework for > +early file system problem detection and reporting recovery tools. > + > +When a file system operation fails, it is common for dozens of kernel > +errors to cascade after the initial failure, hiding the original failure > +log, which is usually the most useful debug data to troubleshoot the > +problem. For this reason, FAN_FS_ERROR tries to report only the first > +error that occurred for a process since the last notification, and it ^^^^^^^^ rather for "a filesystem", no? > +simply counts additional errors. This ensures that the most important > +pieces of information are never lost. > + > +FAN_FS_ERROR requires the fanotify group to be setup with the > +FAN_REPORT_FID flag. > + > +At the time of this writing, the only file system that emits FAN_FS_ERROR > +notifications is Ext4. > + > +A user space example code is provided at ``samples/fanotify/fs-monitor.c``. > + > +A FAN_FS_ERROR Notification has the following format:: > + > + [ Notification Metadata (Mandatory) ] > + [ Generic Error Record (Mandatory) ] > + [ FID record (Mandatory) ] > + I'd add a note here that the ordering of "Generic Error Record" and "FID record" is not really guaranteed and refer to sample code for sample parser. > +Generic error record > +-------------------- > + > +The generic error record provides enough information for a file system > +agnostic tool to learn about a problem in the file system, without > +providing any additional details about the problem. This record is > +identified by ``struct fanotify_event_info_header.info_type`` being set > +to FAN_EVENT_INFO_TYPE_ERROR. > + > + struct fanotify_event_info_error { > + struct fanotify_event_info_header hdr; > + __s32 error; > + __u32 error_count; > + }; > + > +The `error` field identifies the error in a file-system specific way. > +Ext4, for instance, which is the only file system implementing this > +interface at the time of this writing, exposes EXT4_ERR_ values in this > +field. Please refer to the file system documentation for the meaning of > +specific error codes. If 'error' is filesystem-specific number, then how does this work with "filesystem agnostic" tool? All it can tell is "something happened"... If the error was generic errno, I can see some value in the tool being able to tell this is fs corruption (EFSCORRUPTED), hardware problem (EIO), thin provisioning running out of space (ENOSPC) or something else. But yes, I do realize it is going to be more painful to make all filesystem generate these sensible error codes. Even within a filesystem it may be sometimes difficult to propagate proper error code to fsnotify so maybe error codes will not be usable for decisions like above... What do others think? Honza -- Jan Kara SUSE Labs, CR