Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4656872pxv; Tue, 29 Jun 2021 12:15:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ+TA5kImDHJGQK4JY3gwqve1tPpJkKBKyRULnEnO24dEiJhB58hXyJ86BEF7Y8wykW+Mn X-Received: by 2002:a92:c84f:: with SMTP id b15mr12877996ilq.27.1624994122920; Tue, 29 Jun 2021 12:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994122; cv=none; d=google.com; s=arc-20160816; b=U1vzEJKivYaJ9oXUX+qhf68WtcYc+Yp2eWwxd8O0z+nji6K9tDXP5fh2KXdKimkSRJ I87JVGsDL7iyWx0xn2xWHAmxZB29apGeDD8ulrTjBTRJ9xK0unf+XWD6qd0+e4XZQizO x5+gBM2Zb/kvm+ccuTrxrKxf05MJQ9eUSTyW+fhDLGW9ExWz7jTEG3F11bOmnamDTqcn DSyhvIn+xP4Xajx9XdG7QmT5+tW3IkHkE/vF9vbyw/Pr3q7NSxsvExdQD2C5VI0+hx2j 4qfYhlbTzTnNTUYeey5bPl6hCUyTUshhftC7zGN/vypCaoJP41UfX1oEI19uc0OGlzhp WKfQ== 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=/pSJv/qZoP7MoMwDFRO37Y7D6x+pAul9RSjhMjrrq3k=; b=cOUJjXUxSSB8UtoZEQ0jAjtIcOPxBjOntrG9R9gJt1sUDekww3ZXB//1jPoD30o6U3 rSkpznx/Ut9tDDWoq9aHMyfeCtlFVhOM0ogxE+xIhXKe2VNVZdc8gtYu3YicqH5JSd+Q tWNtPg4YGL+lZ4ekqPSW11LY39DE9E7quBWdPsDkNd3Yqru42bPTBuNzbJJbh33U2LpD xS9F41nKSsWDo/fOzeAldnx4ABYfmsKhURghFZEIPywZRNoPXWfJrmdIwum3Bf1sFn2o 15YiJ+bcktTYmmkbP08hhi5n64Zmf9y8YB2aCflrLJ6B3bYOKfVndAEg3nYNYqJog7BR j5fw== 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 n9si22497365jap.0.2021.06.29.12.15.04; Tue, 29 Jun 2021 12:15:22 -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 S235510AbhF2TPR (ORCPT + 99 others); Tue, 29 Jun 2021 15:15:17 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34942 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbhF2TPR (ORCPT ); Tue, 29 Jun 2021 15:15:17 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 5252E1F431AF 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 10/15] fsnotify: Support FS_ERROR event type Date: Tue, 29 Jun 2021 15:10:30 -0400 Message-Id: <20210629191035.681913-11-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 Expose a new type of fsnotify event for filesystems to report errors for userspace monitoring tools. fanotify will send this type of notification for FAN_FS_ERROR events. Reviewed-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - FAN_ERROR->FAN_FS_ERROR (Amir) Changes since v1: - Overload FS_ERROR with FS_IN_IGNORED - Implement support for this type on fsnotify_data_inode (Amir) --- include/linux/fsnotify_backend.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 8222fe12a6c9..ea5f5c7cc381 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -42,6 +42,12 @@ #define FS_UNMOUNT 0x00002000 /* inode on umount fs */ #define FS_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ +#define FS_ERROR 0x00008000 /* Filesystem Error (fanotify) */ + +/* + * FS_IN_IGNORED overloads FS_ERROR. It is only used internally by inotify + * which does not support FS_ERROR. + */ #define FS_IN_IGNORED 0x00008000 /* last inotify event here */ #define FS_OPEN_PERM 0x00010000 /* open event in an permission hook */ @@ -95,7 +101,8 @@ #define ALL_FSNOTIFY_EVENTS (ALL_FSNOTIFY_DIRENT_EVENTS | \ FS_EVENTS_POSS_ON_CHILD | \ FS_DELETE_SELF | FS_MOVE_SELF | FS_DN_RENAME | \ - FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED) + FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ + FS_ERROR) /* Extra flags that may be reported with event or control handling of events */ #define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ @@ -263,6 +270,12 @@ enum fsnotify_data_type { FSNOTIFY_EVENT_NONE, FSNOTIFY_EVENT_PATH, FSNOTIFY_EVENT_INODE, + FSNOTIFY_EVENT_ERROR, +}; + +struct fs_error_report { + int error; + struct inode *inode; }; static inline struct inode *fsnotify_data_inode(const void *data, int data_type) @@ -272,6 +285,8 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type) return (struct inode *)data; case FSNOTIFY_EVENT_PATH: return d_inode(((const struct path *)data)->dentry); + case FSNOTIFY_EVENT_ERROR: + return ((struct fs_error_report *)data)->inode; default: return NULL; } -- 2.32.0