Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4930742pxv; Tue, 29 Jun 2021 20:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeWqYUqBM8Q332ILpGGCRXW/g4T55xuMk3r/PIHDyBk6uK1c+Veg1QyB3lXiL57h3gStFA X-Received: by 2002:a50:fb89:: with SMTP id e9mr42821973edq.131.1625024186286; Tue, 29 Jun 2021 20:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625024186; cv=none; d=google.com; s=arc-20160816; b=dUjNHOsOV89jGQ1A/gW30Z3hIU03TgyXo+UMFvKMhEUkQK9pjafo1M26CweaqAA8uV JC0Ss6ZCNavzM/CpOVFeRxfnUpW7zfWQryR8KS/G74ePRcqkD4ZUU6CpFc5viDQyH5hs 8rj3uvHW1UovozGYsq4e1SqVUnLd9zZffM90BoneSTs7YlTg0jk8hwp3/YJ6mNNF0xzb talPF3hyKYJAu4uvLQiAR6u6jQztEr3R1eNH7YwFwLmTtWEgMgfq8BrEQu+e3TsBc3WV GQCEbZCS9AMePQbbtxU6gnUImV6IpZDwBQe3YiMJ81pFiE1ALpaJEfXLwFfWYTtIZeiV x8Ug== 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=FgOlP1mIeiW5ZmRgmpeSNvUCWk9mw1dHHaN/pWphchI=; b=R+VfGByN1fO6gPNpCovoHCC5KNp5ZYFrrNuvAlt+3xZ0MePqEbA5404Vbna2MDeFom anU0ISkGzdndnDjcydNW0quNcvQEWIcXSPZ0w8OcDT52ZEKBETg2mmNlTjcyDqD+t5s4 zIGBA1iicOJ+yE3FFaab/EWQ1Kg2B7Ww4gKOaY8LX3FVu2b2Bpua6UgLezZt806nUMUs m4thEouAyP6YL7rwZ9/5/wEv6Y4wYah2I5tzTPPB63ICop9u53a+xtumtvtGcYeyW3DL I7bQb/Ir/mTJ6zpM07p23gnh27nrT46A88dXGZ8Hf3RVdvEElh0G9ElEHRfclRCVOeva d4xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W1U9Lkra; 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 e6si18313820ejk.740.2021.06.29.20.35.48; Tue, 29 Jun 2021 20:36:26 -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=W1U9Lkra; 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 S232249AbhF3DPg (ORCPT + 99 others); Tue, 29 Jun 2021 23:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232009AbhF3DPe (ORCPT ); Tue, 29 Jun 2021 23:15:34 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED92C061760; Tue, 29 Jun 2021 20:13:05 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id l5so1397374iok.7; Tue, 29 Jun 2021 20:13:05 -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=FgOlP1mIeiW5ZmRgmpeSNvUCWk9mw1dHHaN/pWphchI=; b=W1U9LkraBi9jIgW45RTFOo39Z+eEtTlYRmbAHs6wgDqTE8VFx3x7G5wAQxT/a6l3Ud ZIua0WIlIeW216KUHba0NO/hdvbEJMCTDkfzKdo0ZogWA51cAM92RIWvTmR9z8MEmZKC FwGy8OeFq9SdwtsNCOo5tIOpnmC3bl6OPZj2W7blthEKN6MDf9J7xba9Lz8ys0To25Co 0ELuK8m0cUlyeDfJmmA4RvOD2FmKsoI3Un4XThVpYf5jthXQfL4OaESKE7pq4dMJN3Lv Lv4zLI9MTfdXdzod69Dq7lcBqQRu6eZa5xdz9ltpAd0Jn9lWYCq3IOOcDOZO9ID+qOpt R+UA== 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=FgOlP1mIeiW5ZmRgmpeSNvUCWk9mw1dHHaN/pWphchI=; b=dJPM9SqZ4aO6E4xjZVQpSpC05jNdl0iVg05Oz04ZxpRkHKfVyYZkMF0NNWKvPUZycu cvnBhZkTCGFLhLxLsB8ZRqjvU70atK5AAjJU2OqXKUSkGc0DRFr0/kRMfKZ4fR8tGmXk hruN1OJbVRWvPf15U3ckRVZ0YMQ16wwc6u3XbSI3bIIEwmPPCmyK1/X0Qutm6sCniYDV A4NmkmZyOm7Ech+lXw8Gf2d+4NfT7Xx1LCIPGvPkHBusIdXBNgNHLMu6tWSmaOz+GgKz xi8U0EIomVTxY1UBdGDoqHaMAfSXjEBZy5SsMLkMoIrxazlLDNDDVdFQqbL0iQp78hl5 YWnw== X-Gm-Message-State: AOAM531+gj/dMhjEi1g5b0nb6ks5IDokCDuUiiP/RaLihDp3G3gljfYY MV1efnOW/+HD3llBZecyrZBg7EePwuWBNSfS/wxr8P+Sppw= X-Received: by 2002:a5e:aa07:: with SMTP id s7mr6248373ioe.186.1625022784593; Tue, 29 Jun 2021 20:13:04 -0700 (PDT) MIME-Version: 1.0 References: <20210629191035.681913-1-krisman@collabora.com> <20210629191035.681913-2-krisman@collabora.com> In-Reply-To: <20210629191035.681913-2-krisman@collabora.com> From: Amir Goldstein Date: Wed, 30 Jun 2021 06:12:53 +0300 Message-ID: Subject: Re: [PATCH v3 01/15] fsnotify: Don't insert unmergeable events in hashtable To: Gabriel Krisman Bertazi Cc: "Darrick J. Wong" , Theodore Tso , Dave Chinner , Jan Kara , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Jun 29, 2021 at 10:11 PM Gabriel Krisman Bertazi wrote: > > 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 > Reviewed-by: Amir Goldstein > --- > 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 >