Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp176485lqp; Tue, 11 Jun 2024 19:56:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3ljrgtMYAHsk4zmQMngpTBg/doMZe8uGU5CedtDpBNLLYJBcNG9fjC3ql5wMO68C3WiH8jKPoYTx8+RQCBTu+ocu8hW7WOU/mQG9Kjw== X-Google-Smtp-Source: AGHT+IGfvQnlu9KeBbsVYRbW2sCGjzI0iEVLP1cNanqvXnmTliQv44iPbUXQE3FTUHFtU9Rp+66r X-Received: by 2002:a05:6a00:1151:b0:704:2f65:4996 with SMTP id d2e1a72fcca58-705bce19e9fmr703292b3a.11.1718160961911; Tue, 11 Jun 2024 19:56:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718160961; cv=pass; d=google.com; s=arc-20160816; b=AJhmEn3WUeYwgAgpO5vLFp5ziKtSa47mxAyZK/RjPcaoJWo0VmjQozSBBKdX+BTjR+ WWYIdrzS63kPpWWCxTLEUec+2zFQF+QUfFTL+DrkyNeOFe9UoPE1qjidZgoLQAXySsby OM/OjjIPsW1s3fLZLO9/EkbFuFfD6nfDzn4uzKGZGzgOTvEUptLGVjRR1eWYKyfKemlR JPdSjVVZaVppZSd9P72UjwUTIIN1gqEslUq9UkhpdqJbsZ9ahdlQg/dETW1NDW4Vf+Sd PON1IqBrx4fhENMNOkOBSiuLOM2cSTAGJCtjhVWlOq2geZJ14xQFnBU3btZAjU4B4kr7 y9eQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:references:in-reply-to:subject:cc:to:from :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=a/btJp52x6H5kgv/jR8z+3XSQ/4SH6/WdXpxSMLKM3U=; fh=XM85XiObgjvAgItKJ2+VkUO01jYc7z7c6IVY/byK5L8=; b=F1StTKKeBVQnw23BvD2Vdv/ILsBPjPZwUFojRBBkDXspTLwFCaLg1K5lS3ZMoNn+kY 6jTKxz+dB7c+c36y7vC6nY+6u1aW3yE8mErGALXFO4+dj+B5LfCcD7/Ja9Ud/3/0yOu9 s0+HzyU9+ZWbuSQnGhfuyYSOwrFUmSX9dsXAfUjwKHGPI+vAfxZwdrzfo8tAfV8CicrV 8CVzEEeKD3ndW/N9YVeKZ7LxaNgTVPdqWAyVhT/V5CdrbQSsYkfzT9QAR/LPEbFS+6tg LqIt+I08EWnJiXytl27QT2GXHL1qJGKfWo+Hsr4pu77L3qkb3PoYJrYEwcyn5MjjCLzf ynXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnBguCff; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=P+G7PaQI; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnBguCff; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-3655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de29120975si8205656a12.657.2024.06.11.19.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 19:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnBguCff; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=P+G7PaQI; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnBguCff; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-3655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 55F25B21FA4 for ; Wed, 12 Jun 2024 02:55:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E23DDDC4; Wed, 12 Jun 2024 02:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HnBguCff"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="P+G7PaQI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HnBguCff"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="P+G7PaQI" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5D1F3C2F; Wed, 12 Jun 2024 02:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718160951; cv=none; b=KOUgARNSxcit/AxrKntwuJlTux+okqAFhYz0dNfkDIMQNecgqWchJ+5xalJ/L8E5d03I3pOUu+FLR5gLlly7JaRdZ4dnbnM694uwB117NO7Jl9Ye9e9T4dt+yMOiRe15Ayivvkvjg6QKGwfdZjhfwd1UH6ItHMQc86nQt1UnA1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718160951; c=relaxed/simple; bh=CWUH+foI6HMl68oOCwwSHQTb1k2+/MYYF0gH8gZanhY=; h=Content-Type:MIME-Version:From:To:Cc:Subject:In-reply-to: References:Date:Message-id; b=LfdH5X3vsAokbTaX0Ba0arMr8y2rYylSd01VunIPfJSyTbDEk9rlVK/Vss0rWo3aMge9g1NoJmNU7WHUWuGAKboxz0RKKn4IQbGcILGVChUwyiJqcs/+6UA14+KeH36qubpw9krH4Y1FoCdM0O2u3vRPIBrh8Kk33zUwpJDwDCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=HnBguCff; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=P+G7PaQI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=HnBguCff; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=P+G7PaQI; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CBEE620E49; Wed, 12 Jun 2024 02:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718160947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/btJp52x6H5kgv/jR8z+3XSQ/4SH6/WdXpxSMLKM3U=; b=HnBguCffpXlQE5lNoNrD1iAZCzOx7MKcBvU13zSgMPlBdzyXItj3sG317S71ShPfLLJVUS ygDf53cBGHafhqz4C3mcq9hDS+CujKgDEMit4EOF61ItG9zjqZC/yLFMLmP3lbPtYxRi1D YAe6/0TAJhbtOJ4DBxrHaoVAdle+Flw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718160947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/btJp52x6H5kgv/jR8z+3XSQ/4SH6/WdXpxSMLKM3U=; b=P+G7PaQI9wQ69zlBmPm3tK1W9z0tIcijUFV4TAu06akCknpdoUcjp7PrSe7Ua4W46plY/u qeva8bmxWc6UaZAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718160947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/btJp52x6H5kgv/jR8z+3XSQ/4SH6/WdXpxSMLKM3U=; b=HnBguCffpXlQE5lNoNrD1iAZCzOx7MKcBvU13zSgMPlBdzyXItj3sG317S71ShPfLLJVUS ygDf53cBGHafhqz4C3mcq9hDS+CujKgDEMit4EOF61ItG9zjqZC/yLFMLmP3lbPtYxRi1D YAe6/0TAJhbtOJ4DBxrHaoVAdle+Flw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718160947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/btJp52x6H5kgv/jR8z+3XSQ/4SH6/WdXpxSMLKM3U=; b=P+G7PaQI9wQ69zlBmPm3tK1W9z0tIcijUFV4TAu06akCknpdoUcjp7PrSe7Ua4W46plY/u qeva8bmxWc6UaZAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1FDDD137DF; Wed, 12 Jun 2024 02:55:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id tv4oLS8OaWZPCgAAD6G6ig (envelope-from ); Wed, 12 Jun 2024 02:55:43 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: "Al Viro" Cc: "Christian Brauner" , "Jan Kara" , "Amir Goldstein" , "James Clark" , ltp@lists.linux.it, linux-nfs@vger.kernel.org, "LKML" , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] VFS: generate FS_CREATE before FS_OPEN when ->atomic_open used. In-reply-to: <20240612023748.GG1629371@ZenIV> References: <171815791109.14261.10223988071271993465@noble.neil.brown.name>, <20240612023748.GG1629371@ZenIV> Date: Wed, 12 Jun 2024 12:55:40 +1000 Message-id: <171816094008.14261.10304380583720747013@noble.neil.brown.name> X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_TLS_ALL(0.00)[]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[kernel.org,suse.cz,gmail.com,arm.com,lists.linux.it,vger.kernel.org]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -4.30 X-Spam-Level: On Wed, 12 Jun 2024, Al Viro wrote: > On Wed, Jun 12, 2024 at 12:05:11PM +1000, NeilBrown wrote: >=20 > > For finish_open() there are three cases: > > - finish_open is used in ->atomic_open handlers. For these we add a > > call to fsnotify_open() in do_open() if FMODE_OPENED is set - which > > means do_dentry_open() has been called. This happens after fsnotify_cr= eate(). >=20 > Hummm.... There's a bit of behaviour change; in case we fail in > may_open(), we used to get fsnotify_open()+fsnotify_close() and with that > patch we's get fsnotify_close() alone. True. Presumably we could fix that by doing diff --git a/fs/namei.c b/fs/namei.c index 37fb0a8aa09a..6fd04c9046fa 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3645,6 +3645,8 @@ static int do_open(struct nameidata *nd, return error; do_truncate =3D true; } + if (file->f_mode & FMODE_OPENED) + fsnotify_open(file); error =3D may_open(idmap, &nd->path, acc_mode, open_flag); if (!error && !(file->f_mode & FMODE_OPENED)) error =3D vfs_open(&nd->path, file); @@ -3702,6 +3704,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap, dput(child); if (error) return error; + fsnotify_open(file); /* Don't check for other permissions, the inode was just created */ error =3D may_open(idmap, &file->f_path, 0, file->f_flags); if (error) instead, but it seems a little weird sending an OPEN notification if may_open() fails. >=20 > IF we don't care about that, we might as well take fsnotify_open() > out of vfs_open() and, for do_open()/do_tmpfile()/do_o_path(), into > path_openat() itself. I mean, having > if (likely(!error)) { > if (likely(file->f_mode & FMODE_OPENED)) { > fsnotify_open(file); > return file; > } > in there would be a lot easier to follow... It would lose fsnotify_open() > in a few more failure exits, but if we don't give a damn about having it > paired with fsnotify_close()... >=20 Should we have fsnotify_open() set a new ->f_mode flag, and fsnotify_close() abort if it isn't set (and clear it if it is)? Then we would be guaranteed a balance - which does seem like a good idea. Thanks, NeilBrown