Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5061905pxb; Thu, 14 Oct 2021 18:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMU2o8QnvVif0gKF+38E9r1gpqdIIumkyM/4Jgyd7hOh/lrux2W3LZ9Mjk7LsZcWSUQsWk X-Received: by 2002:a62:5ec2:0:b0:44d:47e2:4b3b with SMTP id s185-20020a625ec2000000b0044d47e24b3bmr8890748pfb.38.1634260834094; Thu, 14 Oct 2021 18:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634260834; cv=none; d=google.com; s=arc-20160816; b=ufwJihwA5qLHiQsxE+csENzAfPYKqiRNh3YyxVb4LbUY7u3tcZcyoG6br4dCNqPpkU TWkNH8+DKyNQqCzBVYomFGmkz2SWMOaKBOeDv1LqyY3tU3uTIHTrsgatMjn+GYQcWbcm BFRd7fULwMb8aI+0P8/M64CWUmpPWAld798I2AHy3LDVwu6+E1W2rDsXU9X73Rb8Ld3r NZwxW0Mju+6D05l4crikuptJXQvoM5nYPBM8GdF0oOroOJhI/aVBJbNytbTjXbEU3QMg u6+so4YzogBq3HosqHB8Hs2Ec6muapWqr5ttXKquvGsYfeahaKQiYgtCm7Hb8/iRy2Jf ncOg== 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=kKDe4nPrM32TB5sLopwA1nILYJRwbnJyRhxEejmvi1U=; b=DGUJVZ8aIiPrpaJtkBwN/9hBemND5AZlxSjWrZZybP+h5KePh59IPrktVb6o6RDFLv O6jTediS8KxnFnk8Uy34Le5wFmpk2Nty1GpmnUAoBs13+KHYpp59I6ZRE3nt2rDlmq4O y+NDViStf95TWuPCjmykJL1MYAnaq/1pHogBZs9Bq0sQIy2zNRcSwtmk2y94rsYmNRcD gULmvTlWOMUu42yZ4bTPKoVW7pzbSWJ0aEnPadEZVOcHg8r4s+7A3KtTuGKbmF4CyQKC 7ro5Hrgvt4L6yWBKau6sTRFFVszCcV5GDPRBE0xiCNoDJVlsTu2BWf7h8eoQlaGlO8HK xKsg== 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 l19si6232894plg.251.2021.10.14.18.20.21; Thu, 14 Oct 2021 18:20: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 S233117AbhJNVl2 (ORCPT + 99 others); Thu, 14 Oct 2021 17:41:28 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54260 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231596AbhJNVl2 (ORCPT ); Thu, 14 Oct 2021 17:41:28 -0400 Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 7A55A1F44F8C; Thu, 14 Oct 2021 22:39:21 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v7 20/28] fanotify: Support enqueueing of error events Date: Thu, 14 Oct 2021 18:36:38 -0300 Message-Id: <20211014213646.1139469-21-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Once an error event is triggered, collect the data from the fs error report and enqueue it in the notification group, similarly to what is done for other events. FAN_FS_ERROR is no longer handled specially, since the memory is now handled by a preallocated mempool. For now, make the event unhashed. A future patch implements merging for these kinds of events. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 35 +++++++++++++++++++++++++++++++++++ fs/notify/fanotify/fanotify.h | 6 ++++++ 2 files changed, 41 insertions(+) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 01d68dfc74aa..9b970359570a 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -574,6 +574,27 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *id, return &fne->fae; } +static struct fanotify_event *fanotify_alloc_error_event( + struct fsnotify_group *group, + __kernel_fsid_t *fsid, + const void *data, int data_type) +{ + struct fs_error_report *report = + fsnotify_data_error_report(data, data_type); + struct fanotify_error_event *fee; + + if (WARN_ON(!report)) + return NULL; + + fee = mempool_alloc(&group->fanotify_data.error_events_pool, GFP_NOFS); + if (!fee) + return NULL; + + fee->fae.type = FANOTIFY_EVENT_TYPE_FS_ERROR; + + return &fee->fae; +} + static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, u32 mask, const void *data, int data_type, struct inode *dir, @@ -641,6 +662,9 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, if (fanotify_is_perm_event(mask)) { event = fanotify_alloc_perm_event(path, gfp); + } else if (fanotify_is_error_event(mask)) { + event = fanotify_alloc_error_event(group, fsid, data, + data_type); } else if (name_event && (file_name || child)) { event = fanotify_alloc_name_event(id, fsid, file_name, child, &hash, gfp); @@ -850,6 +874,14 @@ static void fanotify_free_name_event(struct fanotify_event *event) kfree(FANOTIFY_NE(event)); } +static void fanotify_free_error_event(struct fsnotify_group *group, + struct fanotify_event *event) +{ + struct fanotify_error_event *fee = FANOTIFY_EE(event); + + mempool_free(fee, &group->fanotify_data.error_events_pool); +} + static void fanotify_free_event(struct fsnotify_group *group, struct fsnotify_event *fsn_event) { @@ -873,6 +905,9 @@ static void fanotify_free_event(struct fsnotify_group *group, case FANOTIFY_EVENT_TYPE_OVERFLOW: kfree(event); break; + case FANOTIFY_EVENT_TYPE_FS_ERROR: + fanotify_free_error_event(group, event); + break; default: WARN_ON_ONCE(1); } diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index a577e87fac2b..ebef952481fa 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -298,6 +298,11 @@ static inline struct fanotify_event *FANOTIFY_E(struct fsnotify_event *fse) return container_of(fse, struct fanotify_event, fse); } +static inline bool fanotify_is_error_event(u32 mask) +{ + return mask & FAN_FS_ERROR; +} + static inline bool fanotify_event_has_path(struct fanotify_event *event) { return event->type == FANOTIFY_EVENT_TYPE_PATH || @@ -327,6 +332,7 @@ static inline struct path *fanotify_event_path(struct fanotify_event *event) static inline bool fanotify_is_hashed_event(u32 mask) { return !(fanotify_is_perm_event(mask) || + fanotify_is_error_event(mask) || fsnotify_is_overflow_event(mask)); } -- 2.33.0