Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1239665rda; Mon, 23 Oct 2023 06:56:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYgTBqt8H2+ti2YpVEyx2OS5uyH9EZkWlrrIBr7a/Bi/ctRMkd4VvhIH1+HV8HTLAGyeMv X-Received: by 2002:a05:6a21:3b45:b0:17b:426f:829 with SMTP id zy5-20020a056a213b4500b0017b426f0829mr8711697pzb.37.1698069360944; Mon, 23 Oct 2023 06:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698069360; cv=none; d=google.com; s=arc-20160816; b=HCIYZfsovudG2DzaiXxB0LJXQO3wC6aYLIf05iordmFKdBGkUCELE1BrM3N21bArJP 8MiOzDfVfVMWtdvaApUI4h/cGw6luAiH1oA11maSWHtiBZr2X3imeCwJIXynm1tpUIzQ 4e+mV5eQrUph3bHrGyGC+a8g10Qf3bfuIX/OH5mhGlTnWPF7C/cjJcyE/0548ZwJPcN3 o5v/DvZ+BAobuB6SY6jgSvPwzw81DzTla1I3CDBKJJ/3vxaZpgo9O0Dl93E9jdcGaUDH fF/VoOYissXmo0+pvs7smzqNaR7PFKaKwHY6ecnPBqouk6pg+HO0tnsiNr5SMp+528Xp Du7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iPMGAbfbGK+qnLdNLN/64hlEEDrMuPiSA0pG5FYaVUE=; fh=+RsDa26EtFinitAHzEdIrc6gnUrGy2h3/tPcdrnXlys=; b=ghfNf6bgkkMs2HS9tx1hfn1iq2SnRlxP5VXAHjNtcFNjfIUsWjUanQcbi8ZfeeND1A aedRW1QTjzBOLY04q6S98Elzgz+mrtzNGTc3mD01s3XE/ObzBOn9d2IDx/bckXgB9XJS 3ghdwf6dsUZ83deBJTj9wup51NWlZo7meAjtZjAeAlI4btBnv3vJMBBR2xSejlPte0Fi 6tue8RyQ8LC4+yZUXvXcV3GZqsnPG3VetoVToTHVDhFHfTUuDMDD+wrYbcDT9kEa40NB w3EyV3M+7oNGbkoHL817m0rVwpjeD1BZ1qOOze4hOzx4ChxH7WoSEFQxxwO+u6ycSgXP ebgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fiNWZqb3; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e9-20020aa798c9000000b00690f74dd2ccsi6485793pfm.69.2023.10.23.06.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fiNWZqb3; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BCAD0807F49B; Mon, 23 Oct 2023 06:55:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbjJWNzz (ORCPT + 99 others); Mon, 23 Oct 2023 09:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjJWNzy (ORCPT ); Mon, 23 Oct 2023 09:55:54 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AB59101; Mon, 23 Oct 2023 06:55:52 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-41cd444d9d0so19161601cf.2; Mon, 23 Oct 2023 06:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698069351; x=1698674151; darn=vger.kernel.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=iPMGAbfbGK+qnLdNLN/64hlEEDrMuPiSA0pG5FYaVUE=; b=fiNWZqb3fACXY82aLv4gCbe2BznksQYTpAiG1HNd3f6awoNGzmIyVb5FAYJN80Xusx ZfBsHatYCsIOWEVDUKroW5nKgManZVXbA8Mya7kZQa/OJbU8kNtzGSTIJpHFxCgfof7e J+YKaa6yEfBtCC5dA5AO0pnUy58UUVzpsitrnVg954Vg/gBEaZXuq0YoUZYZBs5xMFgM iiUbIuv32lGR7Ydu0PECDSTrQk1cJmTnoPLXfH9hd9jWVOLXsMylRFB13tw35QuDdu2K qfvgTM2835clJ9OQeBrf31dxElTF52x1m5FAEWgI9fisV6Qn5uqh8XgsXCVzQRlaVCAP 90bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698069351; x=1698674151; 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=iPMGAbfbGK+qnLdNLN/64hlEEDrMuPiSA0pG5FYaVUE=; b=imTm/5ptaZOu/Gv/hohxEUy3bOWuf0Q+QmXGSVudjrvBW52CNGvNYH8NivpSy0xrzn TnDdwa3LXXVVrYvPsladGzMBOoLUnsXthvdxwNdEkR72ZqzV5lVvI25j6h5hr1YLUmCd KUNt9jHJvAMc6ZBZQpo1phMZ/h4M4z/3zFvaYvR6xFae7idbuFeUlofFjWv4P+JE5Jkw zDoCZdlZDzP8MHCGW3Z67eVD4maxP1ceo5wLsqJU9eN7SUGU65onXmUnqSgdd/nFbmr2 MxQ5PRvdNVNdbzxbtLH2T7tFCNpl0qoG6N9+2qLhPFjFJ0GnteVPVLksQ9tSUo82LL9F wcQQ== X-Gm-Message-State: AOJu0Yw+1RQnMPJgWnbFKgyY8ZBoP+aaCA7FAQKfctmymaZupFxsrw0F OnxbkBga897XkdxGgCuCLOYOfqKpp4bmYLRtAzU= X-Received: by 2002:a05:6214:19ed:b0:66d:1e8f:bb98 with SMTP id q13-20020a05621419ed00b0066d1e8fbb98mr9957696qvc.59.1698069351488; Mon, 23 Oct 2023 06:55:51 -0700 (PDT) MIME-Version: 1.0 References: <20231018100000.2453965-1-amir73il@gmail.com> <20231018100000.2453965-6-amir73il@gmail.com> In-Reply-To: <20231018100000.2453965-6-amir73il@gmail.com> From: Amir Goldstein Date: Mon, 23 Oct 2023 16:55:40 +0300 Message-ID: Subject: Re: [PATCH 5/5] exportfs: support encoding non-decodeable file handles by default To: Jan Kara Cc: Jeff Layton , Chuck Lever , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 06:55:56 -0700 (PDT) On Wed, Oct 18, 2023 at 1:00=E2=80=AFPM Amir Goldstein = wrote: > > AT_HANDLE_FID was added as an API for name_to_handle_at() that request > the encoding of a file id, which is not intended to be decoded. > > This file id is used by fanotify to describe objects in events. > > So far, overlayfs is the only filesystem that supports encoding > non-decodeable file ids, by providing export_operations with an > ->encode_fh() method and without a ->decode_fh() method. > > Add support for encoding non-decodeable file ids to all the filesystems > that do not provide export_operations, by encoding a file id of type > FILEID_INO64_GEN from { i_ino, i_generation }. > > A filesystem may that does not support NFS export, can opt-out of > encoding non-decodeable file ids for fanotify by defining an empty > export_operations struct (i.e. with a NULL ->encode_fh() method). > > This allows the use of fanotify events with file ids on filesystems > like 9p which do not support NFS export to bring fanotify in feature > parity with inotify on those filesystems. > > Note that fanotify also requires that the filesystems report a non-null > fsid. Currently, many simple filesystems that have support for inotify > (e.g. debugfs, tracefs, sysfs) report a null fsid, so can still not be > used with fanotify in file id reporting mode. > > Signed-off-by: Amir Goldstein > --- Hi Jan, Did you get a chance to look at this patch? I saw your review comments on the rest of the series, so was waiting for feedback on this last one before posting v2. BTW, I am going to post a complementary patch to add fsid support for the simple filesystems. Thanks, Amir. > fs/exportfs/expfs.c | 30 +++++++++++++++++++++++++++--- > include/linux/exportfs.h | 10 +++++++--- > 2 files changed, 34 insertions(+), 6 deletions(-) > > diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c > index 30da4539e257..34e7d835d4ef 100644 > --- a/fs/exportfs/expfs.c > +++ b/fs/exportfs/expfs.c > @@ -383,6 +383,30 @@ int generic_encode_ino32_fh(struct inode *inode, __u= 32 *fh, int *max_len, > } > EXPORT_SYMBOL_GPL(generic_encode_ino32_fh); > > +/** > + * exportfs_encode_ino64_fid - encode non-decodeable 64bit ino file id > + * @inode: the object to encode > + * @fid: where to store the file handle fragment > + * @max_len: maximum length to store there > + * > + * This generic function is used to encode a non-decodeable file id for > + * fanotify for filesystems that do not support NFS export. > + */ > +static int exportfs_encode_ino64_fid(struct inode *inode, struct fid *fi= d, > + int *max_len) > +{ > + if (*max_len < 3) { > + *max_len =3D 3; > + return FILEID_INVALID; > + } > + > + fid->i64.ino =3D inode->i_ino; > + fid->i64.gen =3D inode->i_generation; > + *max_len =3D 3; > + > + return FILEID_INO64_GEN; > +} > + > /** > * exportfs_encode_inode_fh - encode a file handle from inode > * @inode: the object to encode > @@ -401,10 +425,10 @@ int exportfs_encode_inode_fh(struct inode *inode, s= truct fid *fid, > if (!exportfs_can_encode_fh(nop, flags)) > return -EOPNOTSUPP; > > - if (nop && nop->encode_fh) > - return nop->encode_fh(inode, fid->raw, max_len, parent); > + if (!nop && (flags & EXPORT_FH_FID)) > + return exportfs_encode_ino64_fid(inode, fid, max_len); > > - return -EOPNOTSUPP; > + return nop->encode_fh(inode, fid->raw, max_len, parent); > } > EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh); > > diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h > index 21eeb9f6bdbd..6688e457da64 100644 > --- a/include/linux/exportfs.h > +++ b/include/linux/exportfs.h > @@ -134,7 +134,11 @@ struct fid { > u32 parent_ino; > u32 parent_gen; > } i32; > - struct { > + struct { > + u64 ino; > + u32 gen; > + } __packed i64; > + struct { > u32 block; > u16 partref; > u16 parent_partref; > @@ -246,7 +250,7 @@ extern int exportfs_encode_fh(struct dentry *dentry, = struct fid *fid, > > static inline bool exportfs_can_encode_fid(const struct export_operation= s *nop) > { > - return nop && nop->encode_fh; > + return !nop || nop->encode_fh; > } > > static inline bool exportfs_can_decode_fh(const struct export_operations= *nop) > @@ -259,7 +263,7 @@ static inline bool exportfs_can_encode_fh(const struc= t export_operations *nop, > { > /* > * If a non-decodeable file handle was requested, we only need to= make > - * sure that filesystem can encode file handles. > + * sure that filesystem did not opt-out of encoding fid. > */ > if (fh_flags & EXPORT_FH_FID) > return exportfs_can_encode_fid(nop); > -- > 2.34.1 >