[PATCH 11/18] misc: storage-by-uuid: consider only first diskuuid match

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Apr 14 03:31:35 PDT 2025


Hello Marco,

On 4/14/25 12:24, Marco Felsch wrote:
> On 25-04-14, Ahmad Fatoum wrote:
>> Multiple devices with the same disk UUID shouldn't happen and if it
> 
> Do we need to print a warning to inform the user that two disks share
> the same disk-UUID?

If we do, we should do it a generic place like when disks are registered
the first time with a duplicate UUID and not at consumers like here.

Cheers,
Ahmad

> 
> Regards,
>   Marco
> 
>> does, the existing code is not equipped to handle that.
>>
>> Change  it, so only the first _disk_ is considered. diskuuid is in a
>> union with partuuid and that could lead to cdev partition being taken as
>> backend storage instead.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
>> ---
>>  drivers/misc/storage-by-uuid.c | 12 ++++++++----
>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c
>> index 8b8fd901685e..7bb987dffbec 100644
>> --- a/drivers/misc/storage-by-uuid.c
>> +++ b/drivers/misc/storage-by-uuid.c
>> @@ -143,10 +143,14 @@ static void check_exist(struct sbu *sbu)
>>  	struct cdev *cdev;
>>  
>>  	for_each_cdev(cdev) {
>> -		if (!strcmp(cdev->diskuuid, sbu->uuid)) {
>> -			dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->diskuuid);
>> -			storage_by_uuid_add_partitions(sbu, cdev);
>> -		}
>> +		if (cdev_is_partition(cdev))
>> +			continue;
>> +		if (strcmp(cdev->diskuuid, sbu->uuid))
>> +			continue;
>> +
>> +		dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->diskuuid);
>> +		storage_by_uuid_add_partitions(sbu, cdev);
>> +		return;
>>  	}
>>  }
>>  
>> -- 
>> 2.39.5
>>
>>
>>
> 

-- 
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 |




More information about the barebox mailing list