md: Fix integrity registration error when no devices are capable

We incorrectly returned -EINVAL when none of the devices in the array
had an integrity profile. This in turn prevented mdadm from starting
the metadevice. Fix this so we only return errors on mismatched
profiles and memory allocation failures.

Reported-by: Giacomo Catenazzi <cate@cateee.net>
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Martin K. Petersen and committed by Linus Torvalds 89078d57 7de8e573

+2 -6
+2 -6
drivers/md/md.c
··· 1777 1777 continue; 1778 1778 if (rdev->raid_disk < 0) 1779 1779 continue; 1780 - /* 1781 - * If at least one rdev is not integrity capable, we can not 1782 - * enable data integrity for the md device. 1783 - */ 1784 - if (!bdev_get_integrity(rdev->bdev)) 1785 - return -EINVAL; 1786 1780 if (!reference) { 1787 1781 /* Use the first rdev as the reference */ 1788 1782 reference = rdev; ··· 1787 1793 rdev->bdev->bd_disk) < 0) 1788 1794 return -EINVAL; 1789 1795 } 1796 + if (!reference || !bdev_get_integrity(reference->bdev)) 1797 + return 0; 1790 1798 /* 1791 1799 * All component devices are integrity capable and have matching 1792 1800 * profiles, register the common profile for the md device.