Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp298918pxj; Wed, 16 Jun 2021 02:40:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+bJMc9iwDN7/Z7041UmN9Zp3UAlPSHYswj5lEyr1JG57lzB9vMFv0nTs79awNuW5lZJ3X X-Received: by 2002:a05:6638:2b7:: with SMTP id d23mr3440922jaq.8.1623836411693; Wed, 16 Jun 2021 02:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623836411; cv=none; d=google.com; s=arc-20160816; b=d4SG+5fCe/BvvVZZpAnlqatFpvK3mwCEVz5UxAXcy1QsQuoNvFnEmiTQ5ZT6GQ27Vi 6E+9ciXH6HV8c4X+tShormtS/lEOvLRH8WbbrDqhisk+utCoynPS0Gyqq/MIiF24bKj0 Se1gCKOm2pCldJ3ASrMyFZIpdrLChQT4nGS3C8pyX2UIhrls/fUIryZpsPxSKyzUqlhR EymFIkIPLkdhu4z7jdmGVjoeq1171y5JNNazVtBi7yxBizJt/+XrF1DDGnIzV3CAEtE+ n/piWgPToJ8aO43Wa8N9sSE6vL8CcBOvScqn/anb2OfcAdAsORDf1RxJDwiEcEI5x1c8 O6yQ== 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=2/MvKY4Cc8ZvNy+Agqhh0BnZkqflTNCcNSEyPszszWE=; b=QTfk5cXEz8kfi5eTK3EXZmRqr61xInR5E/mkR2l09fKLlWuWu82n2+TvwokrTLidPt kLCglWHAzqU2t1p0eFxGpSkaPkZyvJPZ0EYcV2XgD7BtbW+E+PoljcrwphvTWdBWCjHV DAO7jlhIKJKC3duDFbgVqoVFHvGoUBQo5P/WqsdOQX7E+Atnaj6Gu30GJsiDAOsC7kG/ qUS6je05NjrqMHAUykwPub5OGfnLX1dHGo6bg72sG9xXy16IfgkG1+tJAZlIHbxSgAgp iw2cXAHM0o+7qbNgNZKqsU7x+rudkYbJd2pEKlfCitVJ5zc40+MQaulNEA99AOWekRN4 hurQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BCxLH9Vj; 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 h12si1811373ila.79.2021.06.16.02.39.59; Wed, 16 Jun 2021 02:40:11 -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=BCxLH9Vj; 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 S231524AbhFPJk4 (ORCPT + 99 others); Wed, 16 Jun 2021 05:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbhFPJk4 (ORCPT ); Wed, 16 Jun 2021 05:40:56 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6132EC061574; Wed, 16 Jun 2021 02:38:49 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id s26so2308458ioe.9; Wed, 16 Jun 2021 02:38:49 -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=2/MvKY4Cc8ZvNy+Agqhh0BnZkqflTNCcNSEyPszszWE=; b=BCxLH9VjmgtjKc9Vp38RV3uJWTkhfVk9L2cN0xGy3I6OnvNbdC18ZPDp7mIb9LDnqG rqG3L30hKMGkLFsgz1ohSkD1GdOnTD39CfqYIEFITXc+7fydUFXw+cRR3eCFsQTMN6lr 65qAHMy6EWY5LmaZ9W2Rfbwh5MOwEFW3Y9ZCO8WqqD04RwdC3TtfJJz9EyetqzGHRS6t raL0hZGHTVeE4XUelrG2Trp6XONROtpUQeRMngULXJtpA5FBVNGbZc0hXufWPItapiDk 2b0/iFxQljwKmJBVws+7R5rBNecAnR4n9wNrYz5bSggL/tpCNyKE7VLLqkahDENqtG++ U8Uw== 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=2/MvKY4Cc8ZvNy+Agqhh0BnZkqflTNCcNSEyPszszWE=; b=lgBz+ShUUrSLOONxuVSJtCOs17GM+ZQOmUVJ8587Yvbn2GqJVMXA+yEqcsSfPQwugw 5YRYqcl55aoYlyg1osbJ8ulv3ZDFLeBJfl4nqEBWtoTe4D2xFrxWUE+05B2BIeFic0Rp OXQZBcWvfB6Y5lzadgOpXScmSoSOLfo1tbikvsBUCJ8opNw1h7eNwaQ+2rkRs2mFf0vU mjjyQlS+8jXLxCPwa8eIs0y1ogBXIIw2U/oL1tGSoY69sBbKZKN+axOMv4o3beqwhygh nyiWT8hI6T9gq4IKr5xj5UpXYKMx/PrrG3Dwjw17Nw6uuIFWa6FvvbC7mBKWwk5Ji4L9 mZbg== X-Gm-Message-State: AOAM531MZw5k48R91pCrFSrLXLSMrNZwUClClc2TgsoawoOxpUsiyEtM w3yAxkiX0Ia6FIHD2PuOgvy0oMzXCXfljv4q7pc= X-Received: by 2002:a05:6602:2d83:: with SMTP id k3mr3009500iow.5.1623836328913; Wed, 16 Jun 2021 02:38:48 -0700 (PDT) MIME-Version: 1.0 References: <20210615235556.970928-1-krisman@collabora.com> <20210615235556.970928-11-krisman@collabora.com> In-Reply-To: <20210615235556.970928-11-krisman@collabora.com> From: Amir Goldstein Date: Wed, 16 Jun 2021 12:38:38 +0300 Message-ID: Subject: Re: [PATCH v2 10/14] fsnotify: Introduce helpers to send error_events To: Gabriel Krisman Bertazi Cc: kernel@collabora.com, "Darrick J. Wong" , Theodore Tso , Dave Chinner , Jan Kara , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Jun 16, 2021 at 2:56 AM Gabriel Krisman Bertazi wrote: > > Introduce helpers for filesystems interested in reporting FS_ERROR > events. > > Signed-off-by: Gabriel Krisman Bertazi > > --- > Changes since v1: > - Use the inode argument (Amir) > - Protect s_fsnotify_marks with ifdef guard > --- > fs/notify/fsnotify.c | 2 +- > include/linux/fsnotify.h | 20 ++++++++++++++++++++ > include/linux/fsnotify_backend.h | 1 + > 3 files changed, 22 insertions(+), 1 deletion(-) > > diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c > index 36205a769dde..ac05eb3fb368 100644 > --- a/fs/notify/fsnotify.c > +++ b/fs/notify/fsnotify.c > @@ -491,7 +491,7 @@ int __fsnotify(__u32 mask, const struct fsnotify_event_info *event_info) > */ > parent = event_info->dir; > } > - sb = inode->i_sb; > + sb = event_info->sb ?: inode->i_sb; > > /* > * Optimization: srcu_read_lock() has a memory barrier which can > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > index 8c2c681b4495..c0dbc5a65381 100644 > --- a/include/linux/fsnotify.h > +++ b/include/linux/fsnotify.h > @@ -326,4 +326,24 @@ 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) > +{ > +#ifdef CONFIG_FSNOTIFY > + if (sb->s_fsnotify_marks) { __fsnotify() has this optimization very early so you do not need it here and you do not need the ifdef. performance of fsnotify_sb_error() is utterly not important. > + struct fs_error_report report = { > + .error = error, > + .inode = inode, > + }; > + > + return __fsnotify(FS_ERROR, &(struct fsnotify_event_info) { > + .data = &report, > + .data_type = FSNOTIFY_EVENT_ERROR, > + .inode = NULL, .cookie = 0, .sb = sb No need to set members to 0/NULL with this type of initializer. Thanks, Amir.