[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <xslmwjulygnvrqvzevrzj5clalxwhqnmv5p2k2yvrp56bkqdn6@bbdmfeb24axf>
Date: Mon, 26 Feb 2024 16:22:11 -0600
From: John Groves <John@...ves.net>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: John Groves <jgroves@...ron.com>, Jonathan Corbet <corbet@....net>,
Dan Williams <dan.j.williams@...el.com>, Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, Matthew Wilcox <willy@...radead.org>,
linux-cxl@...r.kernel.org, linux-fsdevel@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, nvdimm@...ts.linux.dev, john@...alactic.com,
Dave Chinner <david@...morbit.com>, Christoph Hellwig <hch@...radead.org>,
dave.hansen@...ux.intel.com, gregory.price@...verge.com
Subject: Re: [RFC PATCH 10/20] famfs: famfs_open_device() &
dax_holder_operations
On 24/02/26 12:56PM, Jonathan Cameron wrote:
> On Fri, 23 Feb 2024 11:41:54 -0600
> John Groves <John@...ves.net> 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@...ves.net>
>
> Formatting comments mostly same as previous patches, so I'll stop repeating them.
I tried to bulk apply those recommendations.
>
> > ---
> > 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(
> > + 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;
> Definitely don't force alignment in local parameter definitions.
> Always goes wrong and makes for unreadable mess in patches!
Okay, undone. Everywhere.
>
> > +
> > + if (fsi->dax_devp) {
> > + pr_err("%s: already mounted\n", __func__);
> Fine to fail but worth a error message? Not sure on convention on this but seems noisy
> and maybe in userspace control which isn't good.
Changing to pr_debug. Would be good to have access to it in that way
> > + 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 */
> > + 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);
> > + if (IS_ERR(handlep->bdev)) {
> > + pr_err("%s: failed blkdev_get_by_path(%s)\n", __func__, fc->source);
> > + return PTR_ERR(handlep->bdev);
> > + }
> > +
> > + dax_devp = fs_dax_get_by_bdev(handlep->bdev, &start_off,
> > + fsi /* holder */,
> > + &famfs_blk_dax_holder_ops);
> > + if (IS_ERR(dax_devp)) {
> > + pr_err("%s: unable to get daxdev from handlep->bdev\n", __func__);
> > + bdev_release(handlep);
> > + return -ENODEV;
> > + }
> > + fsi->bdev_handle = handlep;
> > + fsi->dax_devp = dax_devp;
> > +
> > + pr_notice("%s: root device is block dax (%s)\n", __func__, fc->source);
>
> pr_debug() Kernel log is too noisy anyway! + I'd assume we can tell this succeeded
> in lots of other ways.
Done
>
>
> > + return 0;
> > +}
> > +
> > +
> >
> > MODULE_LICENSE("GPL");
Thanks,
John
>
Powered by blists - more mailing lists