Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4657652pxv; Tue, 29 Jun 2021 12:16:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy6+8EflhG3MlsTXkYzvG9zAXsphkWlOuLr+LbWoALUQKqsKP6XVmtAD+/2ePnMyh9PRWn X-Received: by 2002:a05:6402:458:: with SMTP id p24mr16512233edw.142.1624994198409; Tue, 29 Jun 2021 12:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994198; cv=none; d=google.com; s=arc-20160816; b=MVvTzsAXdrkth9Gz4FJ+yfsRpiX1etFXETiCAd0zesZBk4AP8Of8z3uVdUKJhaoN7k sFV3tp9fiMTTYYFyoQCzmofTCg+4dv3uOxrGnJ9g3cECohhIz8hXQ7byR90XjMMzrF4b IC4EI1/MMb5RVEzdptkDyp16vw6DIRpsDBBELSOtQjD1L3U3fSjBlKA6H7F67OIQfASq GXi1tAZHPUFoKKwn2vaFq76kkI8P4nKpAcVWgdOWcEAOieTh+SFHxKThP3wo/pyQ0m/2 QNutUl7JvTaD/ZSqWI7aUtySUcrf+6GhL8a+JVqRF/EC8zoh4YqvWPfb6BY4NnmWSzBz 91JA== 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=8UgyRY2UTk+kVdKot1A43EI38vmuFXZMkFcX3PiGsyw=; b=UG97O+5u0SqthZMO9rMP+T2YLjBmatH3wp0GjAUXjcxkCj5xEWlz+1uKZeOraGXtIL 0/TVT5P0MrdFYyQ21iK47PhpV+AieM+HF5MlGjLo2j5to+ffsEnfOEyt7pNxsBgRMGzR l59Aga+1r5C2bYwTG1rfnuvSnrdLVaq62cZ4U+0AnXYgNYujUPvol84LIn5xlpjI5Qil NiyG3svI7XiHRNB69TEaXCMJFEMnN2BnVhU3lqF3Kl6ixCIieRVJAjAzztkCXB3PGSKj o1jQLRNDFqMINtzrbfmC3vEoe/thc6kLpbsGYfIgnSovKWiENPQGmYkNctFz0ERtTrWB /TvQ== 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 n12si6349123ejz.730.2021.06.29.12.16.14; Tue, 29 Jun 2021 12:16:38 -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 S233916AbhF2TOZ (ORCPT + 99 others); Tue, 29 Jun 2021 15:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234228AbhF2TOW (ORCPT ); Tue, 29 Jun 2021 15:14:22 -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 2A517C061760; Tue, 29 Jun 2021 12:11:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id D22E71F431AF 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 01/15] fsnotify: Don't insert unmergeable events in hashtable Date: Tue, 29 Jun 2021 15:10:21 -0400 Message-Id: <20210629191035.681913-2-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 Some events, like the overflow event, are not mergeable, so they are not hashed. But, when failing inside fsnotify_add_event for lack of space, fsnotify_add_event() still calls the insert hook, which adds the overflow event to the merge list. Add a check to prevent any kind of unmergeable event to be inserted in the hashtable. Fixes: 94e00d28a680 ("fsnotify: use hash table for faster events merge") Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Do check for hashed events inside the insert hook (Amir) --- fs/notify/fanotify/fanotify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 057abd2cf887..310246f8d3f1 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -702,6 +702,9 @@ static void fanotify_insert_event(struct fsnotify_group *group, assert_spin_locked(&group->notification_lock); + if (!fanotify_is_hashed_event(event->mask)) + return; + pr_debug("%s: group=%p event=%p bucket=%u\n", __func__, group, event, bucket); @@ -779,8 +782,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask, fsn_event = &event->fse; ret = fsnotify_add_event(group, fsn_event, fanotify_merge, - fanotify_is_hashed_event(mask) ? - fanotify_insert_event : NULL); + fanotify_insert_event); if (ret) { /* Permission events shouldn't be merged */ BUG_ON(ret == 1 && mask & FANOTIFY_PERM_EVENTS); -- 2.32.0