]> www.infradead.org Git - users/hch/block.git/commitdiff
block: warn if ->groups is set when calling add_disk dax-fix
authorChristoph Hellwig <hch@lst.de>
Mon, 20 Sep 2021 06:57:15 +0000 (08:57 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 21 Sep 2021 06:30:53 +0000 (08:30 +0200)
The proper API is to pass the groups to device_add_disk, but the code
used to also allow groups being set before calling *add_disk.  Warn
about that but keep the group pointer intact for now so that it can
be removed again after a grace period.

Fixes: 52b85909f85d ("block: fold register_disk into device_add_disk")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
block/genhd.c

index 7b6e5e1cf95642adaa6a6fb53e902b6466d1f0f7..409cf608cc5bd49565ec5dc522d948b6e8ef88d3 100644 (file)
@@ -439,7 +439,8 @@ int device_add_disk(struct device *parent, struct gendisk *disk,
        dev_set_uevent_suppress(ddev, 1);
 
        ddev->parent = parent;
-       ddev->groups = groups;
+       if (!WARN_ON_ONCE(ddev->groups))
+               ddev->groups = groups;
        dev_set_name(ddev, "%s", disk->disk_name);
        if (!(disk->flags & GENHD_FL_HIDDEN))
                ddev->devt = MKDEV(disk->major, disk->first_minor);