Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp259112pxb; Thu, 12 Aug 2021 15:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz3wmfiOYZ/XwIjo68UogEg9OzmS9xU35gZErds+IuawjTi0Zw6zobp5HAql22H0xBwCCj X-Received: by 2002:a17:907:2676:: with SMTP id ci22mr5973725ejc.442.1628808994526; Thu, 12 Aug 2021 15:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628808994; cv=none; d=google.com; s=arc-20160816; b=llNxFwVJQv9uVJk+HXhPr/WKaV1Nh9KkA9GzIfs+J1GvGU+y7HWUljvVhTPUL89QdY gmxwpo+P32aChSgFj6ym9rzsFtFa/eZn2aL9Rak3F/em5AkDr8D6WNLqy1e9iFRBJquA dVZ56hQxL6w48qhnUqpuGdKyra3leqJYrhzt0M9nuPPndjgm/ouihshb4elKuzeA3Rbk poChXq+HqI8R+lqK1kbFmX3k+AvVQLIU6rnMRy2hmPc1/ld9E84BwY2C/eF23J0nqfAC Ix/sUH4Lx8cJlq2jqzAIGzVX3wyGUfTxhyZD6NZ10Ps2LY5IkIaikFTW1taii2lp3r0S PURQ== 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=llanoVI1PI8Q+VxWNnPiCRFNjHwSUshQZh6QJojUUQk=; b=iGmmw1Kvy105rfIVQvkFI+7pUpZr0TczgpiLXbk947wXPyw7KsgUx8kJ9jfXcKA5Bx TTRbKBvNCPZzQr1DZpxoIDloLYIHAusDlS5XvffOcT/irAKp72xfktYXPDqNwsIznCEV bs1GreLwDu9l2XMeV0D7jUl/ONMmyq5w+sz22oNGERucuzc2mm7GXeglr66ij/A2dy7R EEc59BHqdkb1UiLLDsidIOVWxGzDDrAKr3YUtHvdUWLYc5E8DGecVsLbK60hYOIzCSiT 0EJuDGWST9whIl5nhCJX68LY4Gw+YstwEtJOXI/kCSGZHoaeOYRpnfY+j0CnoRL0CVM4 qV5Q== 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 z2si4007807edq.209.2021.08.12.15.56.10; Thu, 12 Aug 2021 15:56: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 S237364AbhHLVlC (ORCPT + 99 others); Thu, 12 Aug 2021 17:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237348AbhHLVk5 (ORCPT ); Thu, 12 Aug 2021 17:40:57 -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 0F91EC061756; Thu, 12 Aug 2021 14:40:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 821761F441EF From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, khazhy@google.com, dhowells@redhat.com, david@fromorbit.com, tytso@mit.edu, djwong@kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v6 01/21] fsnotify: Don't insert unmergeable events in hashtable Date: Thu, 12 Aug 2021 17:39:50 -0400 Message-Id: <20210812214010.3197279-2-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812214010.3197279-1-krisman@collabora.com> References: <20210812214010.3197279-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") Reviewed-by: Amir Goldstein Reviewed-by: Jan Kara 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