Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4656899pxv; Tue, 29 Jun 2021 12:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ky3duv32e8k/HmatAGHysTKQhpmgxoUISK0S9tT9U+G/s4aeQm3HJHXePhAVCeJlKDVE X-Received: by 2002:a05:6402:3507:: with SMTP id b7mr42712990edd.66.1624994125545; Tue, 29 Jun 2021 12:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624994125; cv=none; d=google.com; s=arc-20160816; b=QoHmqHIuq/TWOh0Svkszg/wlmYvjBEN65y3FpHRR1sVGcQFqk/EvhA6d1RoZTSYB+9 2QW4u5I16lZnbA5e8S4xxi1rTJ0Ds3P65gTpW2FZ8GtGa8a59UqBYRPiDQkilFqw7GIG V3mtl1rAezNgBqIhED+vG+cVSAxJJ33P5Yx+QRDKq0cqQZYlNpLUbQi3IqJt/h6HJfek 3JF5j2GU1OrEqL/27diZrdgaUwo2jD0ldhPxl8SjatnZ/McX7weFLmYvx/DXhV4vs82t OJXxNDcCT+cFE4PaaLKwgiqO9gGkdTIoHonuHGWv8R/TQxQXViecvXgDrnjYmlj0dxzr v1+g== 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=hg8Jo5oP1W8+6z5BVCCP5utwRh4G8Tq/L9WFOk36fiM=; b=GDTZBV/KORnb886Rj458mb5TcQYe85eNCVUxq7MhaAKPwCTsJ80i1llDVeIpSX0RRo 8QgCTjFoLfKSpLEc2udAgZEsNdWQ2LWdE938SIQgQLFp1P4Be39vVeoqy2A7FvQ50EXy XJMLE0ov3LSTmxYTNj8Mq7RUWQc422my8sICQCDsQ7+89yXkwLpjRySbcLLw4JeCrNfs qgWI284/DdkUJikfzCQhVrbgr2nq1d4XWFim/StELXDqjelKH4DvW+QUDbtkaIRIm4Mk JWJcPOjSuVGR2aIyAbi+dtFPTub5l4WElBHDGW7xHJpUrDLiqTUqLCHxBcqOoBT5327E BdDQ== 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 ar14si18218485ejc.276.2021.06.29.12.15.01; Tue, 29 Jun 2021 12:15:25 -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 S235336AbhF2TPM (ORCPT + 99 others); Tue, 29 Jun 2021 15:15:12 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34926 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235504AbhF2TPM (ORCPT ); Tue, 29 Jun 2021 15:15:12 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id ADA1D1F431AF 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 09/15] fsnotify: Always run the merge hook Date: Tue, 29 Jun 2021 15:10:29 -0400 Message-Id: <20210629191035.681913-10-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 FS_FAN_ERROR must be able to merge events even in the short window after they've been unqueued but prior to being read. Move the list_empty check into the merge hooks, such that merge() is always invoked if existing. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 3 ++- fs/notify/inotify/inotify_fsnotify.c | 3 +++ fs/notify/notification.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index aba06b84da91..769703ef2b9a 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -168,7 +168,8 @@ static int fanotify_merge(struct fsnotify_group *group, * the event structure we have created in fanotify_handle_event() is the * one we should check for permission response. */ - if (fanotify_is_perm_event(new->mask)) + if (list_empty(&group->notification_list) || + fanotify_is_perm_event(new->mask)) return 0; hlist_for_each_entry(old, hlist, merge_list) { diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index a003a64ff8ee..2f357b4933c2 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -52,6 +52,9 @@ static int inotify_merge(struct fsnotify_group *group, struct list_head *list = &group->notification_list; struct fsnotify_event *last_event; + if (list_empty(list)) + return 0; + last_event = list_entry(list->prev, struct fsnotify_event, list); return event_compare(last_event, event); } diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 0d9ba592d725..1d06e0728a24 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -111,7 +111,7 @@ int fsnotify_add_event(struct fsnotify_group *group, goto queue; } - if (!list_empty(list) && merge) { + if (merge) { ret = merge(group, event); if (ret) { spin_unlock(&group->notification_lock); -- 2.32.0