Kostik Belousov wrote:
> On Wed, Apr 27, 2011 at 12:10:26AM +0000, Alexander Motin wrote:
>> Author: mav
>> Date: Wed Apr 27 00:10:26 2011
>> New Revision: 221101
>> URL: http://svn.freebsd.org/changeset/base/221101
>>
>> Log:
>>   Implement relaxed comparision for hardcoded provider names to make it
>>   ignore adX/adaY difference in both directions to simplify migration to
>>   the CAM-based ATA or back.
>>
>> Modified:
>>   head/sys/geom/concat/g_concat.c
>>   head/sys/geom/geom.h
>>   head/sys/geom/geom_subr.c
>>   head/sys/geom/journal/g_journal.c
>>   head/sys/geom/mirror/g_mirror.c
>>   head/sys/geom/raid3/g_raid3.c
>>   head/sys/geom/shsec/g_shsec.c
>>   head/sys/geom/stripe/g_stripe.c
>>   head/sys/geom/virstor/g_virstor.c
>>
>> Modified: head/sys/geom/concat/g_concat.c
>> ==============================================================================
>> --- head/sys/geom/concat/g_concat.c  Tue Apr 26 23:00:32 2011        
>> (r221100)
>> +++ head/sys/geom/concat/g_concat.c  Wed Apr 27 00:10:26 2011        
>> (r221101)
>> @@ -678,7 +678,8 @@ g_concat_taste(struct g_class *mp, struc
>>      if (md.md_version < 4)
>>              md.md_provsize = pp->mediasize;
>>  
>> -    if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0)
>> +    if (md.md_provider[0] != '\0' &&
>> +        !g_compare_names(md.md_provider, pp->name))
>>              return (NULL);
>>      if (md.md_provsize != pp->mediasize)
>>              return (NULL);
>>
>> Modified: head/sys/geom/geom.h
>> ==============================================================================
>> --- head/sys/geom/geom.h     Tue Apr 26 23:00:32 2011        (r221100)
>> +++ head/sys/geom/geom.h     Wed Apr 27 00:10:26 2011        (r221101)
>> @@ -238,6 +238,7 @@ void g_waitidlelock(void);
>>  /* geom_subr.c */
>>  int g_access(struct g_consumer *cp, int nread, int nwrite, int nexcl);
>>  int g_attach(struct g_consumer *cp, struct g_provider *pp);
>> +int g_compare_names(const char *namea, const char *nameb);
>>  void g_destroy_consumer(struct g_consumer *cp);
>>  void g_destroy_geom(struct g_geom *pp);
>>  void g_destroy_provider(struct g_provider *pp);
>>
>> Modified: head/sys/geom/geom_subr.c
>> ==============================================================================
>> --- head/sys/geom/geom_subr.c        Tue Apr 26 23:00:32 2011        
>> (r221100)
>> +++ head/sys/geom/geom_subr.c        Wed Apr 27 00:10:26 2011        
>> (r221101)
>> @@ -1017,6 +1017,43 @@ g_getattr__(const char *attr, struct g_c
>>      return (0);
>>  }
>>  
>> +static int
>> +g_get_device_prefix_len(const char *name)
>> +{
>> +    int len;
>> +
>> +    if (strncmp(name, "ada", 3) == 0)
>> +            len = 3;
>> +    else if (strncmp(name, "ad", 2) == 0)
>> +            len = 2;
>> +    else
>> +            return (0);
>> +    if (name[len] < '0' || name[len] > '9')
>> +            return (0);
>> +    do {
>> +            len++;
>> +    } while (name[len] >= '0' && name[len] <= '9');
>> +    return (len);
>> +}
>> +
>> +int
>> +g_compare_names(const char *namea, const char *nameb)
>> +{
>> +    int deva, devb;
>> +
>> +    if (strcmp(namea, nameb) == 0)
>> +            return (1);
>> +    deva = g_get_device_prefix_len(namea);
>> +    if (deva == 0)
>> +            return (0);
>> +    devb = g_get_device_prefix_len(nameb);
>> +    if (devb == 0)
>> +            return (0);
>> +    if (strcmp(namea + deva, nameb + devb) == 0)
>> +            return (1);
>> +    return (0);
>> +}
>> +
> This is most likely my misunderstanding of things.
> 
> Can we have a legitimate situation where both ada* and ad* devices coexist
> on the same system ? E.g. on-board AHCI and legacy PATA controller ?

Yes, we can and sometimes do. But the new GENERIC kernels in CURRENT
switch everything to the adaX.

> Wouldn't this hack then wreak the havoc ? Can the hack be put under the
> control of some tunable ?

I can't imagine useful situation when device name part of the hardcoded
provider name is important. Only partition name sometimes is.

-- 
Alexander Motin
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to