Re: [PATCH v2 30/31] nfsd: only allow filesystems that set EXPORT_OP_STABLE_HANDLES
Chuck Lever <[email protected]>
| Newsgroups | dev.linux.lists.gfs2,dev.linux.lists.ntfs3,dev.linux.lists.ocfs2-devel,net.sourceforge.lists.linux-f2fs-devel,org.infradead.lists.linux-mtd,org.kernel.vger.ceph-devel,org.kernel.vger.linux-btrfs,org.kernel.vger.linux-cifs,org.kernel.vger.linux-doc,org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs,org.kernel.vger.linux-nilfs,org.kernel.vger.linux-unionfs,org.kernel.vger.linux-xfs,org.kvack.linux-mm,org.ozlabs.lists.linux-erofs |
|---|---|
| Message-ID | <[email protected]> |
On 1/19/26 11:26 AM, Jeff Layton wrote: > Some filesystems have grown export operations in order to provide > filehandles for local usage. Some of these filesystems are unsuitable > for use with nfsd, since their filehandles are not stable across > reboots. > > In check_export(), check whether EXPORT_OP_STABLE_HANDLES is set > and return -EINVAL if it isn't. > > Signed-off-by: Jeff Layton <[email protected]> > --- > fs/nfsd/export.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c > index 2a1499f2ad196a6033787260881e451146283bdc..bc703cf58bfa210c7c57d49f22f15bc10d7cfc91 100644 > --- a/fs/nfsd/export.c > +++ b/fs/nfsd/export.c > @@ -422,13 +422,15 @@ static int check_export(const struct path *path, int *flags, unsigned char *uuid > if (*flags & NFSEXP_V4ROOT) > *flags |= NFSEXP_READONLY; > > - /* There are two requirements on a filesystem to be exportable. > - * 1: We must be able to identify the filesystem from a number. > + /* There are four requirements on a filesystem to be exportable: > + * 1: We must be able to identify the filesystem from a number. > * either a device number (so FS_REQUIRES_DEV needed) > * or an FSID number (so NFSEXP_FSID or ->uuid is needed). > - * 2: We must be able to find an inode from a filehandle. > + * 2: We must be able to find an inode from a filehandle. > * This means that s_export_op must be set. > - * 3: We must not currently be on an idmapped mount. > + * 3: It must provide stable filehandles. > + * This means that EXPORT_OP_STABLE_HANDLES is set > + * 4: We must not currently be on an idmapped mount. > */ Let's avoid the royal "we" here... It seems to mean something different in each of these rules. How about: 1. The filehandle must identify a filesystem by number 2. The filehandle must uniquely identify an inode 3. The exported filesystem must provide stable filehandles 4. The requested file must not reside on an idmapped mount > if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) && > !(*flags & NFSEXP_FSID) && > @@ -442,6 +444,11 @@ static int check_export(const struct path *path, int *flags, unsigned char *uuid > return -EINVAL; > } > > + if (!(inode->i_sb->s_export_op->flags & EXPORT_OP_STABLE_HANDLES)) { > + dprintk("%s: fs does not provide stable filehandles!\n", __func__); > + return -EINVAL; > + } > + > if (is_idmapped_mnt(path->mnt)) { > dprintk("exp_export: export of idmapped mounts not yet supported.\n"); > return -EINVAL; > Reviewed-by: Chuck Lever <[email protected]> -- Chuck Lever