Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp562554pxb; Fri, 13 Aug 2021 00:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvjJVy1juHNEJZVdfsftJ9GbPpRNJCvqfIrKYb95AGbZiDwqYGPZ2TLDEflXehiqPdtxac X-Received: by 2002:a50:ed05:: with SMTP id j5mr1515780eds.256.1628841348121; Fri, 13 Aug 2021 00:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628841348; cv=none; d=google.com; s=arc-20160816; b=Fas4GKo6hwvQZC9TykaIOsnVcnnM1hGQ7bJFOTXefoB8vu9cGOOaL1kkbOFcIhyaXO 06ZkBoptB5zUf4szZebfjsu1fChvVgYkRyRn1HUkMQAf8kRPFCAueIsKIUS0zGZEqD8b eeEEHmVgm6sWGgF6h1EsftoNK6KH6LL5pGpOTvar60xMfhJFO87EqurT1pvsns1rwaHM DMbvbwv/8p4gkL107CsZFuGPNJRyGKLAjR7pjMfwkXOo4HfecOLUVhPLG+BeJ4rFBa8u gj/GITmket+l2JvENz14ydbe7W+cDmDLnXLML+hUE7bVdov6Vph+Ls3G+k8Gi6WT4dgn GHOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MUPcvao+VBLMcbahATQc4c2Hj6GHt0UJVmJ7mxM52JQ=; b=jc9oOLpF99l2YaFMO+ZJPBH05+JQmm+bjI+HPHOIdtig9o3o7zC+3SAdFa6eMDqsng tAoJo47fChMGaxBU8yijXWIn6bKqUMartcLozm1GTUpmfRfkOey54LqANaXTpVDVAGPM ZEFn2gem6UfdXbsc5YetUuysEc6iJKeTsBD+Jf9Qo9ul2vCNb6jrB0tHTr0Uy2VkVrQJ /X18k0Kg+TrLA/hkkwsPTAiFCr2pHhMGMO35JRkiCoI6jd1A0ra20Wahr7iWeqmsA81I ho942cxd7MecREEMx3OvAgOa1/EdRmOXdTBNZYeP+6E15QgNam/KrXHCd17bUqhW99AT 1A9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vcUg15tV; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds17si1262544ejc.251.2021.08.13.00.55.20; Fri, 13 Aug 2021 00:55:48 -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=@gmail.com header.s=20161025 header.b=vcUg15tV; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239780AbhHMHtg (ORCPT + 99 others); Fri, 13 Aug 2021 03:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239614AbhHMHtg (ORCPT ); Fri, 13 Aug 2021 03:49:36 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C48C061756; Fri, 13 Aug 2021 00:49:09 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id z2so9959092iln.0; Fri, 13 Aug 2021 00:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MUPcvao+VBLMcbahATQc4c2Hj6GHt0UJVmJ7mxM52JQ=; b=vcUg15tVKamX4wju606nE+FkbLMr8dgv3HdqkZwLcDcCgueO2G9Ax9TDRP6sHHAuet uOuxHV3SJsdY07NN16UMbKquEUctzUoD5EVVbKd6QkerAEby2jU8fQnMHvSVMRqR7uUC s+B4+wXwrIdcY7lGy3HxHrmc+M0HOU/3nRcxwl1bP2q+nEcNy9YBRhsKtun+Z1vCQ9Ia M6CEf+3Nu5oPlJ77NmTR8GBa0ZtWpFu8fk5ut87GmsVTqNAQ/PgjdKUZwrg6c6FkCZpR 6anBMRPdIaURyauaGCTKhWw9Wk3eWRygMJkm4hNXQgb7QqyCkxa4P3sSyvcpJUPAx1/Z tAXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MUPcvao+VBLMcbahATQc4c2Hj6GHt0UJVmJ7mxM52JQ=; b=aTjh8+9+Kqjl1xqoJMVx4/b1enBOjjt01JpJBQxyiP6XS6x/gTIhaN+2786uvKvn8Z R6fPdiBTwi652ltNHUYz4/kw2/mYZDT5XIxNlI60W62YZPy8wS+A9MaZSwNIeSkXC/Ew v4TcXXjcjsXxIYoOD4IDZcZmLPmV+xTSZqYckY49wB4oYa6ugIiXzei4l7ZcwsnsgSXg fZXvdi5ppvzMUlgNJbfUUHVuJhAomkrbv6fL2wRSqkwBOKSbq+RLwE5gKJzyqJqBprCq Ad2RqXWUD9BKij8ZRVKNdR04xvVznkFarotHcw9Wj55uAj7f11PaJTRzo/OxOn5gITgq VJ1Q== X-Gm-Message-State: AOAM5334Qs/ysRy1nSM0ZzrXCHFhKsB6ymChze6H0hjRD/IKfvW5r2Bz oDnSpBkCEnW8GX5+HMeIyW34wIAn2GSx51TyW3s= X-Received: by 2002:a92:8702:: with SMTP id m2mr960247ild.250.1628840949100; Fri, 13 Aug 2021 00:49:09 -0700 (PDT) MIME-Version: 1.0 References: <20210812214010.3197279-1-krisman@collabora.com> <20210812214010.3197279-11-krisman@collabora.com> In-Reply-To: <20210812214010.3197279-11-krisman@collabora.com> From: Amir Goldstein Date: Fri, 13 Aug 2021 10:48:58 +0300 Message-ID: Subject: Re: [PATCH v6 10/21] fsnotify: Support FS_ERROR event type To: Gabriel Krisman Bertazi Cc: Jan Kara , Linux API , Ext4 , linux-fsdevel , Khazhismel Kumykov , David Howells , Dave Chinner , Theodore Tso , "Darrick J. Wong" , Matthew Bobrowski , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Aug 13, 2021 at 12:41 AM Gabriel Krisman Bertazi wrote: > > 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. This also introduce a helper for > generating the new event. > > Signed-off-by: Gabriel Krisman Bertazi Reviewed-by: Amir Goldstein > > --- > Changes since v5: > - pass sb inside data field (jan) > Changes since v3: > - Squash patch ("fsnotify: Introduce helpers to send error_events") > - Drop reviewed-bys! > > 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) > --- > fs/notify/fsnotify.c | 3 +++ > include/linux/fsnotify.h | 13 +++++++++++++ > include/linux/fsnotify_backend.h | 18 +++++++++++++++++- > 3 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c > index 536db02cb26e..6d3b3de4f8ee 100644 > --- a/fs/notify/fsnotify.c > +++ b/fs/notify/fsnotify.c > @@ -103,6 +103,9 @@ static struct super_block *fsnotify_data_sb(const void *data, int data_type) > struct inode *inode = fsnotify_data_inode(data, data_type); > struct super_block *sb = inode ? inode->i_sb : NULL; > > + if (!sb && data_type == FSNOTIFY_EVENT_ERROR) > + sb = ((struct fs_error_report *) data)->sb; > + > return sb; > } > > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > index f8acddcf54fb..521234af1827 100644 > --- a/include/linux/fsnotify.h > +++ b/include/linux/fsnotify.h > @@ -317,4 +317,17 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) > fsnotify_dentry(dentry, mask); > } > > +static inline int fsnotify_sb_error(struct super_block *sb, struct inode *inode, > + int error) > +{ > + struct fs_error_report report = { > + .error = error, > + .inode = inode, > + .sb = sb, > + }; > + > + return fsnotify(FS_ERROR, &report, FSNOTIFY_EVENT_ERROR, > + NULL, NULL, NULL, 0); > +} > + > #endif /* _LINUX_FS_NOTIFY_H */ > diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h > index e027af3cd8dd..277b6f3e0998 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 | \ > @@ -248,6 +255,13 @@ 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; > + struct super_block *sb; > }; > > static inline struct inode *fsnotify_data_inode(const void *data, int data_type) > @@ -257,6 +271,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 >