Message ID | 20230829-vfs-super-mtd-v1-1-fecb572e5df3@kernel.org |
---|---|
State | New |
Headers | show |
Series | mtd: switch to keying by dev_t | expand |
> + return sget_fc(fc, super_s_dev_set, super_s_dev_test);
return sget_fc(fc, super_s_dev_test, super_s_dev_set);
Sorry, dumb typo that I had already fixed in tree...
----- Ursprüngliche Mail ----- > Von: "Christian Brauner" <brauner@kernel.org> > An: "hch" <hch@lst.de>, "Jan Kara" <jack@suse.cz>, "richard" <richard@nod.at> > CC: "Miquel Raynal" <miquel.raynal@bootlin.com>, "Vignesh Raghavendra" <vigneshr@ti.com>, "linux-mtd" > <linux-mtd@lists.infradead.org>, "linux-fsdevel" <linux-fsdevel@vger.kernel.org> > Gesendet: Dienstag, 29. August 2023 18:29:16 > Betreff: Re: [PATCH 1/2] fs: export sget_dev() >> + return sget_fc(fc, super_s_dev_set, super_s_dev_test); > > return sget_fc(fc, super_s_dev_test, super_s_dev_set); > > Sorry, dumb typo that I had already fixed in tree... What tree does this patch apply to? linux-next? I gave it a quick try on Linus' tree but it failed too: fs/super.c: In function ‘get_tree_bdev’: fs/super.c:1293:19: error: ‘dev’ undeclared (first use in this function); did you mean ‘bdev’? s = sget_dev(fc, dev); ^~~ bdev fs/super.c:1293:19: note: each undeclared identifier is reported only once for each function it appears in Thanks, //richard
On Tue, Aug 29, 2023 at 06:55:04PM +0200, Richard Weinberger wrote: > What tree does this patch apply to? linux-next? > I gave it a quick try on Linus' tree but it failed too: > > fs/super.c: In function ‘get_tree_bdev’: > fs/super.c:1293:19: error: ‘dev’ undeclared (first use in this function); did you mean ‘bdev’? > s = sget_dev(fc, dev); > ^~~ > bdev > fs/super.c:1293:19: note: each undeclared identifier is reported only once for each function it appears in Should be against the latest Linus tree after the merge of the vfs branches yesterday.
> +struct super_block *sget_dev(struct fs_context *fc, dev_t dev)
A kerneldoc comment would probably be useful here.
On Wed, Aug 30, 2023 at 08:13:45AM +0200, hch wrote: > On Tue, Aug 29, 2023 at 06:55:04PM +0200, Richard Weinberger wrote: > > What tree does this patch apply to? linux-next? > > I gave it a quick try on Linus' tree but it failed too: > > > > fs/super.c: In function ‘get_tree_bdev’: > > fs/super.c:1293:19: error: ‘dev’ undeclared (first use in this function); did you mean ‘bdev’? > > s = sget_dev(fc, dev); > > ^~~ > > bdev > > fs/super.c:1293:19: note: each undeclared identifier is reported only once for each function it appears in > > Should be against the latest Linus tree after the merge of the vfs > branches yesterday. I would suggest to just pull it from: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git b4/vfs-super-mtd
On Wed, Aug 30, 2023 at 08:14:09AM +0200, Christoph Hellwig wrote: > > +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) > > A kerneldoc comment would probably be useful here. Added the following in-treep: diff --git a/fs/super.c b/fs/super.c index 158e093f23c9..19fa906b118a 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1388,6 +1388,26 @@ static int super_s_dev_test(struct super_block *s, struct fs_context *fc) s->s_dev == *(dev_t *)fc->sget_key; } +/** + * sget_dev - Find or create a superblock by device number + * @fc: Filesystem context. + * @dev: device number + * + * Find or create a superblock using the provided device number that + * will be stored in fc->sget_key. + * + * If an extant superblock is matched, then that will be returned with + * an elevated reference count that the caller must transfer or discard. + * + * If no match is made, a new superblock will be allocated and basic + * initialisation will be performed (s_type, s_fs_info and s_id will be + * set and the set() callback will be invoked), the superblock will be + * published and it will be returned in a partially constructed state + * with SB_BORN and SB_ACTIVE as yet unset. + * + * Return: an existing or newly created superblock on success, an an + * error pointer on failure. + */ struct super_block *sget_dev(struct fs_context *fc, dev_t dev) { fc->sget_key = &dev;
On Wed 30-08-23 10:05:57, Christian Brauner wrote: > On Wed, Aug 30, 2023 at 08:14:09AM +0200, Christoph Hellwig wrote: > > > +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) > > > > A kerneldoc comment would probably be useful here. > > Added the following in-treep: > > diff --git a/fs/super.c b/fs/super.c > index 158e093f23c9..19fa906b118a 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -1388,6 +1388,26 @@ static int super_s_dev_test(struct super_block *s, struct fs_context *fc) > s->s_dev == *(dev_t *)fc->sget_key; > } > > +/** > + * sget_dev - Find or create a superblock by device number > + * @fc: Filesystem context. > + * @dev: device number ^^^^^^ inconsistent indenting. > + * > + * Find or create a superblock using the provided device number that > + * will be stored in fc->sget_key. > + * > + * If an extant superblock is matched, then that will be returned with > + * an elevated reference count that the caller must transfer or discard. > + * > + * If no match is made, a new superblock will be allocated and basic > + * initialisation will be performed (s_type, s_fs_info and s_id will be > + * set and the set() callback will be invoked), the superblock will be ^^ I guess no point in talking about set() callback when sget_dev() has no callback specified. Rather you could mention s_dev as one of initialized fields. Honza
On Wed, Aug 30, 2023 at 11:38:51AM +0200, Jan Kara wrote: > On Wed 30-08-23 10:05:57, Christian Brauner wrote: > > On Wed, Aug 30, 2023 at 08:14:09AM +0200, Christoph Hellwig wrote: > > > > +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) > > > > > > A kerneldoc comment would probably be useful here. > > > > Added the following in-treep: > > > > diff --git a/fs/super.c b/fs/super.c > > index 158e093f23c9..19fa906b118a 100644 > > --- a/fs/super.c > > +++ b/fs/super.c > > @@ -1388,6 +1388,26 @@ static int super_s_dev_test(struct super_block *s, struct fs_context *fc) > > s->s_dev == *(dev_t *)fc->sget_key; > > } > > > > +/** > > + * sget_dev - Find or create a superblock by device number > > + * @fc: Filesystem context. > > + * @dev: device number > ^^^^^^ inconsistent indenting. Fixed, thanks! > > > + * > > + * Find or create a superblock using the provided device number that > > + * will be stored in fc->sget_key. > > + * > > + * If an extant superblock is matched, then that will be returned with > > + * an elevated reference count that the caller must transfer or discard. > > + * > > + * If no match is made, a new superblock will be allocated and basic > > + * initialisation will be performed (s_type, s_fs_info and s_id will be > > + * set and the set() callback will be invoked), the superblock will be > ^^ I guess no point in talking about set() callback when sget_dev() > has no callback specified. Rather you could mention s_dev as one of > initialized fields. Yeah, good point. Done.
> Yeah, good point. Done. From fe40c7fe1a87814f92f9b1d0b9fb78ac69404c33 Mon Sep 17 00:00:00 2001 From: Christian Brauner <brauner@kernel.org> Date: Tue, 29 Aug 2023 15:05:28 +0200 Subject: [PATCH 1/2] fs: export sget_dev() They will be used for mtd devices as well. Signed-off-by: Christian Brauner <brauner@kernel.org> --- fs/super.c | 64 ++++++++++++++++++++++++++++++++-------------- include/linux/fs.h | 1 + 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/fs/super.c b/fs/super.c index ad7ac3a24d38..d27d80bf7c43 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1371,6 +1371,50 @@ int get_tree_keyed(struct fs_context *fc, } EXPORT_SYMBOL(get_tree_keyed); +static int set_bdev_super(struct super_block *s, void *data) +{ + s->s_dev = *(dev_t *)data; + return 0; +} + +static int super_s_dev_set(struct super_block *s, struct fs_context *fc) +{ + return set_bdev_super(s, fc->sget_key); +} + +static int super_s_dev_test(struct super_block *s, struct fs_context *fc) +{ + return !(s->s_iflags & SB_I_RETIRED) && + s->s_dev == *(dev_t *)fc->sget_key; +} + +/** + * sget_dev - Find or create a superblock by device number + * @fc: Filesystem context. + * @dev: device number + * + * Find or create a superblock using the provided device number that + * will be stored in fc->sget_key. + * + * If an extant superblock is matched, then that will be returned with + * an elevated reference count that the caller must transfer or discard. + * + * If no match is made, a new superblock will be allocated and basic + * initialisation will be performed (s_type, s_fs_info, s_id, s_dev will + * be set). The superblock will be published and it will be returned in + * a partially constructed state with SB_BORN and SB_ACTIVE as yet + * unset. + * + * Return: an existing or newly created superblock on success, an error + * pointer on failure. + */ +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) +{ + fc->sget_key = &dev; + return sget_fc(fc, super_s_dev_test, super_s_dev_set); +} +EXPORT_SYMBOL(sget_dev); + #ifdef CONFIG_BLOCK /* * Lock a super block that the callers holds a reference to. @@ -1429,23 +1473,6 @@ const struct blk_holder_ops fs_holder_ops = { }; EXPORT_SYMBOL_GPL(fs_holder_ops); -static int set_bdev_super(struct super_block *s, void *data) -{ - s->s_dev = *(dev_t *)data; - return 0; -} - -static int set_bdev_super_fc(struct super_block *s, struct fs_context *fc) -{ - return set_bdev_super(s, fc->sget_key); -} - -static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc) -{ - return !(s->s_iflags & SB_I_RETIRED) && - s->s_dev == *(dev_t *)fc->sget_key; -} - int setup_bdev_super(struct super_block *sb, int sb_flags, struct fs_context *fc) { @@ -1523,8 +1550,7 @@ int get_tree_bdev(struct fs_context *fc, } fc->sb_flags |= SB_NOSEC; - fc->sget_key = &dev; - s = sget_fc(fc, test_bdev_super_fc, set_bdev_super_fc); + s = sget_dev(fc, dev); if (IS_ERR(s)) return PTR_ERR(s); diff --git a/include/linux/fs.h b/include/linux/fs.h index ca8ceccde3d6..8a8d1cd5b0a9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2274,6 +2274,7 @@ struct super_block *sget(struct file_system_type *type, int (*test)(struct super_block *,void *), int (*set)(struct super_block *,void *), int flags, void *data); +struct super_block *sget_dev(struct fs_context *fc, dev_t dev); /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \
On Wed 30-08-23 12:02:47, Christian Brauner wrote: > > Yeah, good point. Done. > > From fe40c7fe1a87814f92f9b1d0b9fb78ac69404c33 Mon Sep 17 00:00:00 2001 > From: Christian Brauner <brauner@kernel.org> > Date: Tue, 29 Aug 2023 15:05:28 +0200 > Subject: [PATCH 1/2] fs: export sget_dev() > > They will be used for mtd devices as well. > > Signed-off-by: Christian Brauner <brauner@kernel.org> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/super.c | 64 ++++++++++++++++++++++++++++++++-------------- > include/linux/fs.h | 1 + > 2 files changed, 46 insertions(+), 19 deletions(-) > > diff --git a/fs/super.c b/fs/super.c > index ad7ac3a24d38..d27d80bf7c43 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -1371,6 +1371,50 @@ int get_tree_keyed(struct fs_context *fc, > } > EXPORT_SYMBOL(get_tree_keyed); > > +static int set_bdev_super(struct super_block *s, void *data) > +{ > + s->s_dev = *(dev_t *)data; > + return 0; > +} > + > +static int super_s_dev_set(struct super_block *s, struct fs_context *fc) > +{ > + return set_bdev_super(s, fc->sget_key); > +} > + > +static int super_s_dev_test(struct super_block *s, struct fs_context *fc) > +{ > + return !(s->s_iflags & SB_I_RETIRED) && > + s->s_dev == *(dev_t *)fc->sget_key; > +} > + > +/** > + * sget_dev - Find or create a superblock by device number > + * @fc: Filesystem context. > + * @dev: device number > + * > + * Find or create a superblock using the provided device number that > + * will be stored in fc->sget_key. > + * > + * If an extant superblock is matched, then that will be returned with > + * an elevated reference count that the caller must transfer or discard. > + * > + * If no match is made, a new superblock will be allocated and basic > + * initialisation will be performed (s_type, s_fs_info, s_id, s_dev will > + * be set). The superblock will be published and it will be returned in > + * a partially constructed state with SB_BORN and SB_ACTIVE as yet > + * unset. > + * > + * Return: an existing or newly created superblock on success, an error > + * pointer on failure. > + */ > +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) > +{ > + fc->sget_key = &dev; > + return sget_fc(fc, super_s_dev_test, super_s_dev_set); > +} > +EXPORT_SYMBOL(sget_dev); > + > #ifdef CONFIG_BLOCK > /* > * Lock a super block that the callers holds a reference to. > @@ -1429,23 +1473,6 @@ const struct blk_holder_ops fs_holder_ops = { > }; > EXPORT_SYMBOL_GPL(fs_holder_ops); > > -static int set_bdev_super(struct super_block *s, void *data) > -{ > - s->s_dev = *(dev_t *)data; > - return 0; > -} > - > -static int set_bdev_super_fc(struct super_block *s, struct fs_context *fc) > -{ > - return set_bdev_super(s, fc->sget_key); > -} > - > -static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc) > -{ > - return !(s->s_iflags & SB_I_RETIRED) && > - s->s_dev == *(dev_t *)fc->sget_key; > -} > - > int setup_bdev_super(struct super_block *sb, int sb_flags, > struct fs_context *fc) > { > @@ -1523,8 +1550,7 @@ int get_tree_bdev(struct fs_context *fc, > } > > fc->sb_flags |= SB_NOSEC; > - fc->sget_key = &dev; > - s = sget_fc(fc, test_bdev_super_fc, set_bdev_super_fc); > + s = sget_dev(fc, dev); > if (IS_ERR(s)) > return PTR_ERR(s); > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index ca8ceccde3d6..8a8d1cd5b0a9 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2274,6 +2274,7 @@ struct super_block *sget(struct file_system_type *type, > int (*test)(struct super_block *,void *), > int (*set)(struct super_block *,void *), > int flags, void *data); > +struct super_block *sget_dev(struct fs_context *fc, dev_t dev); > > /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ > #define fops_get(fops) \ > -- > 2.34.1 >
diff --git a/fs/super.c b/fs/super.c index ad7ac3a24d38..88cb628de6a1 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1435,12 +1435,12 @@ static int set_bdev_super(struct super_block *s, void *data) return 0; } -static int set_bdev_super_fc(struct super_block *s, struct fs_context *fc) +static int super_s_dev_set(struct super_block *s, struct fs_context *fc) { return set_bdev_super(s, fc->sget_key); } -static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc) +static int super_s_dev_test(struct super_block *s, struct fs_context *fc) { return !(s->s_iflags & SB_I_RETIRED) && s->s_dev == *(dev_t *)fc->sget_key; @@ -1500,6 +1500,13 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, } EXPORT_SYMBOL_GPL(setup_bdev_super); +struct super_block *sget_dev(struct fs_context *fc, dev_t dev) +{ + fc->sget_key = &dev; + return sget_fc(fc, super_s_dev_set, super_s_dev_test); +} +EXPORT_SYMBOL(sget_dev); + /** * get_tree_bdev - Get a superblock based on a single block device * @fc: The filesystem context holding the parameters @@ -1523,8 +1530,7 @@ int get_tree_bdev(struct fs_context *fc, } fc->sb_flags |= SB_NOSEC; - fc->sget_key = &dev; - s = sget_fc(fc, test_bdev_super_fc, set_bdev_super_fc); + s = sget_dev(fc, dev); if (IS_ERR(s)) return PTR_ERR(s); diff --git a/include/linux/fs.h b/include/linux/fs.h index ca8ceccde3d6..8a8d1cd5b0a9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2274,6 +2274,7 @@ struct super_block *sget(struct file_system_type *type, int (*test)(struct super_block *,void *), int (*set)(struct super_block *,void *), int flags, void *data); +struct super_block *sget_dev(struct fs_context *fc, dev_t dev); /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \
They will be used for mtd devices as well. Signed-off-by: Christian Brauner <brauner@kernel.org> --- fs/super.c | 14 ++++++++++---- include/linux/fs.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-)