Date: Fri, 10 Jun 2011 09:12:10 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r222920 - in stable/8/sys/geom: . concat journal mirror raid3 shsec stripe virstor Message-ID: <201106100912.p5A9CAkd018421@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Jun 10 09:12:09 2011 New Revision: 222920 URL: http://svn.freebsd.org/changeset/base/222920 Log: MFC r221101: 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: stable/8/sys/geom/concat/g_concat.c stable/8/sys/geom/geom.h stable/8/sys/geom/geom_subr.c stable/8/sys/geom/journal/g_journal.c stable/8/sys/geom/mirror/g_mirror.c stable/8/sys/geom/raid3/g_raid3.c stable/8/sys/geom/shsec/g_shsec.c stable/8/sys/geom/stripe/g_stripe.c stable/8/sys/geom/virstor/g_virstor.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/geom/concat/g_concat.c ============================================================================== --- stable/8/sys/geom/concat/g_concat.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/concat/g_concat.c Fri Jun 10 09:12:09 2011 (r222920) @@ -675,7 +675,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: stable/8/sys/geom/geom.h ============================================================================== --- stable/8/sys/geom/geom.h Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/geom.h Fri Jun 10 09:12:09 2011 (r222920) @@ -231,6 +231,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: stable/8/sys/geom/geom_subr.c ============================================================================== --- stable/8/sys/geom/geom_subr.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/geom_subr.c Fri Jun 10 09:12:09 2011 (r222920) @@ -1016,6 +1016,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); +} + #if defined(DIAGNOSTIC) || defined(DDB) /* * This function walks the mesh and returns a non-zero integer if it Modified: stable/8/sys/geom/journal/g_journal.c ============================================================================== --- stable/8/sys/geom/journal/g_journal.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/journal/g_journal.c Fri Jun 10 09:12:09 2011 (r222920) @@ -2526,7 +2526,8 @@ g_journal_taste(struct g_class *mp, stru return (NULL); gp = NULL; - 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 != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/8/sys/geom/mirror/g_mirror.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/mirror/g_mirror.c Fri Jun 10 09:12:09 2011 (r222920) @@ -3006,7 +3006,8 @@ g_mirror_taste(struct g_class *mp, struc return (NULL); gp = NULL; - 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 != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/raid3/g_raid3.c ============================================================================== --- stable/8/sys/geom/raid3/g_raid3.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/raid3/g_raid3.c Fri Jun 10 09:12:09 2011 (r222920) @@ -3328,7 +3328,8 @@ g_raid3_taste(struct g_class *mp, struct return (NULL); gp = NULL; - 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 != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/shsec/g_shsec.c ============================================================================== --- stable/8/sys/geom/shsec/g_shsec.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/shsec/g_shsec.c Fri Jun 10 09:12:09 2011 (r222920) @@ -670,7 +670,8 @@ g_shsec_taste(struct g_class *mp, struct if (md.md_version < 1) 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: stable/8/sys/geom/stripe/g_stripe.c ============================================================================== --- stable/8/sys/geom/stripe/g_stripe.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/stripe/g_stripe.c Fri Jun 10 09:12:09 2011 (r222920) @@ -949,7 +949,8 @@ g_stripe_taste(struct g_class *mp, struc if (md.md_version < 3) 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: stable/8/sys/geom/virstor/g_virstor.c ============================================================================== --- stable/8/sys/geom/virstor/g_virstor.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/virstor/g_virstor.c Fri Jun 10 09:12:09 2011 (r222920) @@ -807,10 +807,9 @@ g_virstor_taste(struct g_class *mp, stru /* If the provider name is hardcoded, use the offered provider only * if it's been offered with its proper name (the one used in * the label command). */ - if (md.provider[0] != '\0') { - if (strcmp(md.provider, pp->name) != 0) - return (NULL); - } + if (md.provider[0] != '\0' && + !g_compare_names(md.provider, pp->name)) + return (NULL); /* Iterate all geoms this class already knows about to see if a new * geom instance of this class needs to be created (in case the provider
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106100912.p5A9CAkd018421>