md device allocation cleanups
Hi all,
this small series cleans up the mddev allocation a bit by returning the structure to callers that want it instead of requiring another lookup.
PATCH 1/2 md: open code md_probe in autorun_devices
autorun_devices should not be limited to the controls for the legacy probe on open, so just call md_alloc directly.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -6500,7 +6500,7 @@ static void autorun_devices(int part)break ; } -md_probe (dev); +md_alloc (dev,NULL ); mddev =mddev_find (dev);if (!mddev)break ;
Signature · 1 line
2.30.2
Re: [PATCH 1/2] md: open code md_probe in autorun_devices
Quoted 13 lines · Christoph Hellwig
autorun_devicesshould not be limited to the controls for the legacy probe on open, so just callmd_allocdirectly.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/md.c +0
-0
drivers/md/md.c static void autorun_devices(int part) · line 6506
Quoted 8 lines
drivers/md/md.c +1
-1@@ -6500,7 +6500,7 @@ static void autorun_devices(int part)break ; } -md_probe (dev); +md_alloc (dev,NULL ); mddev =mddev_find (dev);if (!mddev)break ;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
PATCH 2/2 md: return the allocated devices from md_alloc
In reply to Christoph HellwigTwo callers of md_alloc want to use the newly allocated devices, so return it instead of letting them find it cumbersomely after the allocation.
--- drivers/md/md-autodetect.c | 22 +++++----------- drivers/md/md.c | 54 ++++++++++++++++---------------------- drivers/md/md.h | 3 ++- 3 files changed, 30 insertions(+), 49 deletions(-)
drivers/md/md-autodetect.c +6 -16
@@ -125,7 +125,6 @@ static void __init md_setup_drive(struct md_setup_args *args)char *devname = args->device_names;dev_t devices[MD_SB_DISKS +1 ], mdev;struct mdu_array_info_s ainfo = { }; -struct block_device *bdev;struct mddev *mddev;int err =0 , i;char name[16 ];
@@ -169,25 +168,16 @@ static void __init md_setup_drive(struct md_setup_args *args)pr_info ("md: Loading %s: %s\n" , name, args->device_names); -md_alloc (mdev, name); - bdev =blkdev_get_by_dev (mdev,FMODE_READ ,NULL ); -if (IS_ERR (bdev)) { -pr_err ("md: open failed - cannot start array %s\n" , name); + mddev =md_alloc (mdev, name); +if (IS_ERR (mddev)) { +pr_err ("md: md_alloc failed - cannot start array %s\n" , name);return ; } - err = -EIO ; -if (WARN (bdev->bd_disk->fops != &md_fops, -"Opening block device %x resulted in non-md device\n" , - mdev)) - goto out_blkdev_put; - - mddev = bdev->bd_disk->private_data; - err =mddev_lock (mddev);if (err) {pr_err ("md: failed to lock array %s\n" , name); - goto out_blkdev_put; + goto out_mddev_put; }if (!list_empty (&mddev->disks) || mddev->raid_disks) {
@@ -231,8 +221,8 @@ static void __init md_setup_drive(struct md_setup_args *args)pr_warn ("md: starting %s failed\n" , name); out_unlock:mddev_unlock (mddev); -out_blkdev_put: -blkdev_put (bdev,FMODE_READ ); +out_mddev_put: +mddev_put (mddev); }static int __init raid_setup (char *str)
drivers/md/md.c +22 -32
112 lines not on this page · raw message
drivers/md/md.h +2 -1
@@ -767,7 +767,8 @@ extern int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev);extern int strict_strtoul_scaled (const char *cp,unsigned long *res,int scale);extern void mddev_init (struct mddev *mddev); -int md_alloc (dev_t dev,char *name); +struct mddev *md_alloc (dev_t dev,char *name); +void mddev_put (struct mddev *mddev);extern int md_run (struct mddev *mddev);extern int md_start (struct mddev *mddev);extern void md_stop (struct mddev *mddev);
Signature · 1 line
2.30.2
Re: [PATCH 2/2] md: return the allocated devices from md_alloc
Quoted 11 lines · Christoph Hellwig
Two callers of
md_allocwant to use the newly allocated devices, so return it instead of letting them find it cumbersomely after the allocation.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/md/md-autodetect.c | 22 +++++----------- drivers/md/md.c | 54 ++++++++++++++++---------------------- drivers/md/md.h | 3 ++- 3 files changed, 30 insertions(+), 49 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Logan Gunthorpe
Reviewed-byQuoted 5 lines · Christoph Hellwig
Hi all,
this small series cleans up the mddev allocation a bit by returning the structure to callers that want it instead of requiring another lookup.
I've reviewed and tested these two patches and they look good to me.
Thanks,
Logan
Quoted 9 lines · Logan Gunthorpe
Quoted 5 lines · Christoph Hellwig
Hi all,
this small series cleans up the mddev allocation a bit by returning the structure to callers that want it instead of requiring another lookup.
Applied to md-next. Thanks!
Quoted 4 lines
I've reviewed and tested these two patches and they look good to me.
Reviewed-by Logan Gunthorpe <[email protected]>
I changed this to
Please let me know if you think this is not appropriate.
Thanks,
Song