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 4D771CD4F5B for ; Thu, 5 Sep 2024 08:08:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C02EA6B0131; Thu, 5 Sep 2024 04:08:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAFF76B0133; Thu, 5 Sep 2024 04:08:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A510C6B0134; Thu, 5 Sep 2024 04:08:01 -0400 (EDT) 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 818E96B0131 for ; Thu, 5 Sep 2024 04:08:01 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2A3E640AE2 for ; Thu, 5 Sep 2024 08:08:01 +0000 (UTC) X-FDA: 82529956362.23.2B526FE Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf11.hostedemail.com (Postfix) with ESMTP id 6823B40016 for ; Thu, 5 Sep 2024 08:07:59 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GrzCogiK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of amir73il@gmail.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=amir73il@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725523655; a=rsa-sha256; cv=none; b=xoIcWJ6MwRh9TluMQBOFNwtscf1HtsABOpVZ4cHw6LxVrgc9xgMCtfaioo2k2ZFIr+bQ0z yaUEA4k8Fq/lkHv3A4sVj7gr06YGKtF2i10vCL9Ti1IVHnNHbLmZD6qBH194VdqQmCMuK+ DtHp+IlrzoFkMtay668Wr7lUpSnkPqM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GrzCogiK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of amir73il@gmail.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=amir73il@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725523655; 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=Q9evaM+/i7nGyrRogDxvgPy1n3dS/KfQS+d0VRsLRTo=; b=PsoaWUHI0lJ6i65YmqnWLhKRf6FNulFr3XHbuYLLiKt0jnbiGvgscy6f6qDlzKNq5+7Y9F CpkQ64QzAx+ZA+o45hgJWEkbeE+8lrdH1tYe1HE03VK4Scr5KnIB0RpWCbOFnfWZHEFlWH 6bmxYLz6Rq2a3FPLlshPZrPUfT9wj+8= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6c34c02ff1cso3201336d6.2 for ; Thu, 05 Sep 2024 01:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725523678; x=1726128478; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q9evaM+/i7nGyrRogDxvgPy1n3dS/KfQS+d0VRsLRTo=; b=GrzCogiK7vNOqf+/4676MbMsWb8FvZaRU3jwI7g/tSqO14zkYyP8yFvnMTGz1CaepX +Qop/UCBggoDWxh76zL8lWB4wF7COwB7UjHBkRB4lcmqQqmQaLeGVF5/Mlw7QoSNubx0 6Ef2GWP65yEUXcH7QSw5Jop9EXjGBC9Vy/BTeZjj/WQ25alSyj/ObOBxUCB+Cpz35xAe 5BHnzVp6xQW+DYM9XMnd2oPpNb1Iz6B7y9InBrZp5LKv8E+oNR3s0Zl27voLmilDK1Wb rgrKDVdEsiukXC03mHKSxUHsKS/Y4trxv/leRcEAxcBAg4y8weWBt7qufWsFkLQCt5+5 dHlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725523678; x=1726128478; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q9evaM+/i7nGyrRogDxvgPy1n3dS/KfQS+d0VRsLRTo=; b=uU34AJOC1OVX7lD8qUR6t420HwIG/FVwCN0WkX5TAPydt5udOdcGVD7ulOUll+diS+ 3k1jjsoHfLOhtHFg7x+pUu0jBviOWMrGTg/XhvTmDcGnbPOH5JXFJnLSPdWhEz/H0Uvz 4NPhZP4+xLyT4OfCzy7nHs/9+0Aap7b+2xFU7NaY0V8As+1sNmvfA+dRgOwDc/PW0aUA L/9Ew9ZJGT7An5CbVnvrDmCj6QMVQHeXI/KSR9ktN0V/sXcmUa6IjOmyjiKuZ64oTj4D oC5AjAQThWvA2cbmcMtGJjgMRSJXNYRGLiKWg7q1Yfz0UQRgIRTfsiZe1LOMshfRpYAe axiw== X-Forwarded-Encrypted: i=1; AJvYcCXamXdQvMkf+KuHLTUTw5i8l+dc1/m92o4PE9S79Vmv4qP2sSLwWE44bW6iPEarAwLOFXVyfTOQpg==@kvack.org X-Gm-Message-State: AOJu0YwFJw8z+Jec+0UpZ4we7BFZxRXO+1gkVObXqxKiaVqeZnS+kfVt dxCae9omiikIm8+DBZu3q/+cIdSR+zYy3nhjeLqNcpW+5nMMRDz6SL37wPKO/Q1a2cGpx8zjLXV fOYGseDu3BM5pggFb1ySvpGUNV8o= X-Google-Smtp-Source: AGHT+IH1V7cjY3UVK2E999mAtRxtZnv2ifLJeXP6Pbb6prHkryHmT1Xk5RpQhKkwMl11HK2Cz/GJl+Mgv/3CUTLzcQ0= X-Received: by 2002:a05:6214:5902:b0:6bf:7c44:f7b4 with SMTP id 6a1803df08f44-6c3556d2f6cmr218344006d6.31.1725523678325; Thu, 05 Sep 2024 01:07:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amir Goldstein Date: Thu, 5 Sep 2024 10:07:46 +0200 Message-ID: Subject: Re: [PATCH v5 10/18] fs: add a flag to indicate the fs supports pre-content events To: Josef Bacik Cc: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, brauner@kernel.org, linux-xfs@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 6823B40016 X-Rspamd-Server: rspam01 X-Stat-Signature: 5966ugw6gefsig18u3ok1rs9i5phd7ft X-HE-Tag: 1725523679-208710 X-HE-Meta: U2FsdGVkX1/iOAaeenxfvLBUmzzWXFVshnoFDS/pOc0S3+26UxAMH7KDubjld/Tx4Lr1JMpDGgg5FV2K2iDYlwWjXFJHi3stDAJBi6uES3z0WW096BDMSUduMoxOLSJ51Db1/Gfc4BRb/aDUBijlXzGePWF48zS2kBg02YJXsVgnGDpk10hVrkfs0At6s+oQ3j3N7krVHZy+ORHyksqjGkBygcCE8HBqDSlp3qTZOPFpGKhMGZhKKAZRiWZffSUrYwHGTtESzkWm8Szwc5/LlBb+3//vmcXeRg24fahbW80dtMmU9SbtEBE4wSz8lcZWlanJBWI3ghGJB+i9j+XrqVuq9cXO6gmn7+CeU45DcnPNJy4ECZWSl2RD+IkujmrPBp1CgJyISVezw1hwhUKkxvPeqqPdRGTsHFlzNlvVpIP6pPslXVRpsjIRW8rLWJhjIdyAFXmFb07QI06RiTPagsSarMIfO+E2/7EK4WS/n4tUIMYu9WCoZE1PwGkgCzJHyMVulj7TSUdgigaT1ex7ZTz+V+8ALcYRyI3e+fnQ6bZ0Nlq4RDAh+mBvXL8q/IH0MGzfBZCHeH1dlWEjHv5qFss/ll7TynHV0xk7hOpf17NoJoPkTMrRP18Cg4m0wVGTC8TcSThSbmS99EHqUkjrX6D5ZE6VtcMOR5c1jw61ZZGY68qTnCH4P2fKJHOPhdKYSXqq2RtYvp8Bg8kEcjvRLGhuMatOcKuNBwU0/2RJMh/sLyVF8kZNDTf7trsRbwmTdWtW8idTjdvA+IG6fBDfM15dHVjb0rI3OduEzA3Ipo1b4XQdlCplqUrM1UtSohg99eR27Ugf5+yvAan15brQCfk3LJ2nfz72Pk84sCUYWV4SquKgPk6WGneLoXOw5UPI1ibfe2cC8R51mznp3zvg7kDdSPAoPqV1QObsL5Ln/TstJpqnC6K6VhzX8W3THvZsrwux/WyGPzN1AC7b+RF Yz/+YDMI HJgD/pp8pczWl5RzE9qNzsAHo6Clmz1FR2BFjlkMdH48T0RYX4ia5rYfAAOF/PLjeCaQF7ULfIZLDiFCVxsJdTV7eq7dC/a53Mb6MhALPdKIP2hQHPQ2e4IuO2EoVZ8iedMgKOOwvu/4qbmaqisMJeQhCYefWkPCei4I9LR/711WGfbxMeXD9c1XGz+ujTlzAEY9yHZK+ILeHY/HCkRDdE2jhtu6o/cl6u6m2R37CoadIUEKNakDn4+cfTkxf/gyCf/yAIP8buiFSMpgz/p5NUyIB/8rDSAbUHO3OCrtJT2ZCImyNaUSfzDho6rb0eGqkrWXUc/F/45s5/2PfgrIfbZOFt2BxTpGXKYUQstqucvrIcepqOxUvCxA7i3sctAu8b8qR 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 Wed, Sep 4, 2024 at 10:29=E2=80=AFPM Josef Bacik = wrote: > > The pre-content events require some extra thinking, especially around > page faults. In order to make sure we don't advertise a feature working > that doesn't actually work, add a flag to allow file systems to opt-in > to this behavior. > > Signed-off-by: Josef Bacik Better squash this patch to FAN_PRE_ACCESS patch, so it will not be allowed to mark with FAN_PRE_ACCESS on unsupported fs mid series. OR - move this patch before the FAN_PRE_ACCESS patch and pre-define FANOTIFY_PRE_CONTENT_EVENTS to 0. Apart from that, you may add: Reviewed-by: Amir Goldstein Thanks, Amir. > --- > fs/notify/fanotify/fanotify_user.c | 2 ++ > include/linux/fs.h | 1 + > include/linux/fsnotify.h | 4 ++++ > 3 files changed, 7 insertions(+) > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fano= tify_user.c > index 53eee8af34a0..936e9f9e0cbc 100644 > --- a/fs/notify/fanotify/fanotify_user.c > +++ b/fs/notify/fanotify/fanotify_user.c > @@ -1736,6 +1736,8 @@ static int fanotify_events_supported(struct fsnotif= y_group *group, > > /* Pre-content events are only supported on regular files and dir= s */ > if (mask & FANOTIFY_PRE_CONTENT_EVENTS) { > + if (!(path->mnt->mnt_sb->s_type->fs_flags & FS_ALLOW_HSM)= ) > + return -EINVAL; > if (!is_dir && !d_is_reg(path->dentry)) > return -EINVAL; > if (is_dir && mask & FAN_PRE_MODIFY) > diff --git a/include/linux/fs.h b/include/linux/fs.h > index fd34b5755c0b..5708e91d3625 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2494,6 +2494,7 @@ struct file_system_type { > #define FS_USERNS_MOUNT 8 /* Can be mounted by user= ns root */ > #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permi= ssion events */ > #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle = vfs idmappings. */ > +#define FS_ALLOW_HSM 64 /* FS can handle fanotify pre-con= tent events. */ > #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during= rename() internally. */ > int (*init_fs_context)(struct fs_context *); > const struct fs_parameter_spec *parameters; > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > index 9d001d328619..27992b548f0c 100644 > --- a/include/linux/fsnotify.h > +++ b/include/linux/fsnotify.h > @@ -179,6 +179,10 @@ static inline int fsnotify_file_area_perm(struct fil= e *file, int perm_mask, > if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode)) > return 0; > > + /* The fs doesn't support pre-content events. */ > + if (!(inode->i_sb->s_type->fs_flags & FS_ALLOW_HSM)) > + return 0; > + > if (perm_mask & MAY_WRITE) > fsnotify_mask =3D FS_PRE_MODIFY; > else if (perm_mask & (MAY_READ | MAY_ACCESS)) > -- > 2.43.0 >