Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E4BC433EF for ; Mon, 21 Mar 2022 09:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345678AbiCUJKt (ORCPT ); Mon, 21 Mar 2022 05:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345623AbiCUJKt (ORCPT ); Mon, 21 Mar 2022 05:10:49 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC963DF7C for ; Mon, 21 Mar 2022 02:09:23 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6612F1F37F; Mon, 21 Mar 2022 09:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1647853762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iea9zm5Pabi5b4nJXG6eNco1lLeH+gXs+NfqLPdQL2M=; b=zxu25ytxR0mv0n7lwUHnegTDWE7+BRyLhFpGe+G2NF8xpVsNT7+axx90V6UcDJErZ2CRtV uu04OXlFN8ZkMnHVlQTCPmq3qvLz1ExeALlC39bLVNWK2uXA8dWX3zT32cT1PL9gCT1F9/ ofGGGHNofaZoCMPdS2HXMX3J4H+g8xI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1647853762; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iea9zm5Pabi5b4nJXG6eNco1lLeH+gXs+NfqLPdQL2M=; b=ko89DgXKVxeKuyeMIOMnpNmqNMeYtASuZ3PcJrJXczkbybl03+C1p8N5MfPp1+RyzWMrke CILYnHo64f+O1ZBg== Received: from quack3.suse.cz (unknown [10.100.224.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 4D624A3B81; Mon, 21 Mar 2022 09:09:22 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 043BBA0610; Mon, 21 Mar 2022 10:09:18 +0100 (CET) Date: Mon, 21 Mar 2022 10:09:18 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Matthew Bobrowski , linux-fsdevel Subject: Re: [PATCH 4/5] fanotify: add support for exclusive create of mark Message-ID: <20220321090918.tpthlbjd6ffavdte@quack3.lan> References: <20220307155741.1352405-1-amir73il@gmail.com> <20220307155741.1352405-5-amir73il@gmail.com> <20220317153443.iy5rvns5nwxlxx43@quack3.lan> <20220317154550.y3rvxmmfcaf5n5st@quack3.lan> <20220318103219.j744o5g5bmsneihz@quack3.lan> <20220318140951.oly4ummcuu2snat5@quack3.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri 18-03-22 18:06:40, Amir Goldstein wrote: > > > > So far my thinking is that we either follow the path of possibly generating > > > > more events than necessary (i.e., any merge of two masks that do not both > > > > have FAN_MARK_VOLATILE set will clear FAN_MARK_VOLATILE) > > I agree that would provide predictable behavior which is also similar to > that of _SURV_MODIFY. > But IMO, this is very weird to explain/document in the wider sense. > However, if we only document that > "FAN_MARK_VOLATILE cannot be set on an existing mark and any update > of the mask without FAN_MARK_VOLATILE clears that flag" > (i.e. we make _VOLATILE imply the _CREATE behavior) > then the merge logic is the same as you suggested, but easier to explain. Yes, makes sense. > > > > or we rework the > > > > whole mark API (and implementation!) to completely avoid these strange > > > > effects of flag merging. I don't like FAN_MARK_CREATE much because IMO it > > > > solves only half of the problem - when new mark with a flag wants to merge > > > > with an existing mark, but does not solve the other half when some other > > > > mark wants to merge to a mark with a flag. Thoughts? > > > > > > > > > > Yes. Just one thought. > > > My applications never needed to change the mark mask after it was > > > set and I don't really see a huge use case for changing the mask > > > once it was set (besides removing the entire mark). > > > > > > So instead of FAN_MARK_CREATE, we may try to see if FAN_MARK_CONST > > > results in something that is useful and not too complicated to implement > > > and document. > > > > > > IMO using a "const" initialization for the "volatile" mark is not such a big > > > limitation and should not cripple the feature. > > > > OK, so basically if there's mark already placed at the inode and we try to > > add FAN_MARK_CONST, the addition would fail, and similarly if we later tried > > to add further mark to the inode with FAN_MARK_CONST mark, it would fail? > > > > Thinking out loud: What does FAN_MARK_CONST bring compared to the > > suggestion to go via the path of possibly generating more events by > > clearing FAN_MARK_VOLATILE? I guess some additional safety if you would add > > another mark to the same inode by an accident. Because if you never update > > marks, there's no problem with additional mark flags. > > Is the new flag worth it? Not sure... :) > > I rather not add new flags if we can do without them. > > To summarize my last proposal: > > 1. On fanotify_mark() with FAN_MARK_VOLATILE > 1.a. If the mark is new, the HAS_IREF flag is not set and no ihold() > 1.b. If mark already exists without HAS_IREF flag, mask is updated > 1.c. If mark already exists with HAS_IREF flag, mark add fails with EEXISTS > > 2. On fanotify_mark() without FAN_MARK_VOLATILE > 2.a. If the mark is new or exists without HAS_IREF, the HAS_IREF flag > is set and ihold() > 2.b. If mark already exists with HAS_IREF flag, mask is updated > > Do we have a winner? Sounds good to me. Honza -- Jan Kara SUSE Labs, CR