From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B07DBD6DDED for ; Fri, 15 Nov 2024 11:48:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AD496B0089; Fri, 15 Nov 2024 06:48:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35D4B6B008A; Fri, 15 Nov 2024 06:48:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FE116B008C; Fri, 15 Nov 2024 06:48:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 024FC6B0089 for ; Fri, 15 Nov 2024 06:48:01 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 792C71C7310 for ; Fri, 15 Nov 2024 11:48:01 +0000 (UTC) X-FDA: 82788153252.13.6137F9F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf01.hostedemail.com (Postfix) with ESMTP id C8C0840005 for ; Fri, 15 Nov 2024 11:47:23 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="jPi7ZF/m"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XT72GDTl; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=yfxa+0uy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xj9DXuah; spf=pass (imf01.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731671134; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=sLSISZqZ5n9htJt4xL3hS+cL5Ypb46GaDYtip+z3mJ8=; b=anWCaatAXIHd1xeLyfWQ1IqBQFN4aTrkMbkO0/XOG7XuIEbJ/7Gi+sMoDX6YTyepibMMc5 DlTuqcKiOZC/kWR2wXRH1BNKvk0/FE+pIhP8hwWMULxvdPeZ5umDi59QPvR6FrFTzk4UVV Xk7whOtqv+W5D1RVY2SjkL8SFeUZdbc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731671134; a=rsa-sha256; cv=none; b=EWT2zWDok4fGD2EJDWurSvSRfETGzBjH2L1Ya1B5EBLmwu81F5SCx89xTA3WQ6K5nJoMqZ YbxQThLA3qt59ld0Y6qWvVPBv1YydOlKk0fMG+V0mUkuWBvf9DE9raD9xf11R5go7XIpxK CDIMLW26R9KDS8rkXNYsiTsA5yb/+mw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="jPi7ZF/m"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XT72GDTl; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=yfxa+0uy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xj9DXuah; spf=pass (imf01.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 452252116C; Fri, 15 Nov 2024 11:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1731671277; 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=sLSISZqZ5n9htJt4xL3hS+cL5Ypb46GaDYtip+z3mJ8=; b=jPi7ZF/miO6vjADrGElR8HFeXb3tieltSOCVp/yopEEv6ov0NiIZQBoQf1JcgLxL4+vf2C Y2hj07MuJTQCc/KdIqEBPY+uF2gEL9QKWOkP6525ss0AgTNgeMK6bv4d1MB0DMw9BNSF84 5QtQc6wIbcT7ew4wozE0k/OrE8bMLY0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1731671277; 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=sLSISZqZ5n9htJt4xL3hS+cL5Ypb46GaDYtip+z3mJ8=; b=XT72GDTlFIzotnygXMZgsWu6N1xjbUOPqXhnyUy9dcr+gPCLTKaw4WD0//QbbkO1/whdNy MHpetfDCo1EuFTDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1731671276; 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=sLSISZqZ5n9htJt4xL3hS+cL5Ypb46GaDYtip+z3mJ8=; b=yfxa+0uyIesOZzZBCTLXJdk2kUMYlkcLUWznOg32xH3p0fiEWzzY5AQ7lVFL/2fEeYNdbI OYf/kgB0RMO3XJKkEB28iqZYrN0+K5IGeFaXgRU8st3O+WzjZFyd/ovlR8auI8PBh3oyHy iJ94rNfmzkEMfYEmEArrxh0Wv9i5ZLo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1731671276; 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=sLSISZqZ5n9htJt4xL3hS+cL5Ypb46GaDYtip+z3mJ8=; b=xj9DXuah+YQn4GXWUPuaeojBApMtPJSw/6KQHov+b4gqbCPl+jcKjJiTJ3HcK6LfY09om8 NEB0BDvM7VuwgIBQ== 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 37663134B8; Fri, 15 Nov 2024 11:47:56 +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 cT+DDew0N2eXcgAAD6G6ig (envelope-from ); Fri, 15 Nov 2024 11:47:56 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id F2707A0986; Fri, 15 Nov 2024 12:47:55 +0100 (CET) Date: Fri, 15 Nov 2024 12:47:55 +0100 From: Jan Kara To: Amir Goldstein Cc: Josef Bacik , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, brauner@kernel.org, torvalds@linux-foundation.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Subject: Re: [PATCH v7 09/18] fanotify: introduce FAN_PRE_ACCESS permission event Message-ID: <20241115114755.whr4q3tuj5rdj7hm@quack3> References: <8de8e335e07502f31011a18ec91583467dff51eb.1731433903.git.josef@toxicpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C8C0840005 X-Stat-Signature: srs43ymg3846fruk1gc6j3kha4ycao65 X-HE-Tag: 1731671243-798938 X-HE-Meta: U2FsdGVkX18B75KjSvWfc6yTLA5ZNIoA9j5xy74IQga6uQ9kyklrDLh1RrwPIkkD6hdOfuFzj05M144UlBHjcQbD2Vzqr7PfQ17OhGXp41lhDMUkYOCpUNmz4CGKih+yztRr5vRjpouNhK2YMw2Hh566/FpdjZZot3HE73Rj/lnH4C6GFYkG+NgUogY1AD5FPukQJboAsnNIG+Sqj6gVcjQOQ0d3p742eX9vMTRG0QDnRYZjBfT+kYKwbMmRY2Qpz4JczJ0pcq9GKPq51dFKg3+HiiAbcg9/ifNv4fOxFuEDSdggFl3Jg8pue5GsVUt6UrUh3JBCZgC1xmDM17BKynQ+pLc/7ueGF46U9jF7ug2IQz7b6FWAuNIcACrZutIMxCHpoHDzt1Qvx8w5ETwuoUPsw2zXu6KjzFC6BfmHfFVJBBZuRGRhOyWpocaVS982s3wStrv1PZt0Vuyi0SLfssOFfz1yZ22m04kxPGhI4fBROl6O3h8b1JwTqnyBbwvRopIpKAc2zAUFzDRo8G97HML5a+0zoSxydsRALEimhhxj7fQvAdWUtWL6iTvb55aH37jsC1tfmpVjI0n9m9VV+V713jb7aw8xsfSH/3K9nvjza11crbHMVtwArDgt9g0mzzI9Yi/z0VKoH+rknnC8nOtAggRjHroodv+4zp12z8lObS5aNlWfEVpSO1D9dw9YM6ncVuvbnsL0ro+P2gKCknoB23QwWhTbjkBUV523+K+rGiLopDyKvVjblVhzNylAL96rSphe8IMOIvh77tHQK9Br3e3azeDDVpXFJHjFj/JGo7aMClihn8GxZivmSBR7RgCr87rEOnRcmKPFGTQzeFTEExEffH05yYxqQn0EavOpDJstbPfL99QJJwQTqYypQY7/0feHD7GLw+TtkxBB93SXksecAcz3aMOZiSayPjHw9+0y+oZSBrY0mXs93Pi9RnksnZLjzshefSSniJd cNOHdNJa gTy2GKfQv9U/DhtbNPF4pa6gTRhnGczfgSUNCV0Z46doaSR2/NMMLO3eSJS2vT3X6/mA9EP9JoNqHfEk7cl6eGvGD+tanrH9GPsDnvAQ9Cvet4qQ0ugaWHsLrlL4cEZxjR31eCSESc9uXnCNUTFmVwJYxVjwgSyrNIYGCTqR5Kx/lt34Is4zZ5JCXpm/443QFhljfPDKgnWSp8IZLsvXqjuct9Khd/zJd/4bY8fAAP7hrtkIJAA05G7ancAvmmE8ydHHxMfFM4hrTnzHqSNAEkMzadIY4r9gVj0KRiUDEWz1yvK/V05YeOHH0zKFEz1M5q0LeawtYDLIRqCfiQEHqRMDM+/MyekTcIpt9CADqaehtp4Iap60lC67jwEwhB8FKj7kkSTteqPi78kVoS4bRvpLwEB865wRE7vTuSXF5nK5uAVyCZGdcjXqhCbWSfCFDWw1qjinvugna4wJbbnj7UFJEYU50ujLvCvqR0nsJ7nBWlfiyMxMqYDtICQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri 15-11-24 12:28:01, Amir Goldstein wrote: > On Tue, Nov 12, 2024 at 6:56 PM Josef Bacik wrote: > > > > From: Amir Goldstein > > > > Similar to FAN_ACCESS_PERM permission event, but it is only allowed with > > class FAN_CLASS_PRE_CONTENT and only allowed on regular files and dirs. > > > > Unlike FAN_ACCESS_PERM, it is safe to write to the file being accessed > > in the context of the event handler. > > > > This pre-content event is meant to be used by hierarchical storage > > managers that want to fill the content of files on first read access. > > > > Signed-off-by: Amir Goldstein > > --- > > fs/notify/fanotify/fanotify.c | 3 ++- > > fs/notify/fanotify/fanotify_user.c | 22 +++++++++++++++++++--- > > include/linux/fanotify.h | 14 ++++++++++---- > > include/uapi/linux/fanotify.h | 2 ++ > > 4 files changed, 33 insertions(+), 8 deletions(-) > > > > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c > > index 2e6ba94ec405..da6c3c1c7edf 100644 > > --- a/fs/notify/fanotify/fanotify.c > > +++ b/fs/notify/fanotify/fanotify.c > > @@ -916,8 +916,9 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask, > > BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM); > > BUILD_BUG_ON(FAN_FS_ERROR != FS_ERROR); > > BUILD_BUG_ON(FAN_RENAME != FS_RENAME); > > + BUILD_BUG_ON(FAN_PRE_ACCESS != FS_PRE_ACCESS); > > > > - BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 21); > > + BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 22); > > > > mask = fanotify_group_event_mask(group, iter_info, &match_mask, > > mask, data, data_type, dir); > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c > > index 9cc4a9ac1515..2ec0cc9c85cf 100644 > > --- a/fs/notify/fanotify/fanotify_user.c > > +++ b/fs/notify/fanotify/fanotify_user.c > > @@ -1633,11 +1633,23 @@ static int fanotify_events_supported(struct fsnotify_group *group, > > unsigned int flags) > > { > > unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS; > > + bool is_dir = d_is_dir(path->dentry); > > /* Strict validation of events in non-dir inode mask with v5.17+ APIs */ > > bool strict_dir_events = FAN_GROUP_FLAG(group, FAN_REPORT_TARGET_FID) || > > (mask & FAN_RENAME) || > > (flags & FAN_MARK_IGNORE); > > > > + /* > > + * Filesystems need to opt-into pre-content evnets (a.k.a HSM) > > + * and they are only supported on regular files and directories. > > + */ > > + if (mask & FANOTIFY_PRE_CONTENT_EVENTS) { > > + if (!(path->mnt->mnt_sb->s_iflags & SB_I_ALLOW_HSM)) > > + return -EINVAL; > > Should we make this return -EOPNOTSUPP? I see no reason not to do that so go ahead. Honza -- Jan Kara SUSE Labs, CR