Re: [RFC PATCH 10/20] famfs: famfs_open_device() & dax_holder_operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/02/27 02:39PM, Christian Brauner wrote:
> On Fri, Feb 23, 2024 at 11:41:54AM -0600, John Groves wrote:
> > Famfs works on both /dev/pmem and /dev/dax devices. This commit introduces
> > the function that opens a block (pmem) device and the struct
> > dax_holder_operations that are needed for that ABI.
> > 
> > In this commit, support for opening character /dev/dax is stubbed. A
> > later commit introduces this capability.
> > 
> > Signed-off-by: John Groves <john@xxxxxxxxxx>
> > ---
> >  fs/famfs/famfs_inode.c | 83 ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 83 insertions(+)
> > 
> > diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c
> > index 3329aff000d1..82c861998093 100644
> > --- a/fs/famfs/famfs_inode.c
> > +++ b/fs/famfs/famfs_inode.c
> > @@ -68,5 +68,88 @@ static const struct super_operations famfs_ops = {
> >  	.show_options	= famfs_show_options,
> >  };
> >  
> > +/***************************************************************************************
> > + * dax_holder_operations for block dax
> > + */
> > +
> > +static int
> > +famfs_blk_dax_notify_failure(
> > +	struct dax_device	*dax_devp,
> > +	u64			offset,
> > +	u64			len,
> > +	int			mf_flags)
> > +{
> > +
> > +	pr_err("%s: dax_devp %llx offset %llx len %lld mf_flags %x\n",
> > +	       __func__, (u64)dax_devp, (u64)offset, (u64)len, mf_flags);
> > +	return -EOPNOTSUPP;
> > +}
> > +
> > +const struct dax_holder_operations famfs_blk_dax_holder_ops = {
> > +	.notify_failure		= famfs_blk_dax_notify_failure,
> > +};
> > +
> > +static int
> > +famfs_open_char_device(
> > +	struct super_block *sb,
> > +	struct fs_context  *fc)
> > +{
> > +	pr_err("%s: Root device is %s, but your kernel does not support famfs on /dev/dax\n",
> > +	       __func__, fc->source);
> > +	return -ENODEV;
> > +}
> > +
> > +/**
> > + * famfs_open_device()
> > + *
> > + * Open the memory device. If it looks like /dev/dax, call famfs_open_char_device().
> > + * Otherwise try to open it as a block/pmem device.
> > + */
> > +static int
> > +famfs_open_device(
> 
> I'm confused why that function is added here but it's completely unclear
> in what wider context it's called. This is really hard to follow.

First, thank you for taking the time to do a thoughtful review.

I didn't factor this series correctly. The next one will be
"module-operations-up" unless you or somebody suggests a more sensible
approach.

Some background that might be useful: this work is really targeted for 
/dev/dax, but it started on /dev/pmem because the iomap interface wasn't 
working on /dev/dax. This patch addresses that (the dev_dax_iomap commits), 
although it's likely that code will evolve.

The current famfs code base tries to support both pmem (block) and /dev/dax 
(char), but I'm now thinking it should move to /dev/dax-only (no block 
support).

/dev/pmem devices can converted to /dev/dax mode anyway, so I'm not sure 
there is a reason to support both interfaces. (Need to think a bit more on 
that...).

> 
> > +	struct super_block *sb,
> > +	struct fs_context  *fc)
> > +{
> > +	struct famfs_fs_info *fsi = sb->s_fs_info;
> > +	struct dax_device    *dax_devp;
> > +	u64 start_off = 0;
> > +	struct bdev_handle   *handlep;
> > +
> > +	if (fsi->dax_devp) {
> > +		pr_err("%s: already mounted\n", __func__);
> > +		return -EALREADY;
> > +	}
> > +
> > +	if (strstr(fc->source, "/dev/dax")) /* There is probably a better way to check this */
> > +		return famfs_open_char_device(sb, fc);
> > +
> > +	if (!strstr(fc->source, "/dev/pmem")) { /* There is probably a better way to check this */
> 
> Yeah, this is not just a bit ugly but also likely wrong because:
> 
> sudo mount --bind /dev/pmem /opt/muhaha
> 
> fsconfig(fd_fs, FSCONFIG_SET_STRING, "source", "/opt/muhaha", [...])
> 
> or a simple mknod to create that device somewhere else. You likely want:
> 
> lookup_bdev(fc->source, &dev);
> 
> if (!DEVICE_NUMBER_SOMETHING_SOMETHING_SANE(dev))
> 	return invalfc(fc, "SOMETHING SOMETHING...
> 
> bdev_open_by_dev(dev, ....)
> 
> (This reminds me that I should get back to making it possible to specify
> "source" as a file descriptor instead of a mere string with the new
> mount api...)

All good points - sorry for the flakyness here.

I think the solution is to stop trying to support both pmem and dax. Then 
I don't need to distinguish between different device types.

> 
> > +		pr_err("%s: primary backing dev (%s) is not pmem\n",
> > +		       __func__, fc->source);
> > +		return -EINVAL;
> > +	}
> > +
> > +	handlep = bdev_open_by_path(fc->source, FAMFS_BLKDEV_MODE, fsi, &fs_holder_ops);
> 
> Hm, I suspected that FAMFS_BLKDEV_MODE would be wrong based on:
> https://lore.kernel.org/r/13556dbbd8d0f51bc31e3bdec796283fe85c6baf.1708709155.git.john@xxxxxxxxxx
> 
> It's defined as FMODE_READ | FMODE_WRITE which is wrong. But these
> helpers want BLOCK_OPEN_READ | BLOCK_OPEN_WRITE.

Dropping pmem/block support will also make this go away

> 
> > +	if (IS_ERR(handlep->bdev)) {
> 
> @bdev_handle will be gone as of v6.9 so you might want to wait until
> then to resend.

And this dependency will also disappear...

Thank you!!
John





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux