On 7/24/25 11:13, Marco Felsch wrote: > Before commit a6410cfa9aff ("block: mark underlying cdev with > DEVFS_IS_BLOCK_DEV") the block device decision was made based on the > block_ops. Since each parition-cdev inherits the parent (master) > cdev-ops the parition-cdevs were detected as block device. > > Commit a6410cfa9aff the detection mechanism to be based on cdev flag but > commit a6410cfa9aff forgot to pass the flag to the partition (child) > cdev. > > Fix this by passing the DEVFS_IS_BLOCK_DEV to the partition (child) cdev > as well. Add a small helper function to query the inheritable devfs > flags instead of open coding it within __devfs_add_partition(). > > Fixes: a6410cfa9aff ("block: mark underlying cdev with DEVFS_IS_BLOCK_DEV")
Reviewed-by: Ahmad Fatoum <a.fat...@pengutronix.de> > Signed-off-by: Marco Felsch <m.fel...@pengutronix.de> > --- > fs/devfs-core.c | 4 ++-- > include/driver.h | 10 ++++++++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/fs/devfs-core.c b/fs/devfs-core.c > index 73a13be7336d..f80281aaf91c 100644 > --- a/fs/devfs-core.c > +++ b/fs/devfs-core.c > @@ -584,7 +584,7 @@ static struct cdev *__devfs_add_partition(struct cdev > *cdev, > loff_t _end = end ? *end : 0; > static struct cdev *new; > struct cdev *overlap; > - unsigned inherited_flags = 0; > + unsigned inherited_flags; > > if (cdev_by_name(partinfo->name)) > return ERR_PTR(-EEXIST); > @@ -628,7 +628,7 @@ static struct cdev *__devfs_add_partition(struct cdev > *cdev, > } > > /* Filter flags that we want to pass along to children */ > - inherited_flags |= cdev->flags & DEVFS_WRITE_AUTOERASE; > + inherited_flags = get_inheritable_devfs_flags(cdev); > > if (IS_ENABLED(CONFIG_MTD) && cdev->mtd) { > struct mtd_info *mtd; > diff --git a/include/driver.h b/include/driver.h > index dd50a7aa3cce..01e04578540b 100644 > --- a/include/driver.h > +++ b/include/driver.h > @@ -627,6 +627,16 @@ static inline bool cdev_is_gpt_partitioned(const struct > cdev *master) > return master && (master->flags & DEVFS_IS_GPT_PARTITIONED); > } > > +#define DEVFS_INHERITABLE_FLAGS (DEVFS_WRITE_AUTOERASE | DEVFS_IS_BLOCK_DEV) > + > +static inline unsigned int > +get_inheritable_devfs_flags(const struct cdev *parent_cdev) > +{ > + if (!parent_cdev) > + return 0; > + return parent_cdev->flags & DEVFS_INHERITABLE_FLAGS; > +} > + > struct cdev * > cdev_find_child_by_gpt_typeuuid(struct cdev *cdev, const guid_t *typeuuid); > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |