Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1954311pxb; Sun, 17 Oct 2021 01:53:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2hEIu3AiuN3NmjFgq2ImkiAli/DtWijwTP1tbw0DWAsC17YCexm4kRl2myQXYBznkwPUA X-Received: by 2002:a17:902:b711:b029:11e:6480:258a with SMTP id d17-20020a170902b711b029011e6480258amr20885309pls.41.1634460828867; Sun, 17 Oct 2021 01:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634460828; cv=none; d=google.com; s=arc-20160816; b=GxChudQBSlrnAGhF7kl4TlNCVSmyZq9Ek6Fe7ih+dsV/6KZ+TBJXUhDLqqPvgOLiKL eGj8ZuN99XLlRm1PwdRZ9rwWr97QywskK+kPzXPFw3ly0b66SJIxI6DT/QlDxtf2IhiZ locMLGGzKVEub733GOrpE+HLnR47HEaSkfYYYCN6MPH0t9XUTpy6gdkQzegfrEDEFFrT XFDBTJY9fO9fbL/uo0ZKZWkYDmXKs+Pb9ohs1SEpDcBeYf0KQENC6RhkKsmUxowdebt4 c0hx5bOsJzh8j+rNKOf+I4sMLmhrm6wpSTBN1SnPmZj+KruNcuKAD9ESZXMXg6hrjOFP 8cRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:organization:subject:cc:to:from; bh=atkwIfnXLpMU54tPQMh6QueGkl966H++ixuh7o1Q/MA=; b=gIZ3s9bz3yg0vpSZt6J4dIdotWJ1CB1mrsOWPqAbvTpHProHezZS2INTMdZ7oEmkoL dX7gbKYMkrc7iWyYTMLkF7yUnplNjrAOc1YG5JBs6QevR6M9EiTdeOl/JsLtHNzOahHy yV8j0Ji/7u13slutRWO0ECgrOyFbZYtPbb4fmaGYKJjpZkzN1+57VzEhJ/UuDepq1w7/ BYt/iv7+MkbyHn30+15yck7WxKyMLQUY6aFoTjYU6Zj4gduUfCnNjCSpdGETW0zVM+p9 POumC1QjP4t1mKgsRRZysoAwksRFvhNI+qFLfTVl34FQqxfagTWUaJXxcz2AUYVwedEx j65g== 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 n26si14699497pfe.304.2021.10.17.01.53.36; Sun, 17 Oct 2021 01:53:48 -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 S241696AbhJOQza (ORCPT + 99 others); Fri, 15 Oct 2021 12:55:30 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:36456 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236428AbhJOQza (ORCPT ); Fri, 15 Oct 2021 12:55:30 -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 AD44D1F45452; Fri, 15 Oct 2021 17:53:21 +0100 (BST) From: Gabriel Krisman Bertazi To: Amir Goldstein Cc: Jan Kara , "Darrick J. Wong" , Theodore Tso , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , Linux API , Matthew Bobrowski , kernel@collabora.com Subject: Re: [PATCH v7 19/28] fanotify: Limit number of marks with FAN_FS_ERROR per group Organization: Collabora References: <20211014213646.1139469-1-krisman@collabora.com> <20211014213646.1139469-20-krisman@collabora.com> Date: Fri, 15 Oct 2021 13:53:16 -0300 In-Reply-To: (Amir Goldstein's message of "Fri, 15 Oct 2021 09:15:46 +0300") Message-ID: <87tuhip6v7.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Amir Goldstein writes: > On Fri, Oct 15, 2021 at 12:39 AM Gabriel Krisman Bertazi > wrote: >> >> Since FAN_FS_ERROR memory must be pre-allocated, limit a single group >> from watching too many file systems at once. The current scheme >> guarantees 1 slot per filesystem, so limit the number of marks with >> FAN_FS_ERROR per group. >> >> Signed-off-by: Gabriel Krisman Bertazi >> --- >> fs/notify/fanotify/fanotify_user.c | 10 ++++++++++ >> include/linux/fsnotify_backend.h | 1 + >> 2 files changed, 11 insertions(+) >> >> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c >> index f1cf863d6f9f..5324890500fc 100644 >> --- a/fs/notify/fanotify/fanotify_user.c >> +++ b/fs/notify/fanotify/fanotify_user.c >> @@ -959,6 +959,10 @@ static int fanotify_remove_mark(struct fsnotify_group *group, >> >> removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags, >> umask, &destroy_mark); >> + >> + if (removed & FAN_FS_ERROR) >> + group->fanotify_data.error_event_marks--; >> + >> if (removed & fsnotify_conn_mask(fsn_mark->connector)) >> fsnotify_recalc_mask(fsn_mark->connector); >> if (destroy_mark) >> @@ -1057,6 +1061,9 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, >> >> static int fanotify_group_init_error_pool(struct fsnotify_group *group) >> { >> + if (group->fanotify_data.error_event_marks >= FANOTIFY_DEFAULT_FEE_POOL) >> + return -ENOMEM; > > Why not try to mempool_resize()? Jan suggested we might not need to bother with it, but I can do that for the next version. > Also, I did not read the rest of the patches yet, but don't we need two > slots per mark? one for alloc-pre-enqueue and one for free-post-dequeue? I don't understand what you mean by two slots for alloc-pre-enqueue and free-post-dequeue. I suspect it is no longer necessary now that FAN_FS_ERROR is handled like any other event on enqueue/dequeue, but can you confirm or clarify? Thanks, -- Gabriel Krisman Bertazi