Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4656980pxv; Tue, 29 Jun 2021 12:15:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcg/EZVuWGqbvfVbUmr3y26Y2ZU3CSDZNyhqoY2nomI2Q+RsNXlaYerb7jCimxbXbtcWU+ X-Received: by 2002:a17:907:3e28:: with SMTP id hp40mr1857973ejc.381.1624994134899; Tue, 29 Jun 2021 12:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994134; cv=none; d=google.com; s=arc-20160816; b=J0rJitKkQtMU7uPpCgwRuYuJlpKJ2llIll6rKZZ0HsR1OZpKVjIk7NUGSpWBi2ylU8 UGnSB39uIUZ1oD8xMvSSBRgfZnrZ/cnHVGxvjlp/BXP5hGgFbk+va25kwqcy4LpFyecO 5w30upQXow+xC9Xcl3nuWhcek8CEDUN4VsV9ZEGHUe7OdRFPbwxII16+YTP9mzqYWxpl TzfQ9ncIxWpljbhGYtsUM1ZuekRLklc8obWaQ5VubzXX8uMSTR71i45pQpmV3vTmA8Sy OFWE9kMIByA7zSlTx0HR1Y3yC8gV+COgp/SbX/exjxCvfoJYPyIAnXJT+Dzps6NV9FPj iR3g== 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=I7HpNdCABg+0kkoKVNHVs8OVAu6BID31S5Gh41nolUE=; b=FpU/8abPzKTguH62/c+UbP8gc0yW2GOaH2huPAtSobmPJrMVF5CbeX6W0vvbuW6tlq 3Guz67A6nXxwvIs6tP+gW7+Q/k98rxhkAZ5kqybyxh6azty9hDkm9Vdg3J7OsVQ6BbFc ofSf3sIkQ3bPzCE3ImIpCXx/gvB6Kzwy9CkaeoIMfLTbgtehzCqbeX8wEWgmSdzDcoLI +unSYXw2hprYmumyiD43zDB+n6fUlMlgUBYckpH5STR2xef42yJgpXddT71uEFUulDZ0 Q81S18EqQEcXhmIMnVK2ko71e9N4Wfi0ug9ub6EYvpPAaHJflsBMlsRm8QmMDwG4acvk 9mPw== 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 h9si8994215edb.389.2021.06.29.12.15.10; Tue, 29 Jun 2021 12:15:34 -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 S235515AbhF2TPY (ORCPT + 99 others); Tue, 29 Jun 2021 15:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235504AbhF2TPX (ORCPT ); Tue, 29 Jun 2021 15:15:23 -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 A6EBFC061760; Tue, 29 Jun 2021 12:12:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 224C81F431AF 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 11/15] fsnotify: Introduce helpers to send error_events Date: Tue, 29 Jun 2021 15:10:31 -0400 Message-Id: <20210629191035.681913-12-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 Introduce helpers for filesystems interested in reporting FS_ERROR events. When notifying errors, the file system might not have an inode to report on the error. To support this, allow the caller to specify the superblock to which the error applies. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Drop reference to s_fnotify_marks and guards (Amir) Changes since v1: - Use the inode argument (Amir) - Protect s_fsnotify_marks with ifdef guard --- fs/notify/fsnotify.c | 2 +- include/linux/fsnotify.h | 13 +++++++++++++ include/linux/fsnotify_backend.h | 1 + 3 files changed, 15 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..684c79ca01b2 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -326,4 +326,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, + }; + + return __fsnotify(FS_ERROR, &(struct fsnotify_event_info) { + .data = &report, .data_type = FSNOTIFY_EVENT_ERROR, + .sb = sb}); +} + #endif /* _LINUX_FS_NOTIFY_H */ diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index ea5f5c7cc381..5a32c5010f45 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -138,6 +138,7 @@ struct fsnotify_event_info { struct inode *dir; const struct qstr *name; struct inode *inode; + struct super_block *sb; u32 cookie; }; -- 2.32.0